Browse Source

This successfully builds a working bikebike rails app with Docker!

Jonathan Rosenbaum 3 years ago
parent
commit
0a55db70c4
  1. 4
      .gitignore
  2. 43
      Dockerfile
  3. 16
      Gemfile
  4. 11
      README.md
  5. 4
      app/assets/config/manifest.js
  6. 8
      app/helpers/i18n_helper.rb
  7. 6
      app/mailers/user_mailer.rb
  8. BIN
      bumbleberry-css.tar.gz
  9. 19
      config/environments/production.rb
  10. 12
      docker-compose.build
  11. 89
      docker-compose.yml
  12. 8
      entrypoint.sh

4
.gitignore

@ -8,7 +8,9 @@
!.openshift
*~
# Docker.gitignore
.env
bike_bike_advanced_environment
# OSX.gitignore
.DS_Store

43
Dockerfile

@ -0,0 +1,43 @@
############
# BikeBike #
############
FROM ruby:2.5
MAINTAINER Jonathan Rosenbaum <bike@bikelover.org>
##RUN git clone https://github.com/fspc/BikeBikeBike.git /app/BikeBike
COPY . /app/BikeBike
RUN apt-get update && apt-get install -y nodejs postgresql-client
# Note: phantomjs has been deprecated in favor of headless chrome
WORKDIR /app/BikeBike
# COPY changes/Gemfile .
# Use DATABASE_URL env variable instead, although it takes precedence, regardless
# COPY database.yml ./config/database.yml
RUN bundle install
RUN mkdir -p public/stylesheets/application -p public/stylesheets/web-fonts && tar xvfz bumbleberry-css.tar.gz -C public/stylesheets/application && tar xvfz bumbleberry-css.tar.gz -C public/stylesheets/web-fonts
#RUN gem install json -v '1.8.6'
#RUN gem install activesupport -v '4.2.0'
#RUN gem install mini_portile2 -v '2.6.1'
#RUN gem install racc -v '1.6.0'
#RUN gem install actionview -v '4.2.0'
# Gem::LoadError: You have already activated rake 12.3.3, but your Gemfile requires rake 11.1.2. Prepending `bundle exec` to your command may solve this.
# Do this with docker-compose
# RUN rake db:create
# RUN rake db:migrate
# Add a script to be executed every time the container starts.
COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000
# Configure the main process to run when running the image
CMD ["rails", "server", "-b", "0.0.0.0"]

16
Gemfile

@ -1,9 +1,9 @@
source 'http://rubygems.org'
gem 'rails', '4.2.0'
gem 'pg'
gem 'rake', '11.1.2'
gem 'ruby_dep', '1.3.1' # Lock at 1.3.1 since 1.4 requires ruby 2.5. We should unlock once we upgrade the ruby version on our server
gem 'rails', '4.2.8'
gem 'pg', '0.21.0'
gem 'rake', '12.3.3'
gem 'ruby_dep', '1.4' # Lock at 1.3.1 since 1.4 requires ruby 2.5. We should unlock once we upgrade the ruby version on our server
gem 'rack-mini-profiler'
@ -41,17 +41,18 @@ gem 'sitemap_generator'
gem 'sass-json-vars'
gem 'redcarpet'
gem 'to_spreadsheet', git: 'https://github.com/glebm/to_spreadsheet.git'
gem 'net-ssh', '4.1.0'
group :development do
gem 'better_errors', '2.2.0'
gem 'binding_of_caller'
gem 'meta_request'
gem 'capistrano', '~> 3.1'
gem 'capistrano-rails', '~> 1.1'
gem 'capistrano-faster-assets', '~> 1.0'
gem 'eventmachine', git: 'https://github.com/krzcho/eventmachine', :branch => 'master'
gem 'eventmachine', git: 'https://github.com/eventmachine/eventmachine', :branch => 'master'
gem 'thin'
gem 'rubocop', require: false
gem 'haml-lint', require: false
@ -67,6 +68,7 @@ group :test do
gem 'guard-cucumber'
gem 'poltergeist'
gem 'capybara', '2.15.1'
gem 'capybara-email'
gem 'guard-rspec'
gem 'factory_girl_rails'
@ -93,7 +95,7 @@ end
platforms 'mswin', 'mingw' do
gem 'tzinfo-data'
group :test do
gem 'wdm', '>= 0.1.0'
gem 'win32console', require: false

11
README.md

@ -5,6 +5,17 @@
| Development | [![Development Build Status](https://travis-ci.org/bikebike/BikeBike.svg?branch=development)](https://travis-ci.org/bikebike/BikeBike) |
| Production | [![Production Build Status](https://travis-ci.org/bikebike/BikeBike.svg?branch=master)](https://travis-ci.org/bikebike/BikeBike) |
## About this Fork
The Tech group for BikeBike!Everywhere! decided to utilize this conferencing/scheduling software for the next BikeBike.
This repository creates a test environment so that we can test/fix issues before manually committing them to the live site.
Instructions can be found in docker-compose.yml, and docker-compose.build.
## From bikebike/bikebike
This is the repository for the Bike!Bike! website. It can be found in development at [preview.bikebike.org](https://preview-en.bikebike.org/) and in production at [bikebike.org](https://bikebike.org/)
Feel free to clone or fork the repository any time to start working on new features or fixes. To get help create an issue or contact Godwin: `goodgodwin` `@` `hotmail.com` any time.

4
app/assets/config/manifest.js

@ -0,0 +1,4 @@
//= link_tree ../images
//= link_directory ../javascripts .js
//= link_directory ../stylesheets .scss
//= link_directory ../fonts

8
app/helpers/i18n_helper.rb

@ -5,8 +5,8 @@ module I18nHelper
url ||= current_path(true)
return url if Rails.env.development? || Rails.env.test?
return "https://preview-#{locale.to_s}.bikebike.org#{url}" if Rails.env.preview?
"https://#{locale.to_s}.bikebike.org#{url}"
return "https://preview-#{locale.to_s}." + ENV['DEFAULT_URL'] + "#{url}" if Rails.env.preview?
"https://#{locale.to_s}." + ENV['DEFAULT_URL'] + "#{url}"
end
def current_path(relative = false)
@ -21,13 +21,13 @@ module I18nHelper
return url_for(new_params) if relative
subdomain = Rails.env.preview? ? "preview-#{locale.to_s}" : locale.to_s
url_for(new_params.merge(host: "#{subdomain}.bikebike.org"))
url_for(new_params.merge(host: "#{subdomain}." + ENV['DEFAULT_URL']))
end
def canonical_url
url = current_path
return url if Rails.env.development? || Rails.env.test?
return "https://preview.bikebike.org#{url}" if Rails.env.preview?
return ENV['DEFAULT_URL'] + "#{url}" if Rails.env.preview?
"https://bikebike.org#{url}"
end

6
app/mailers/user_mailer.rb

@ -6,7 +6,7 @@ class UserMailer < ActionMailer::Base
before_filter :set_host
default from: "Bike!Bike! <info@bikebike.org>"
default from: "Bike!Bike! <" + ENV['SMTP_USER_NAME'] + ">"
def email_confirmation(confirmation)
@confirmation = EmailConfirmation.find_by_id(confirmation) if confirmation.present?
@ -172,9 +172,9 @@ class UserMailer < ActionMailer::Base
private
def set_host(*args)
if Rails.env.production?
@host = "https://#{I18n.locale.to_s}.bikebike.org"
@host = "https://#{I18n.locale.to_s}." + ENV['DEFAULT_URL']
elsif Rails.env.preview?
@host = "https://preview-#{I18n.locale.to_s}.bikebike.org"
@host = "https://preview-#{I18n.locale.to_s}." + ENV['DEFAULT_URL']
else
@host = UserMailer.default_url_options[:host]
end

BIN
bumbleberry-css.tar.gz

Binary file not shown.

19
config/environments/production.rb

@ -28,7 +28,7 @@ BikeBike::Application.configure do
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
#config.assets.compile = true
config.assets.compile = true
# Generate digests for assets URLs.
config.assets.digest = true
@ -46,8 +46,6 @@ BikeBike::Application.configure do
# Set to :debug to see everything in the log.
config.log_level = :info
config.assets.compile = false
# Prepend all log lines with the following tags.
config.log_tags = [ :subdomain, :uuid ]
@ -61,7 +59,8 @@ BikeBike::Application.configure do
# config.action_controller.asset_host = "http://assets.example.com"
# Precompile additional assets.
config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif *.json *.ttf *.otf *.woff *.woff2 *.svg *.json)
#config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif *.json *.ttf *.otf *.woff *.woff2 *.svg *.json)
config.assets.precompile = ["manifest.js"]
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
@ -82,18 +81,18 @@ BikeBike::Application.configure do
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
domain: 'bikebike.org',
port: 587,
address: config.app_config['smtp_address'],
domain: config.app_config['smtp_domain'],
port: config.app_config['smtp_port'],
authentication: :plain,
enable_starttls_auto: true,
openssl_verify_mode: 'none',
user_name: 'info@bikebike.org',
password: config.app_config['email_password']
user_name: config.app_config['smtp_user_name'],
password: config.app_config['smtp_password']
}
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
I18n.config.language_detection_method = I18n::Config::DETECT_LANGUAGE_FROM_SUBDOMAIN
config.action_controller.default_url_options = { host: 'https://bikebike.org', trailing_slash: true }
config.action_controller.default_url_options = { host: config.app_config['default_url'], trailing_slash: true }
Sidekiq::Extensions.enable_delay!
end

12
docker-compose.build

@ -0,0 +1,12 @@
#!/bin/bash
# This assume docker-compose build, which takes a long time and builds the image, has already happened,
# it should on up -d.
# Also, you may need to remove and create the external volumes again for the steps
# below to work correctly.
docker-compose up -d
docker-compose run bikebike rake db:setup
docker-compose run bikebike rake db:migrate
docker-compose run bikebike rake assets:precompile
docker-compose down
docker-compose up -d

89
docker-compose.yml

@ -0,0 +1,89 @@
# BikeBike
#
# ENV DATABASE_URL string = https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING
#
# docker-compose up -d
# docker-compose run bikebike rake db:setup
# docker-compose run bikebike rake db:migrate
# docker-compose run bikebike rake assets:precompile
# docker-compose down
# docker-compose up
#
# don't do this because new sprockets and manifest.js isn't precompiling to *css, and breaks the container
# -- docker-compose run bikebike rake bumbleberry:update --
version: '3'
services:
db:
container_name: bikebikebike-db
image: postgres:9.5
ports:
- "5432"
restart: always
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
volumes:
- bikebikebike_db:/var/lib/postgresql/data
environment:
- POSTGRES_PASSWORD=password
- POSTGRES_USER=bike_bike
- POSTGRES_DB=bike_bike
bikebike:
build: .
image: bikebikebike
container_name: bikebikebike
networks:
letsencrypt:
default:
command: /bin/sh -c "rm -f /app/BikeBike/tmp/pids/server.pid && rails server -e production -b '0.0.0.0'"
# Add environment values that are not in .env (environment:) below in the bike_bike_advanced_environment file
# Empty file ok, too, or just comment out this section
env_file:
- bike_bike_advanced_environment
# Add your own environment values in .env, or use the default ones
environment:
- PORT=3000
- DATABASE_URL=${DATABASE_URL:-postgresql://bike_bike:password@db/bike_bike?encoding=unicode&pool=5}
- RAILS_ENV=${RAILS_ENV:-production rails assets:precompile.log}
- SMTP_ADDRESS=${SMTP_ADDRESS:-fake-smtp.bikebike.org}
- SMTP_DOMAIN=${SMTP_DOMAIN:-bikebike.org}
- SMTP_PORT=${SMTP_PORT:-587}
- SMTP_USER_NAME=${SMTP_USER_NAME:-info@bikebike.org}
- SMTP_PASSWORD=${SMTP_PASSWORD:-fake}
- DEFAULT_URL=${DEFAULT_URL:-bikebike.org}
volumes:
- bikebikebike:/app/BikeBike
- bikebikebike_bundle:/usr/local/bundle
build: .
expose:
- "3000"
links:
- db
restart: always
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# Create this volumes, docker volume create me
# or comment our external
volumes:
bikebikebike_db:
external: true
bikebikebike:
external: true
bikebikebike_bundle:
external: true
# Remove this network if you don't use it
networks:
letsencrypt:
external: true

8
entrypoint.sh

@ -0,0 +1,8 @@
#!/bin/bash
set -e
# Remove a potentially pre-existing server.pid for Rails.
rm -f /app/BikeBike/tmp/pids/server.pid
# Then exec the container's main process (what's set as CMD in the Dockerfile).
exec "$@"
Loading…
Cancel
Save