diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..254a985d9 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +CHANGELOG.md +CONTRIBUTING +Dockerfile +README.md +#deployment/ +*.yml.example* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..0d8bc4fda --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM ruby:2.4.1 +RUN apt-get update -qq && apt-get install -y imagemagick ghostscript +# throw errors if Gemfile has been modified since Gemfile.lock +RUN bundle config --global frozen 1 + +WORKDIR /usr/src/reservations + +COPY Gemfile Gemfile.lock ./ +RUN bundle install --without development test heroku + +# Copy app source code +COPY . . +# Add docker specific +COPY deployment/docker/config/ config/. + +# Add a script to be executed every time the container starts. +COPY deployment/docker/entrypoint.sh /usr/bin/ +RUN chmod +x /usr/bin/entrypoint.sh +ENTRYPOINT ["entrypoint.sh"] +#EXPOSE 3000 +EXPOSE 8080 + +VOLUME /usr/src/reservations/.env +VOLUME /usr/src/reservations/assets/ +VOLUME /usr/src/reservations/attachments/ + +# Start the main process. +CMD ["bundle", "exec", "puma"] diff --git a/Gemfile b/Gemfile index c5d043d17..f7b52581f 100644 --- a/Gemfile +++ b/Gemfile @@ -67,15 +67,12 @@ group :development, :test do gem 'pry-byebug', '~> 3.4.2' gem 'pry-stack_explorer', '~> 0.4.9.2' gem 'pry-remote', '~> 0.1.8' - gem 'letter_opener', '~> 1.4.1' - gem 'letter_opener_web', '~> 1.3.0' gem 'factory_girl_rails', '~> 4.7.0' gem 'rspec-rails', '~> 3.6.0' gem 'shoulda-matchers', '~> 3.1.2' gem 'capybara', '~> 3.9.0' gem 'capybara-selenium', '~> 0.0.6' gem 'selenium-webdriver', '~> 3.14.1' - gem 'puma' gem 'guard-rspec', '~> 4.7.3' gem 'spring', '~> 2.0.2' gem 'spring-commands-rspec', '~> 1.0.4' @@ -93,7 +90,7 @@ group :development, :test do gem 'timecop', '~> 0.9.1' end -group :development, :test, :heroku do +group :development, :test, :heroku, :docker do # seed script gems gem 'ffaker', '~> 2.6.0', require: false gem 'ruby-progressbar', '~> 1.8.1', require: false @@ -106,7 +103,7 @@ gem 'uglifier', '~> 3.2.0' gem 'bootstrap-sass', '~> 3.3.7' gem 'font-awesome-rails', '~> 4.7.0.2' -group :development do +group :development, :docker do gem 'thin', '~> 1.7.0' gem 'rack-mini-profiler', '~> 0.10.5' gem 'bullet', '~> 5.5.1' @@ -123,3 +120,9 @@ group :heroku do gem 'aws-sdk', '~> 2.3.0' gem 'rails_12factor', '~> 0.0.3' end + +group :docker, :development, :test do + gem 'puma', '~> 4.1', '>= 4.1.1' + gem 'letter_opener', '~> 1.4.1' + gem 'letter_opener_web', '~> 1.3.0' +end diff --git a/Gemfile.lock b/Gemfile.lock index 79c1e96aa..f85f0c7b8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,54 +1,53 @@ GEM remote: https://rubygems.org/ specs: - actioncable (5.1.2) - actionpack (= 5.1.2) + actioncable (5.1.7) + actionpack (= 5.1.7) nio4r (~> 2.0) websocket-driver (~> 0.6.1) - actionmailer (5.1.2) - actionpack (= 5.1.2) - actionview (= 5.1.2) - activejob (= 5.1.2) + actionmailer (5.1.7) + actionpack (= 5.1.7) + actionview (= 5.1.7) + activejob (= 5.1.7) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.1.2) - actionview (= 5.1.2) - activesupport (= 5.1.2) + actionpack (5.1.7) + actionview (= 5.1.7) + activesupport (= 5.1.7) rack (~> 2.0) - rack-test (~> 0.6.3) + rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.1.2) - activesupport (= 5.1.2) + actionview (5.1.7) + activesupport (= 5.1.7) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.1.2) - activesupport (= 5.1.2) + activejob (5.1.7) + activesupport (= 5.1.7) globalid (>= 0.3.6) - activemodel (5.1.2) - activesupport (= 5.1.2) - activemodel-serializers-xml (1.0.1) + activemodel (5.1.7) + activesupport (= 5.1.7) + activemodel-serializers-xml (1.0.2) activemodel (> 5.x) - activerecord (> 5.x) activesupport (> 5.x) builder (~> 3.1) - activerecord (5.1.2) - activemodel (= 5.1.2) - activesupport (= 5.1.2) + activerecord (5.1.7) + activemodel (= 5.1.7) + activesupport (= 5.1.7) arel (~> 8.0) - activesupport (5.1.2) + activesupport (5.1.7) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (~> 0.7) + i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) addressable (2.3.8) - airbrussh (1.3.0) + airbrussh (1.3.4) sshkit (>= 1.6.1, != 1.7.0) arel (8.0.0) - ast (2.3.0) - autoprefixer-rails (7.1.2.2) + ast (2.4.0) + autoprefixer-rails (9.6.1.1) execjs awesome_print (1.8.0) aws-sdk (2.3.22) @@ -57,8 +56,8 @@ GEM jmespath (~> 1.0) aws-sdk-resources (2.3.22) aws-sdk-core (= 2.3.22) - bcrypt (3.1.11) - binding_of_caller (0.7.2) + bcrypt (3.1.13) + binding_of_caller (0.8.0) debug_inspector (>= 0.0.1) bootstrap-sass (3.3.7) autoprefixer-rails (>= 5.2.1) @@ -77,7 +76,7 @@ GEM capistrano-bundler (1.2.0) capistrano (~> 3.1) sshkit (~> 1.2) - capistrano-rails (1.3.0) + capistrano-rails (1.3.1) capistrano (~> 3.1) capistrano-bundler (~> 1.1) capistrano-rvm (0.1.2) @@ -99,10 +98,10 @@ GEM climate_control (0.2.0) cocaine (0.5.8) climate_control (>= 0.0.3, < 1.0) - cocoon (1.2.10) - codeclimate-test-reporter (1.0.8) + cocoon (1.2.14) + codeclimate-test-reporter (1.0.9) simplecov (<= 0.13) - coderay (1.1.1) + coderay (1.1.2) coffee-rails (4.2.2) coffee-script (>= 2.2.0) railties (>= 4.0.0) @@ -110,10 +109,10 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.0.5) + concurrent-ruby (1.1.5) crass (1.0.4) - daemons (1.2.4) - database_cleaner (1.6.1) + daemons (1.3.1) + database_cleaner (1.6.2) debug_inspector (0.0.3) devise (4.3.0) bcrypt (~> 3.0) @@ -121,16 +120,16 @@ GEM railties (>= 4.1.0, < 5.2) responders warden (~> 1.2.3) - devise_cas_authenticatable (1.10.0) + devise_cas_authenticatable (1.10.4) devise (>= 1.2.0) rubycas-client (>= 2.2.1) diff-lcs (1.3) docile (1.1.5) - dotenv (2.2.1) - dotenv-rails (2.2.1) - dotenv (= 2.2.1) - railties (>= 3.2, < 5.2) - draper (3.0.0) + dotenv (2.2.2) + dotenv-rails (2.2.2) + dotenv (= 2.2.2) + railties (>= 3.2, < 6.0) + draper (3.0.1) actionpack (~> 5.0) activemodel (~> 5.0) activemodel-serializers-xml (~> 1.0) @@ -139,8 +138,8 @@ GEM em-websocket (0.5.1) eventmachine (>= 0.12.9) http_parser.rb (~> 0.6.0) - erubi (1.6.1) - eventmachine (1.2.3) + erubi (1.8.0) + eventmachine (1.2.7) execjs (2.7.0) factory_girl (4.7.0) activesupport (>= 3.0.0) @@ -151,8 +150,8 @@ GEM multipart-post (>= 1.2, < 3) ffaker (2.6.0) ffi (1.11.1) - font-awesome-rails (4.7.0.2) - railties (>= 3.2, < 5.2) + font-awesome-rails (4.7.0.5) + railties (>= 3.2, < 6.1) formatador (0.2.5) fullcalendar-rails (3.0.0.0) jquery-rails (>= 4.0.5, < 5.0.0) @@ -161,12 +160,12 @@ GEM fuubar (2.2.0) rspec-core (~> 3.0) ruby-progressbar (~> 1.4) - globalid (0.4.0) + globalid (0.4.2) activesupport (>= 4.2.0) - guard (2.14.1) + guard (2.15.1) formatador (>= 0.2.4) listen (>= 2.7, < 4.0) - lumberjack (~> 1.0) + lumberjack (>= 1.0.12, < 2.0) nenv (~> 0.1) notiffany (~> 0.0) pry (>= 0.9.12) @@ -182,42 +181,42 @@ GEM guard (~> 2.1) guard-compat (~> 1.1) rspec (>= 2.99.0, < 4.0) - haml (5.0.4) + haml (5.1.2) temple (>= 0.8.0) tilt - highline (1.7.8) + highline (1.7.10) http_parser.rb (0.6.0) - i18n (0.9.5) + i18n (1.6.0) concurrent-ruby (~> 1.0) icalendar (2.4.1) - inline_svg (1.2.2) + inline_svg (1.2.3) activesupport (>= 3.0) nokogiri (>= 1.6) jbuilder (2.7.0) activesupport (>= 4.2.0) multi_json (>= 1.2) - jmespath (1.3.1) + jmespath (1.4.0) jquery-datatables-rails (3.4.0) actionpack (>= 3.1) jquery-rails railties (>= 3.1) sass-rails - jquery-rails (4.3.1) + jquery-rails (4.3.5) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) jquery-ui-rails (5.0.5) railties (>= 3.2.16) - json (2.1.0) + json (2.2.0) kaminari (0.17.0) actionpack (>= 3.0.0) activesupport (>= 3.0.0) - kgio (2.11.0) + kgio (2.11.2) launchy (2.4.3) addressable (~> 2.3) letter_opener (1.4.1) launchy (~> 2.2) - letter_opener_web (1.3.1) + letter_opener_web (1.3.4) actionmailer (>= 3.2) letter_opener (~> 1.0) railties (>= 3.2) @@ -229,35 +228,35 @@ GEM loofah (2.2.3) crass (~> 1.0.2) nokogiri (>= 1.5.9) - lumberjack (1.0.12) - mail (2.6.6) - mime-types (>= 1.16, < 4) + lumberjack (1.0.13) + mail (2.7.1) + mini_mime (>= 0.1.1) method_source (0.8.2) - mime-types (3.2.2) + mime-types (3.3) mime-types-data (~> 3.2015) - mime-types-data (3.2019.0331) - mimemagic (0.3.2) + mime-types-data (3.2019.0904) + mimemagic (0.3.3) mini_mime (1.0.2) mini_portile2 (2.4.0) minitest (5.11.3) momentjs-rails (2.17.1) railties (>= 3.1) - multi_json (1.12.1) - multipart-post (2.0.0) - mysql2 (0.4.8) + multi_json (1.13.1) + multipart-post (2.1.1) + mysql2 (0.4.10) nenv (0.3.0) nested_form (0.3.2) - net-ldap (0.16.0) - net-scp (1.2.1) - net-ssh (>= 2.6.5) - net-ssh (4.1.0) + net-ldap (0.16.1) + net-scp (2.0.0) + net-ssh (>= 2.6.5, < 6.0.0) + net-ssh (5.2.0) nilify_blanks (1.2.1) activerecord (>= 3.0.0) activesupport (>= 3.0.0) - nio4r (2.1.0) + nio4r (2.5.1) nokogiri (1.10.4) mini_portile2 (~> 2.4.0) - notiffany (0.1.1) + notiffany (0.1.3) nenv (~> 0.1) shellany (~> 0.0) octokit (3.8.0) @@ -269,58 +268,58 @@ GEM cocaine (~> 0.5.5) mime-types mimemagic (~> 0.3.0) - parallel (1.11.2) - parser (2.4.0.0) - ast (~> 2.2) + parallel (1.17.0) + parser (2.6.4.1) + ast (~> 2.4.0) party_foul (1.5.5) octokit (~> 3.1) - powerpack (0.1.1) + powerpack (0.1.2) pry (0.10.4) coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) - pry-byebug (3.4.2) - byebug (~> 9.0) + pry-byebug (3.4.3) + byebug (>= 9.0, < 9.1) pry (~> 0.10) - pry-rails (0.3.6) + pry-rails (0.3.9) pry (>= 0.10.4) pry-remote (0.1.8) pry (~> 0.9) slop (~> 3.0) - pry-stack_explorer (0.4.9.2) + pry-stack_explorer (0.4.9.3) binding_of_caller (>= 0.7) pry (>= 0.9.11) - puma (4.1.0) + puma (4.1.1) nio4r (~> 2.0) rack (2.0.7) - rack-mini-profiler (0.10.5) + rack-mini-profiler (0.10.7) rack (>= 1.2.0) - rack-pjax (1.0.0) + rack-pjax (1.1.0) nokogiri (~> 1.5) rack (>= 1.1) - rack-test (0.6.3) - rack (>= 1.0) + rack-test (1.1.0) + rack (>= 1.0, < 3) rack-timeout (0.4.2) - rails (5.1.2) - actioncable (= 5.1.2) - actionmailer (= 5.1.2) - actionpack (= 5.1.2) - actionview (= 5.1.2) - activejob (= 5.1.2) - activemodel (= 5.1.2) - activerecord (= 5.1.2) - activesupport (= 5.1.2) - bundler (>= 1.3.0, < 2.0) - railties (= 5.1.2) + rails (5.1.7) + actioncable (= 5.1.7) + actionmailer (= 5.1.7) + actionpack (= 5.1.7) + actionview (= 5.1.7) + activejob (= 5.1.7) + activemodel (= 5.1.7) + activerecord (= 5.1.7) + activesupport (= 5.1.7) + bundler (>= 1.3.0) + railties (= 5.1.7) sprockets-rails (>= 2.0.0) - rails-controller-testing (1.0.2) - actionpack (~> 5.x, >= 5.0.1) - actionview (~> 5.x, >= 5.0.1) - activesupport (~> 5.x) + rails-controller-testing (1.0.4) + actionpack (>= 5.0.1.x) + actionview (>= 5.0.1.x) + activesupport (>= 5.0.1.x) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) - rails-html-sanitizer (1.0.4) + rails-html-sanitizer (1.2.0) loofah (~> 2.2, >= 2.2.2) rails4-autocomplete (1.1.1) rails (>= 3.0) @@ -342,28 +341,29 @@ GEM sass-rails (>= 4.0, < 6) rails_serve_static_assets (0.0.5) rails_stdout_logging (0.0.5) - railties (5.1.2) - actionpack (= 5.1.2) - activesupport (= 5.1.2) + railties (5.1.7) + actionpack (= 5.1.7) + activesupport (= 5.1.7) method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rainbow (2.2.2) rake - raindrops (0.18.0) + raindrops (0.19.0) rake (12.0.0) - rb-fsevent (0.10.2) - rb-inotify (0.9.10) - ffi (>= 0.5.0, < 2) + rb-fsevent (0.10.3) + rb-inotify (0.10.0) + ffi (~> 1.0) record_tag_helper (1.0.0) actionview (~> 5.x) redcarpet (3.4.0) ref (2.0.0) - remotipart (1.4.2) - request_store (1.3.2) - responders (2.4.0) - actionpack (>= 4.2.0, < 5.3) - railties (>= 4.2.0, < 5.3) + remotipart (1.4.3) + request_store (1.4.1) + rack (>= 1.4) + responders (2.4.1) + actionpack (>= 4.2.0, < 6.0) + railties (>= 4.2.0, < 6.0) rspec (3.6.0) rspec-core (~> 3.6.0) rspec-expectations (~> 3.6.0) @@ -376,7 +376,7 @@ GEM rspec-mocks (3.6.0) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.6.0) - rspec-rails (3.6.0) + rspec-rails (3.6.1) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) @@ -392,17 +392,17 @@ GEM rainbow (>= 1.99.1, < 3.0) ruby-progressbar (~> 1.7) unicode-display_width (~> 1.0, >= 1.0.1) - ruby-progressbar (1.8.1) + ruby-progressbar (1.8.3) ruby_dep (1.5.0) rubycas-client (2.3.9) activesupport - rubyzip (1.2.3) - sass (3.5.0) - sass-listen (~> 3.0.7) - sass-listen (3.0.7) - rb-fsevent (>= 0.9.3) - rb-inotify (>= 0.9.7) - sass-rails (5.0.6) + rubyzip (1.2.4) + sass (3.7.4) + sass-listen (~> 4.0.0) + sass-listen (4.0.0) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + sass-rails (5.0.7) railties (>= 4.0.0, < 6) sass (~> 3.1) sprockets (>= 2.8, < 4.0) @@ -417,16 +417,16 @@ GEM childprocess (~> 0.5) rubyzip (~> 1.2, >= 1.2.2) shellany (0.0.1) - shoulda-matchers (3.1.2) + shoulda-matchers (3.1.3) activesupport (>= 4.0.0) - simple_form (3.5.0) + simple_form (3.5.1) actionpack (> 4, < 5.2) activemodel (> 4, < 5.2) simplecov (0.13.0) docile (~> 1.1.0) json (>= 1.8, < 3) simplecov-html (~> 0.10.0) - simplecov-html (0.10.1) + simplecov-html (0.10.2) slop (3.6.0) spring (2.0.2) activesupport (>= 4.2) @@ -435,14 +435,14 @@ GEM sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.2.0) + sprockets-rails (3.2.1) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - sshkit (1.14.0) + sshkit (1.20.0) net-scp (>= 1.1.2) net-ssh (>= 2.8.0) - temple (0.8.0) + temple (0.8.2) therubyracer (0.12.3) libv8 (~> 3.16.14.15) ref @@ -450,24 +450,24 @@ GEM daemons (~> 1.0, >= 1.0.9) eventmachine (~> 1.0, >= 1.0.4) rack (>= 1, < 3) - thor (0.19.4) + thor (0.20.3) thread_safe (0.3.6) - tilt (2.0.7) + tilt (2.0.9) timecop (0.9.1) tzinfo (1.2.5) thread_safe (~> 0.1) uglifier (3.2.0) execjs (>= 0.3.0, < 3) - unicode-display_width (1.3.0) + unicode-display_width (1.6.0) unicorn (5.1.0) kgio (~> 2.6) raindrops (~> 0.7) uniform_notifier (1.10.0) - warden (1.2.7) - rack (>= 1.0) + warden (1.2.8) + rack (>= 2.0.6) websocket-driver (0.6.5) websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.2) + websocket-extensions (0.1.4) whenever (0.9.7) chronic (>= 0.6.3) xpath (3.2.0) @@ -525,7 +525,7 @@ DEPENDENCIES pry-rails (~> 0.3.6) pry-remote (~> 0.1.8) pry-stack_explorer (~> 0.4.9.2) - puma + puma (~> 4.1, >= 4.1.1) rack-mini-profiler (~> 0.10.5) rack-timeout (~> 0.4.2) rails (~> 5.1.2) diff --git a/deployment/docker/config/database.yml b/deployment/docker/config/database.yml new file mode 100644 index 000000000..4303df647 --- /dev/null +++ b/deployment/docker/config/database.yml @@ -0,0 +1,18 @@ +defaults: &defaults + adapter: mysql2 + encoding: utf8 + database: <%= ENV['RES_DB_NAME'] %> + username: <%= ENV['RES_DB_USERNAME'] %> + password: <%= ENV['RES_DB_PASSWORD'] %> + host: <%= ENV['RES_DB_HOST'] %> + port: 3306 + pool: 5 + +development: + <<: *defaults + +test: + <<: *defaults + +production: + <<: *defaults diff --git a/deployment/docker/config/puma.rb b/deployment/docker/config/puma.rb new file mode 100644 index 000000000..714a43ad5 --- /dev/null +++ b/deployment/docker/config/puma.rb @@ -0,0 +1,16 @@ +workers Integer(ENV['WEB_CONCURRENCY'] || 2) +threads_count = Integer(ENV['MAX_THREADS'] || 5) +threads threads_count, threads_count + +preload_app! + +rackup DefaultRackup +port ENV['PORT'] || 8080 +environment ENV['RACK_ENV'] || 'production' + +on_worker_boot do + # Worker specific setup for Rails 4.1+ + # See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot + ActiveRecord::Base.establish_connection +end + diff --git a/deployment/docker/entrypoint.sh b/deployment/docker/entrypoint.sh new file mode 100644 index 000000000..ec53feb12 --- /dev/null +++ b/deployment/docker/entrypoint.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -e + +# Remove a potentially pre-existing server.pid for Rails. +rm -f /usr/src/reservations/tmp/pids/server.pid +bundle exec rake assets:precompile + +# Then exec the container's main process (what's set as CMD in the Dockerfile). +exec "$@" +