From 3984ad2442f2feca43174165f21ff840f7248bde Mon Sep 17 00:00:00 2001 From: Ari Timonen Date: Sat, 14 Apr 2018 13:02:58 +0000 Subject: [PATCH] Fix docker image Fix bunch of things with docker and add entry.sh --- .gitignore | 1 + Dockerfile | 13 +++++++++---- config/application.rb | 1 + config/database.yml | 2 +- config/environments/production.rb | 5 ++++- entry.sh | 6 ++++++ fig.yml | 12 +++++++----- 7 files changed, 29 insertions(+), 11 deletions(-) create mode 100755 entry.sh diff --git a/.gitignore b/.gitignore index c9d3f82..b782149 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ /log/* /tmp/* /spec/tmp/* +/env/* .ruby-version .ruby-gemset .env diff --git a/Dockerfile b/Dockerfile index e1b6af5..ea536ed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,10 +29,15 @@ USER web WORKDIR /var/www COPY .env /var/www/ -RUN bundle install --path /var/bundle -RUN bundle exec rake assets:precompile +RUN bundle install --path /var/bundle --jobs 4 +#RUN bundle exec rake assets:precompile -# When using bash USER root -CMD ["bundle", "exec", "puma", "-C /var/www/config/puma.rb"] +RUN apt-get install -y memcached +RUN service memcached start + +#USER root + +USER web +CMD ["/var/www/entry.sh"] diff --git a/config/application.rb b/config/application.rb index aaa2b35..1ce42b6 100644 --- a/config/application.rb +++ b/config/application.rb @@ -10,6 +10,7 @@ module Ensl # Additional assets config.assets.precompile += ["themes/*/theme.css", "themes/*/errors.css"] + config.assets.initialize_on_precompile = false # Custom directories with classes and modules you want to be autoloadable. config.autoload_paths += Dir["#{config.root}/app/services/**/", "#{config.root}/app/models/concerns/"] diff --git a/config/database.yml b/config/database.yml index b2dfeb0..bb0011b 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,7 +1,7 @@ base: &db adapter: mysql2 encoding: utf8 - host: <%= ENV['MYSQL_HOST'] || 'localhost' %> + host: <%= ENV['MYSQL_HOST'] %> database: <%= ENV['MYSQL_DATABASE'] %> username: <%= ENV['MYSQL_USERNAME'] %> password: <%= ENV['MYSQL_PASSWORD'] %> diff --git a/config/environments/production.rb b/config/environments/production.rb index 6cdc6d3..8b5edb8 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -64,4 +64,7 @@ Ensl::Application.configure do # Custom Session Store config to allow gathers.staging.ensl.org config.session_store :cookie_store, key: "_ENSL_session_key", expire_after: 30.days.to_i, domain: ".ensl.org" -end \ No newline at end of file + +# config.cache_store = :dalli_store, 'cache', 'cache-2.example.com:11211:2', +# { :namespace => NAME_OF_RAILS_APP, :expires_in => 1.day, :compress => true } +end diff --git a/entry.sh b/entry.sh new file mode 100755 index 0000000..1523ba4 --- /dev/null +++ b/entry.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +env|grep -i MYSQL +cd /var/www +bundle exec rake assets:precompile +bundle exec puma -C config/puma.rb diff --git a/fig.yml b/fig.yml index 314632f..4f008fa 100644 --- a/fig.yml +++ b/fig.yml @@ -1,9 +1,11 @@ web: - image: ensl/ensl.org + image: ensl links: - mysql - - redis +# - redis mysql: - image: mysql -redis: - image: redis + image: mysql/mysql-server + volumes: + - /srv/ensl/mysql:/var/lib/mysql +#redis: +# image: redis