Browse Source

History is made for the first demo of Bikeshed

master
Jonathan Rosenbaum 10 years ago
commit
995f8b4d9c
  1. 42
      Dockerfile
  2. 5
      bikeshed.conf
  3. BIN
      extjs-4.1.1.zip
  4. 11
      pg_hba.conf
  5. 7
      postgresql.conf
  6. 59
      seeds.rb

42
Dockerfile

@ -0,0 +1,42 @@
############
# BikeShed #
############
# login for test users on website
FROM bikebike/bikebike
MAINTAINER Jonathan Rosenbaum <gnuser@gmail.com>
RUN git clone git://github.com/spacemunkay/BikeShed.git
RUN gem install bundler
RUN apt-get update && apt-get -y install libpq-dev postgresql-9.3 g++ unzip
RUN bundle install --gemfile=/BikeShed/Gemfile; \
cd /BikeShed; gem install rake -v '10.1.1'; \
gem install therubyracer -v '0.10.2'
COPY pg_hba.conf /etc/postgresql/9.3/main/pg_hba.conf
# Because of an undefined constant SeedBike
COPY seeds.rb /BikeShed/db/seeds.rb
RUN cp /BikeShed/config/database.yml.example /BikeShed/config/database.yml; \
service postgresql start; \
cd /BikeShed; \
sudo -u postgres -i createuser -d -w velocipede; \
adduser --disabled-password --gecos "" velocipede; \
sudo -u velocipede -i createdb -U velocipede --owner=velocipede velocipede; \
sudo -u velocipede -i createdb -U velocipede --owner=velocipede velocipede_test; \
bundle exec rake db:create db:migrate; \
bundle exec rake db:seed
COPY postgresql.conf bikeshed.conf /etc/supervisor/conf.d/
#COPY bikeshed.conf /etc/supervisor/conf.d/
COPY extjs-4.1.1.zip /BikeShed/
RUN cd /BikeShed; \
unzip extjs-4.1.1.zip; \
ln -s /BikeShed/ext-4.1.1a /BikeShed/public/extjs
CMD ["supervisord", "-c", "/etc/supervisor/supervisord.conf"]
# docker run -d -p 3000:3000 --name="freehub" bikebike/freehub

5
bikeshed.conf

@ -0,0 +1,5 @@
[program:bikeshed]
priority=200
directory=/BikeShed
command=rails s
autorestart=false

BIN
extjs-4.1.1.zip

Binary file not shown.

11
pg_hba.conf

@ -0,0 +1,11 @@
# Database administrative login by Unix domain socket
local all postgres peer
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 md5

7
postgresql.conf

@ -0,0 +1,7 @@
[program:postgres]
priority = 100
user = postgres
command = /usr/lib/postgresql/9.3/bin/postgres -D /var/lib/postgresql/9.3/main -c config_file=/etc/postgresql/9.3/main/postgresql.conf
autostart = true
autorestart = true
startsecs = 10

59
seeds.rb

@ -0,0 +1,59 @@
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
require 'active_record/fixtures'
#Load defaults from db/seed/fixtures
Dir.glob(File.join(Rails.root, 'db', 'seed', 'fixtures', '**', '*.{yml,csv}')).each do |fixture_file, something|
ActiveRecord::Fixtures.create_fixtures(File.dirname(fixture_file), File.basename(fixture_file, '.*'))
end
#Load bike brands and models from sql
if BikeBrand.all.empty? and BikeModel.all.empty?
# Need to use DEFAULT instead of explicit IDs that are used in the sql file,
# so that the PG table ID sequence is incremented
#
# Note the drop(1) which assumes we have a junk PRAGMA line at the top
load_statements = File.readlines(File.join(Rails.root, 'db', 'seed', 'sql', 'bike_brands_and_models.sql')).drop(1).map do |statement|
statement.sub(/VALUES\(\d+,/, 'VALUES(DEFAULT,')
end
ActiveRecord::Base.connection.execute(load_statements.join)
end
if Rails.env.development?
#create default users
if User.all.empty?
u = FactoryGirl.create(:user)
FactoryGirl.create(:user_profile, user_id: u.id)
u = FactoryGirl.create(:staff)
FactoryGirl.create(:user_profile, user_id: u.id)
u = FactoryGirl.create(:bike_admin)
FactoryGirl.create(:user_profile, user_id: u.id)
u = FactoryGirl.create(:admin)
FactoryGirl.create(:user_profile, user_id: u.id)
end
#create fake bikes
if Bike.all.empty?
42.times do |n|
# FactoryGirl.create(:seed_bike)
end
end
elsif Rails.env.production?
unless User.find_by_username('admin')
#create an admin
admin = User.create!( :username => 'admin',
:first_name => 'admin',
:last_name => 'admin',
:email=>'admin@example.com',
:password=>'password')
admin.roles << Role.find_by_role('admin')
end
end
Loading…
Cancel
Save