ruby and rails upgrade

This commit is contained in:
Dan Elbert 2020-05-02 14:12:04 -05:00
parent cf1294cf20
commit b85c2e1f60
26 changed files with 674 additions and 551 deletions

View File

@ -1 +1 @@
2.6.5 2.7.1

View File

@ -1,51 +1,42 @@
FROM phusion/passenger-ruby26:1.0.9 FROM ruby:2.7.1-buster
# Use baseimage-docker's init process.
CMD ["/sbin/my_init"]
# Install Node
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - && \ RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - && \
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list && \ echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list && \
apt-get update && \ apt-get update && apt-get dist-upgrade -y && \
apt-get -y dist-upgrade && \ apt-get install -y \
apt-get install -y --no-install-recommends yarn nodejs && \ nodejs \
yarn \
nginx && \
apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/*
RUN gem update --system && gem install bundler RUN gem update --system && gem install bundler
# Enable Nginx / Passenger
RUN rm -f /etc/service/nginx/down
# Install nginx config files # Install nginx config files
RUN rm /etc/nginx/sites-enabled/default RUN rm /etc/nginx/sites-enabled/default
ADD docker/nginx_server.conf /etc/nginx/sites-enabled/parsley.conf ADD docker/nginx_server.conf /etc/nginx/sites-enabled/parsley.conf
ADD docker/nginx_env.conf /etc/nginx/main.d/env.conf
# Add DB Migration Script # Add scripts
RUN mkdir -p /etc/my_init.d ADD docker/bin/* /usr/local/bin/
ADD docker/db_migrate.sh /etc/my_init.d/db_migrate.sh RUN chmod +x /usr/local/bin/entrypoint.sh /usr/local/bin/nginx_service.sh /usr/local/bin/rails_service.sh
RUN chmod +x /etc/my_init.d/db_migrate.sh
# Set Default RAILS_ENV # Set Default RAILS_ENV
ENV RAILS_ENV docker ENV RAILS_ENV docker
ENV PASSENGER_APP_ENV docker
# Setup directory and install gems # Setup directory and install gems
RUN mkdir -p /home/app/parsley/log /home/app/parsley/tmp RUN mkdir -p /parsley
RUN chown -R app:app /home/app/parsley/ WORKDIR /parsley
WORKDIR /home/app/parsley/
COPY Gemfile* ./ COPY Gemfile* ./
RUN su app -c "bundle install --deployment --jobs 4 --without development test" RUN bundle install
COPY package.json yarn.lock ./ COPY package.json yarn.lock ./
RUN su app -c "yarn install --production=true --frozen-lockfile" RUN yarn install --production=true --frozen-lockfile
# Copy the app into the image COPY . .
COPY --chown="app" . .
# Compile assets # Compile assets
RUN su app -c "bundle exec rails webpacker:clobber webpacker:compile" RUN bundle exec rails webpacker:clobber webpacker:compile
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

24
Gemfile
View File

@ -1,36 +1,32 @@
source 'https://rubygems.org' source 'https://rubygems.org'
gem 'rails', '5.2.4.1' gem 'rails', '6.0.2.2'
gem 'pg', '~> 1.2.2' gem 'pg', '~> 1.2.2'
gem 'webpacker', '4.2.2' gem 'webpacker', '5.1.1'
gem 'bootsnap', '>= 1.1.0', require: false gem 'bootsnap', '>= 1.1.0', require: false
gem 'jbuilder', '~> 2.9' gem 'jbuilder', '~> 2.10'
gem 'oj', '~> 3.10.1' gem 'oj', '~> 3.10.6'
gem 'kaminari', '~> 1.1.1' gem 'kaminari', '~> 1.2.0'
gem 'unitwise', '~> 2.2.0' gem 'unitwise', '~> 2.2.0'
gem 'redcarpet', '~> 3.5.0' gem 'redcarpet', '~> 3.5.0'
gem 'dalli', '~> 2.7.10' gem 'dalli', '~> 2.7.10'
gem 'puma', '~> 4.3.3'
# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.13' gem 'bcrypt', '~> 3.1.13'
gem 'tzinfo-data' gem 'tzinfo-data'
group :development, :test do group :development, :test do
gem 'puma', '~> 4.3.1'
gem 'sqlite3', '~> 1.4.2' gem 'sqlite3', '~> 1.4.2'
gem 'guard', '~> 2.16.1' gem 'guard', '~> 2.16.2'
gem 'guard-rspec', require: false gem 'guard-rspec', require: false
gem 'rspec-rails', '~> 3.9.0' gem 'rspec-rails', '~> 3.9.1'
gem 'rails-controller-testing' gem 'rails-controller-testing'
gem 'factory_bot_rails', '~> 5.1.1' gem 'factory_bot_rails', '~> 5.2.0'
gem 'database_cleaner', '~> 1.7.0' gem 'database_cleaner', '~> 1.8.4'
end end

View File

@ -1,48 +1,61 @@
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
actioncable (5.2.4.1) actioncable (6.0.2.2)
actionpack (= 5.2.4.1) actionpack (= 6.0.2.2)
nio4r (~> 2.0) nio4r (~> 2.0)
websocket-driver (>= 0.6.1) websocket-driver (>= 0.6.1)
actionmailer (5.2.4.1) actionmailbox (6.0.2.2)
actionpack (= 5.2.4.1) actionpack (= 6.0.2.2)
actionview (= 5.2.4.1) activejob (= 6.0.2.2)
activejob (= 5.2.4.1) activerecord (= 6.0.2.2)
activestorage (= 6.0.2.2)
activesupport (= 6.0.2.2)
mail (>= 2.7.1)
actionmailer (6.0.2.2)
actionpack (= 6.0.2.2)
actionview (= 6.0.2.2)
activejob (= 6.0.2.2)
mail (~> 2.5, >= 2.5.4) mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
actionpack (5.2.4.1) actionpack (6.0.2.2)
actionview (= 5.2.4.1) actionview (= 6.0.2.2)
activesupport (= 5.2.4.1) activesupport (= 6.0.2.2)
rack (~> 2.0, >= 2.0.8) rack (~> 2.0, >= 2.0.8)
rack-test (>= 0.6.3) rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2) rails-html-sanitizer (~> 1.0, >= 1.2.0)
actionview (5.2.4.1) actiontext (6.0.2.2)
activesupport (= 5.2.4.1) actionpack (= 6.0.2.2)
activerecord (= 6.0.2.2)
activestorage (= 6.0.2.2)
activesupport (= 6.0.2.2)
nokogiri (>= 1.8.5)
actionview (6.0.2.2)
activesupport (= 6.0.2.2)
builder (~> 3.1) builder (~> 3.1)
erubi (~> 1.4) erubi (~> 1.4)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3) rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (5.2.4.1) activejob (6.0.2.2)
activesupport (= 5.2.4.1) activesupport (= 6.0.2.2)
globalid (>= 0.3.6) globalid (>= 0.3.6)
activemodel (5.2.4.1) activemodel (6.0.2.2)
activesupport (= 5.2.4.1) activesupport (= 6.0.2.2)
activerecord (5.2.4.1) activerecord (6.0.2.2)
activemodel (= 5.2.4.1) activemodel (= 6.0.2.2)
activesupport (= 5.2.4.1) activesupport (= 6.0.2.2)
arel (>= 9.0) activestorage (6.0.2.2)
activestorage (5.2.4.1) actionpack (= 6.0.2.2)
actionpack (= 5.2.4.1) activejob (= 6.0.2.2)
activerecord (= 5.2.4.1) activerecord (= 6.0.2.2)
marcel (~> 0.3.1) marcel (~> 0.3.1)
activesupport (5.2.4.1) activesupport (6.0.2.2)
concurrent-ruby (~> 1.0, >= 1.0.2) concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2) i18n (>= 0.7, < 2)
minitest (~> 5.1) minitest (~> 5.1)
tzinfo (~> 1.1) tzinfo (~> 1.1)
arel (9.0.0) zeitwerk (~> 2.2)
bcrypt (3.1.13) bcrypt (3.1.13)
bootsnap (1.4.6) bootsnap (1.4.6)
msgpack (~> 1.0) msgpack (~> 1.0)
@ -51,13 +64,13 @@ GEM
concurrent-ruby (1.1.6) concurrent-ruby (1.1.6)
crass (1.0.6) crass (1.0.6)
dalli (2.7.10) dalli (2.7.10)
database_cleaner (1.7.0) database_cleaner (1.8.4)
diff-lcs (1.3) diff-lcs (1.3)
erubi (1.9.0) erubi (1.9.0)
factory_bot (5.1.2) factory_bot (5.2.0)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
factory_bot_rails (5.1.1) factory_bot_rails (5.2.0)
factory_bot (~> 5.1.0) factory_bot (~> 5.2.0)
railties (>= 4.2.0) railties (>= 4.2.0)
ffi (1.12.2) ffi (1.12.2)
formatador (0.2.5) formatador (0.2.5)
@ -81,18 +94,18 @@ GEM
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
jbuilder (2.10.0) jbuilder (2.10.0)
activesupport (>= 5.0.0) activesupport (>= 5.0.0)
kaminari (1.1.1) kaminari (1.2.0)
activesupport (>= 4.1.0) activesupport (>= 4.1.0)
kaminari-actionview (= 1.1.1) kaminari-actionview (= 1.2.0)
kaminari-activerecord (= 1.1.1) kaminari-activerecord (= 1.2.0)
kaminari-core (= 1.1.1) kaminari-core (= 1.2.0)
kaminari-actionview (1.1.1) kaminari-actionview (1.2.0)
actionview actionview
kaminari-core (= 1.1.1) kaminari-core (= 1.2.0)
kaminari-activerecord (1.1.1) kaminari-activerecord (1.2.0)
activerecord activerecord
kaminari-core (= 1.1.1) kaminari-core (= 1.2.0)
kaminari-core (1.1.1) kaminari-core (1.2.0)
liner (0.2.4) liner (0.2.4)
listen (3.2.1) listen (3.2.1)
rb-fsevent (~> 0.10, >= 0.10.3) rb-fsevent (~> 0.10, >= 0.10.3)
@ -133,18 +146,20 @@ GEM
rack rack
rack-test (1.1.0) rack-test (1.1.0)
rack (>= 1.0, < 3) rack (>= 1.0, < 3)
rails (5.2.4.1) rails (6.0.2.2)
actioncable (= 5.2.4.1) actioncable (= 6.0.2.2)
actionmailer (= 5.2.4.1) actionmailbox (= 6.0.2.2)
actionpack (= 5.2.4.1) actionmailer (= 6.0.2.2)
actionview (= 5.2.4.1) actionpack (= 6.0.2.2)
activejob (= 5.2.4.1) actiontext (= 6.0.2.2)
activemodel (= 5.2.4.1) actionview (= 6.0.2.2)
activerecord (= 5.2.4.1) activejob (= 6.0.2.2)
activestorage (= 5.2.4.1) activemodel (= 6.0.2.2)
activesupport (= 5.2.4.1) activerecord (= 6.0.2.2)
activestorage (= 6.0.2.2)
activesupport (= 6.0.2.2)
bundler (>= 1.3.0) bundler (>= 1.3.0)
railties (= 5.2.4.1) railties (= 6.0.2.2)
sprockets-rails (>= 2.0.0) sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.4) rails-controller-testing (1.0.4)
actionpack (>= 5.0.1.x) actionpack (>= 5.0.1.x)
@ -155,14 +170,14 @@ GEM
nokogiri (>= 1.6) nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0) rails-html-sanitizer (1.3.0)
loofah (~> 2.3) loofah (~> 2.3)
railties (5.2.4.1) railties (6.0.2.2)
actionpack (= 5.2.4.1) actionpack (= 6.0.2.2)
activesupport (= 5.2.4.1) activesupport (= 6.0.2.2)
method_source method_source
rake (>= 0.8.7) rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0) thor (>= 0.20.3, < 2.0)
rake (13.0.1) rake (13.0.1)
rb-fsevent (0.10.3) rb-fsevent (0.10.4)
rb-inotify (0.10.1) rb-inotify (0.10.1)
ffi (~> 1.0) ffi (~> 1.0)
redcarpet (3.5.0) redcarpet (3.5.0)
@ -187,6 +202,7 @@ GEM
rspec-mocks (~> 3.9.0) rspec-mocks (~> 3.9.0)
rspec-support (~> 3.9.0) rspec-support (~> 3.9.0)
rspec-support (3.9.2) rspec-support (3.9.2)
semantic_range (2.3.0)
shellany (0.0.1) shellany (0.0.1)
signed_multiset (0.2.1) signed_multiset (0.2.1)
sprockets (4.0.0) sprockets (4.0.0)
@ -201,20 +217,22 @@ GEM
thread_safe (0.3.6) thread_safe (0.3.6)
tzinfo (1.2.7) tzinfo (1.2.7)
thread_safe (~> 0.1) thread_safe (~> 0.1)
tzinfo-data (1.2019.3) tzinfo-data (1.2020.1)
tzinfo (>= 1.0.0) tzinfo (>= 1.0.0)
unitwise (2.2.0) unitwise (2.2.0)
liner (~> 0.2) liner (~> 0.2)
memoizable (~> 0.4) memoizable (~> 0.4)
parslet (~> 1.5) parslet (~> 1.5)
signed_multiset (~> 0.2) signed_multiset (~> 0.2)
webpacker (4.2.2) webpacker (5.1.1)
activesupport (>= 4.2) activesupport (>= 5.2)
rack-proxy (>= 0.6.1) rack-proxy (>= 0.6.1)
railties (>= 4.2) railties (>= 5.2)
semantic_range (>= 2.3.0)
websocket-driver (0.7.1) websocket-driver (0.7.1)
websocket-extensions (>= 0.1.0) websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.4) websocket-extensions (0.1.4)
zeitwerk (2.3.0)
PLATFORMS PLATFORMS
ruby ruby
@ -223,23 +241,23 @@ DEPENDENCIES
bcrypt (~> 3.1.13) bcrypt (~> 3.1.13)
bootsnap (>= 1.1.0) bootsnap (>= 1.1.0)
dalli (~> 2.7.10) dalli (~> 2.7.10)
database_cleaner (~> 1.7.0) database_cleaner (~> 1.8.4)
factory_bot_rails (~> 5.1.1) factory_bot_rails (~> 5.2.0)
guard (~> 2.16.1) guard (~> 2.16.2)
guard-rspec guard-rspec
jbuilder (~> 2.9) jbuilder (~> 2.10)
kaminari (~> 1.1.1) kaminari (~> 1.2.0)
oj (~> 3.10.1) oj (~> 3.10.6)
pg (~> 1.2.2) pg (~> 1.2.2)
puma (~> 4.3.1) puma (~> 4.3.3)
rails (= 5.2.4.1) rails (= 6.0.2.2)
rails-controller-testing rails-controller-testing
redcarpet (~> 3.5.0) redcarpet (~> 3.5.0)
rspec-rails (~> 3.9.0) rspec-rails (~> 3.9.1)
sqlite3 (~> 1.4.2) sqlite3 (~> 1.4.2)
tzinfo-data tzinfo-data
unitwise (~> 2.2.0) unitwise (~> 2.2.0)
webpacker (= 4.2.2) webpacker (= 5.1.1)
BUNDLED WITH BUNDLED WITH
2.1.4 2.1.4

2
Jenkinsfile vendored
View File

@ -20,7 +20,7 @@ node {
if (env.BRANCH_NAME == "production") { if (env.BRANCH_NAME == "production") {
stage("Deploy") { stage("Deploy") {
remote_deploy("azathoth.thenever", "parsley", "./docker-compose-rlyeh.yml") remote_deploy("azathoth.thenever", "parsley", "./docker-compose-azathoth.yml")
} }
} }
} }

View File

@ -1,17 +1,16 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
require 'pathname'
require 'fileutils' require 'fileutils'
include FileUtils
# path to your application root. # path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) APP_ROOT = File.expand_path('..', __dir__)
def system!(*args) def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==") system(*args) || abort("\n== Command #{args} failed ==")
end end
chdir APP_ROOT do FileUtils.chdir APP_ROOT do
# This script is a starting point to setup your application. # This script is a way to setup or update your development environment automatically.
# This script is idempotent, so that you can run it at anytime and get an expectable outcome.
# Add necessary setup steps to this file. # Add necessary setup steps to this file.
puts '== Installing dependencies ==' puts '== Installing dependencies =='
@ -20,11 +19,11 @@ chdir APP_ROOT do
# puts "\n== Copying sample files ==" # puts "\n== Copying sample files =="
# unless File.exist?('config/database.yml') # unless File.exist?('config/database.yml')
# cp 'config/database.yml.sample', 'config/database.yml' # FileUtils.cp 'config/database.yml.sample', 'config/database.yml'
# end # end
puts "\n== Preparing database ==" puts "\n== Preparing database =="
system! 'bin/rails db:setup' system! 'bin/rails db:prepare'
puts "\n== Removing old logs and tempfiles ==" puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear' system! 'bin/rails log:clear tmp:clear'

View File

@ -8,30 +8,31 @@ require "active_record/railtie"
# require "active_storage/engine" # require "active_storage/engine"
require "action_controller/railtie" require "action_controller/railtie"
require "action_mailer/railtie" require "action_mailer/railtie"
# require "action_mailbox/engine"
# require "action_text/engine"
require "action_view/railtie" require "action_view/railtie"
# require "action_cable/engine" # require "action_cable/engine"
# require "sprockets/railtie" # require "sprockets/railtie"
require "rails/test_unit/railtie" require "rails/test_unit/railtie"
require "active_support/core_ext/string/inquiry"
# Require the gems listed in Gemfile, including any gems # Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production. # you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups) Bundler.require(*Rails.groups)
module Parsley module Parsley
class Application < Rails::Application class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here. # Initialize configuration defaults for originally generated Rails version.
# Application configuration should go into files in config/initializers config.load_defaults 6.0
# -- all .rb files in that directory are automatically loaded.
config.load_defaults 5.2
if ENV['RAILS_USE_MEMCACHE'] == 'true' if ENV['RAILS_USE_MEMCACHE'] == 'true'
config.cache_store = :mem_cache_store, ENV['RAILS_MEMCACHE_HOST'] || 'memcache' config.cache_store = :mem_cache_store, ENV['RAILS_MEMCACHE_HOST'] || 'memcache'
end end
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
config.time_zone = 'Central Time (US & Canada)' config.time_zone = 'Central Time (US & Canada)'
# Settings in config/environments/* take precedence over those specified here.
# Application configuration can go into files in config/initializers
# -- all .rb files in that directory are automatically loaded after loading
# the framework and any gems in your application.
end end
end end

View File

@ -1,6 +1,4 @@
Rails.application.configure do Rails.application.configure do
# Verifies that versions and hashed value of the package contents in the project's package.json
config.webpacker.check_yarn_integrity = true
# Settings specified here will take precedence over those in config/application.rb. # Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on # In the development environment your application's code is reloaded on
@ -14,18 +12,15 @@ Rails.application.configure do
# Show full error reports. # Show full error reports.
config.consider_all_requests_local = true config.consider_all_requests_local = true
memcache_enabled = ENV['RAILS_USE_MEMCACHE'] == 'true'
# Enable/disable caching. By default caching is disabled. # Enable/disable caching. By default caching is disabled.
if Rails.root.join('tmp/caching-dev.txt').exist? || memcache_enabled # Run rails dev:cache to toggle caching.
if Rails.root.join('tmp', 'caching-dev.txt').exist?
config.action_controller.perform_caching = true config.action_controller.perform_caching = true
config.action_controller.enable_fragment_cache_logging = true
unless memcache_enabled config.cache_store = :memory_store
config.cache_store = :memory_store
end
config.public_file_server.headers = { config.public_file_server.headers = {
'Cache-Control' => 'public, max-age=172800' 'Cache-Control' => "public, max-age=#{2.days.to_i}"
} }
else else
config.action_controller.perform_caching = false config.action_controller.perform_caching = false
@ -44,18 +39,14 @@ Rails.application.configure do
# Raise an error on page load if there are pending migrations. # Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load config.active_record.migration_error = :page_load
# # Debug mode disables concatenation and preprocessing of assets. # Highlight code that triggered database queries in logs.
# # This option may cause significant delays in view rendering with a large config.active_record.verbose_query_logs = true
# # number of complex assets.
# config.assets.debug = true
#
# # Suppress logger output for asset requests.
# config.assets.quiet = true
# Raises error for missing translations
# Raises error for missing translations.
# config.action_view.raise_on_missing_translations = true # config.action_view.raise_on_missing_translations = true
# Use an evented file watcher to asynchronously detect changes in source code, # Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem. # routes, locales, etc. This feature depends on the listen gem.
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker config.file_watcher = ActiveSupport::EventedFileUpdateChecker
end end

View File

@ -1,6 +1,4 @@
Rails.application.configure do Rails.application.configure do
# Verifies that versions and hashed value of the package contents in the project's package.json
config.webpacker.check_yarn_integrity = false
# Settings specified here will take precedence over those in config/application.rb. # Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests. # Code is not reloaded between requests.
@ -13,22 +11,17 @@ Rails.application.configure do
config.eager_load = true config.eager_load = true
# Full error reports are disabled and caching is turned on. # Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = true config.consider_all_requests_local = false
config.action_controller.perform_caching = true config.action_controller.perform_caching = true
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
# config.require_master_key = true
# Disable serving static files from the `/public` folder by default since # Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this. # Apache or NGINX already handles this.
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
# # Compress JavaScripts and CSS.
# config.assets.js_compressor = :uglifier
# # config.assets.css_compressor = :sass
#
# # Do not fallback to assets pipeline if a precompiled asset is missed.
# config.assets.compile = false
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Enable serving of images, stylesheets, and JavaScripts from an asset server. # Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com' # config.action_controller.asset_host = 'http://assets.example.com'
@ -36,11 +29,6 @@ Rails.application.configure do
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Mount Action Cable outside main process or domain
# config.action_cable.mount_path = nil
# config.action_cable.url = 'wss://example.com/cable'
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true # config.force_ssl = true
@ -54,9 +42,10 @@ Rails.application.configure do
# Use a different cache store in production. # Use a different cache store in production.
# config.cache_store = :mem_cache_store # config.cache_store = :mem_cache_store
# Use a real queuing backend for Active Job (and separate queues per environment) # Use a real queuing backend for Active Job (and separate queues per environment).
# config.active_job.queue_adapter = :resque # config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "parsley_#{Rails.env}" # config.active_job.queue_name_prefix = "parsley_production"
config.action_mailer.perform_caching = false config.action_mailer.perform_caching = false
# Ignore bad email addresses and do not raise email delivery errors. # Ignore bad email addresses and do not raise email delivery errors.
@ -80,9 +69,30 @@ Rails.application.configure do
if ENV["RAILS_LOG_TO_STDOUT"].present? if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT) logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger) config.logger = ActiveSupport::TaggedLogging.new(logger)
end end
# Do not dump schema after migrations. # Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false config.active_record.dump_schema_after_migration = false
# Inserts middleware to perform automatic connection switching.
# The `database_selector` hash is used to pass options to the DatabaseSelector
# middleware. The `delay` is used to determine how long to wait after a write
# to send a subsequent read to the primary.
#
# The `database_resolver` class is used by the middleware to determine which
# database is appropriate to use based on the time delay.
#
# The `database_resolver_context` class is used by the middleware to set
# timestamps for the last write to the primary. The resolver uses the context
# class timestamps to determine how long to wait before reading from the
# replica.
#
# By default Rails will store a last write timestamp in the session. The
# DatabaseSelector middleware is designed as such you can define your own
# strategy for connection switching and pass that into the middleware through
# these configuration options.
# config.active_record.database_selector = { delay: 2.seconds }
# config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
# config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
end end

View File

@ -1,6 +1,4 @@
Rails.application.configure do Rails.application.configure do
# Verifies that versions and hashed value of the package contents in the project's package.json
config.webpacker.check_yarn_integrity = false
# Settings specified here will take precedence over those in config/application.rb. # Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests. # Code is not reloaded between requests.
@ -16,19 +14,14 @@ Rails.application.configure do
config.consider_all_requests_local = false config.consider_all_requests_local = false
config.action_controller.perform_caching = true config.action_controller.perform_caching = true
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
# config.require_master_key = true
# Disable serving static files from the `/public` folder by default since # Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this. # Apache or NGINX already handles this.
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
# # Compress JavaScripts and CSS.
# config.assets.js_compressor = :uglifier
# # config.assets.css_compressor = :sass
#
# # Do not fallback to assets pipeline if a precompiled asset is missed.
# config.assets.compile = false
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Enable serving of images, stylesheets, and JavaScripts from an asset server. # Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com' # config.action_controller.asset_host = 'http://assets.example.com'
@ -36,11 +29,6 @@ Rails.application.configure do
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Mount Action Cable outside main process or domain
# config.action_cable.mount_path = nil
# config.action_cable.url = 'wss://example.com/cable'
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true # config.force_ssl = true
@ -54,9 +42,10 @@ Rails.application.configure do
# Use a different cache store in production. # Use a different cache store in production.
# config.cache_store = :mem_cache_store # config.cache_store = :mem_cache_store
# Use a real queuing backend for Active Job (and separate queues per environment) # Use a real queuing backend for Active Job (and separate queues per environment).
# config.active_job.queue_adapter = :resque # config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "parsley_#{Rails.env}" # config.active_job.queue_name_prefix = "parsley_production"
config.action_mailer.perform_caching = false config.action_mailer.perform_caching = false
# Ignore bad email addresses and do not raise email delivery errors. # Ignore bad email addresses and do not raise email delivery errors.
@ -80,9 +69,30 @@ Rails.application.configure do
if ENV["RAILS_LOG_TO_STDOUT"].present? if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT) logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger) config.logger = ActiveSupport::TaggedLogging.new(logger)
end end
# Do not dump schema after migrations. # Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false config.active_record.dump_schema_after_migration = false
# Inserts middleware to perform automatic connection switching.
# The `database_selector` hash is used to pass options to the DatabaseSelector
# middleware. The `delay` is used to determine how long to wait after a write
# to send a subsequent read to the primary.
#
# The `database_resolver` class is used by the middleware to determine which
# database is appropriate to use based on the time delay.
#
# The `database_resolver_context` class is used by the middleware to set
# timestamps for the last write to the primary. The resolver uses the context
# class timestamps to determine how long to wait before reading from the
# replica.
#
# By default Rails will store a last write timestamp in the session. The
# DatabaseSelector middleware is designed as such you can define your own
# strategy for connection switching and pass that into the middleware through
# these configuration options.
# config.active_record.database_selector = { delay: 2.seconds }
# config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
# config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
end end

View File

@ -1,10 +1,11 @@
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
Rails.application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb. # Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true config.cache_classes = true
# Do not eager load code on boot. This avoids loading your whole application # Do not eager load code on boot. This avoids loading your whole application
@ -15,18 +16,20 @@ Rails.application.configure do
# Configure public file server for tests with Cache-Control for performance. # Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true config.public_file_server.enabled = true
config.public_file_server.headers = { config.public_file_server.headers = {
'Cache-Control' => 'public, max-age=3600' 'Cache-Control' => "public, max-age=#{1.hour.to_i}"
} }
# Show full error reports and disable caching. # Show full error reports and disable caching.
config.consider_all_requests_local = true config.consider_all_requests_local = true
config.action_controller.perform_caching = false config.action_controller.perform_caching = false
config.cache_store = :null_store
# Raise exceptions instead of rendering exception templates. # Raise exceptions instead of rendering exception templates.
config.action_dispatch.show_exceptions = false config.action_dispatch.show_exceptions = false
# Disable request forgery protection in test environment. # Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false config.action_controller.allow_forgery_protection = false
config.action_mailer.perform_caching = false config.action_mailer.perform_caching = false
# Tell Action Mailer not to deliver emails to the real world. # Tell Action Mailer not to deliver emails to the real world.
@ -37,6 +40,6 @@ Rails.application.configure do
# Print deprecation notices to the stderr. # Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr config.active_support.deprecation = :stderr
# Raises error for missing translations # Raises error for missing translations.
# config.action_view.raise_on_missing_translations = true # config.action_view.raise_on_missing_translations = true
end end

View File

@ -1,6 +1,8 @@
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# ApplicationController.renderer.defaults.merge!( # ActiveSupport::Reloader.to_prepare do
# http_host: 'example.org', # ApplicationController.renderer.defaults.merge!(
# https: false # http_host: 'example.org',
# ) # https: false
# )
# end

View File

@ -1,13 +1,12 @@
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# # Version of your assets, change this if you want to expire all your assets. # Version of your assets, change this if you want to expire all your assets.
# Rails.application.config.assets.version = '1.0' # Rails.application.config.assets.version = '1.0'
#
# # Add additional assets to the asset load path # Add additional assets to the asset load path.
# # Rails.application.config.assets.paths << Emoji.images_path # Rails.application.config.assets.paths << Emoji.images_path
#
# # Precompile additional assets. # Precompile additional assets.
# # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. # application.js, application.css, and all non-JS/CSS in the app/assets
# # Rails.application.config.assets.precompile += %w( search.js ) # folder are already added.
# # Rails.application.config.assets.precompile += %w( admin.js admin.css )
# Rails.application.config.assets.precompile << Proc.new { |filename, path| %w(.eot .svg .tff .woff .woff2).include?(File.extname(filename)) }

View File

@ -0,0 +1,28 @@
# Be sure to restart your server when you modify this file.
# Define an application-wide content security policy
# For further information see the following documentation
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
# Rails.application.config.content_security_policy do |policy|
# policy.default_src :self, :https
# policy.font_src :self, :https, :data
# policy.img_src :self, :https, :data
# policy.object_src :none
# policy.script_src :self, :https
# policy.style_src :self, :https
# # Specify URI for violation reports
# # policy.report_uri "/csp-violation-report-endpoint"
# end
# If you are using UJS then enable automatic nonce generation
# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
# Set the nonce only to specific directives
# Rails.application.config.content_security_policy_nonce_directives = %w(script-src)
# Report CSP violations to a specified URI
# For further information see the following documentation:
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
# Rails.application.config.content_security_policy_report_only = true

View File

@ -16,8 +16,18 @@
# #
# This would use the information in config/locales/es.yml. # This would use the information in config/locales/es.yml.
# #
# The following keys must be escaped otherwise they will not be retrieved by
# the default I18n backend:
#
# true, false, on, off, yes, no
#
# Instead, surround them with single quotes.
#
# en:
# 'true': 'foo'
#
# To learn more, please read the Rails Internationalization guide # To learn more, please read the Rails Internationalization guide
# available at http://guides.rubyonrails.org/i18n.html. # available at https://guides.rubyonrails.org/i18n.html.
en: en:
hello: "Hello world" hello: "Hello world"

View File

@ -1,13 +1,14 @@
# Puma can serve each request in a thread from an internal thread pool. # Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers a minimum and maximum. # The `threads` method setting takes two numbers: a minimum and maximum.
# Any libraries that use thread pools should be configured to match # Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum # the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum, this matches the default thread size of Active Record. # and maximum; this matches the default thread size of Active Record.
# #
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
threads threads_count, threads_count min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
threads min_threads_count, max_threads_count
# Specifies the `port` that Puma will listen on to receive requests, default is 3000. # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
# #
port ENV.fetch("PORT") { 3000 } port ENV.fetch("PORT") { 3000 }
@ -15,8 +16,11 @@ port ENV.fetch("PORT") { 3000 }
# #
environment ENV.fetch("RAILS_ENV") { "development" } environment ENV.fetch("RAILS_ENV") { "development" }
# Specifies the `pidfile` that Puma will use.
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
# Specifies the number of `workers` to boot in clustered mode. # Specifies the number of `workers` to boot in clustered mode.
# Workers are forked webserver processes. If using threads and workers together # Workers are forked web server processes. If using threads and workers together
# the concurrency of the application would be max `threads` * `workers`. # the concurrency of the application would be max `threads` * `workers`.
# Workers do not work on JRuby or Windows (both of which do not support # Workers do not work on JRuby or Windows (both of which do not support
# processes). # processes).
@ -26,22 +30,9 @@ environment ENV.fetch("RAILS_ENV") { "development" }
# Use the `preload_app!` method when specifying a `workers` number. # Use the `preload_app!` method when specifying a `workers` number.
# This directive tells Puma to first boot the application and load code # This directive tells Puma to first boot the application and load code
# before forking the application. This takes advantage of Copy On Write # before forking the application. This takes advantage of Copy On Write
# process behavior so workers use less memory. If you use this option # process behavior so workers use less memory.
# you need to make sure to reconnect any threads in the `on_worker_boot`
# block.
# #
# preload_app! # preload_app!
# The code in the `on_worker_boot` will be called if you are using
# clustered mode by specifying a number of `workers`. After each worker
# process is booted this block will be run, if you are using `preload_app!`
# option you will want to use this block to reconnect to any threads
# or connections that may have been created at application boot, Ruby
# cannot share connections between processes.
#
# on_worker_boot do
# ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
# end
# Allow puma to be restarted by `rails restart` command. # Allow puma to be restarted by `rails restart` command.
plugin :tmp_restart plugin :tmp_restart

View File

@ -8,10 +8,26 @@ services:
web: web:
image: registry.elbert.us/parsley:production image: registry.elbert.us/parsley:production
command: web
restart: unless-stopped
networks:
- default
- traefik
labels:
traefik.enable: "true"
traefik.http.routers.parsley.rule: "Host(`parsley.elbert.us`)"
traefik.http.routers.parsley.entrypoints: websecure
traefik.http.routers.parsley.tls: "true"
traefik.http.routers.parsley.tls.certResolver: cert-resolver
app:
image: registry.elbert.us/parsley:production
command: app
restart: unless-stopped restart: unless-stopped
environment: environment:
- PORT=80
- RAILS_USE_MEMCACHE=true - RAILS_USE_MEMCACHE=true
- PASSENGER_APP_ENV=production - RAILS_LOG_TO_STDOUT=true
- RAILS_ENV=production - RAILS_ENV=production
- SECRET_KEY_BASE=${SECRET_KEY_BASE} - SECRET_KEY_BASE=${SECRET_KEY_BASE}
- PARSLEY_DB_HOST=${PARSLEY_DB_HOST} - PARSLEY_DB_HOST=${PARSLEY_DB_HOST}
@ -21,14 +37,7 @@ services:
- PARSLEY_PG_PASSWORD=${PARSLEY_PG_PASSWORD} - PARSLEY_PG_PASSWORD=${PARSLEY_PG_PASSWORD}
networks: networks:
- default - default
- traefik
- db - db
labels:
traefik.enable: "true"
traefik.http.routers.parsley.rule: "Host(`parsley.elbert.us`)"
traefik.http.routers.parsley.entrypoints: websecure
traefik.http.routers.parsley.tls: "true"
traefik.http.routers.parsley.tls.certResolver: cert-resolver
networks: networks:
traefik: traefik:

View File

@ -16,13 +16,23 @@ services:
web: web:
build: . build: .
image: registry.elbert.us/parsley:latest image: registry.elbert.us/parsley:latest
environment: command: web
- RAILS_USE_MEMCACHE=true
- RAILS_LOG_TO_STDOUT=true
ports: ports:
- "3000:80" - "3000:80"
links:
- app
app:
build: .
image: registry.elbert.us/parsley:latest
command: app
environment:
- PORT=80
- RAILS_USE_MEMCACHE=true
- RAILS_LOG_TO_STDOUT=true
links: links:
- postgres - postgres
- memcache
volumes: volumes:
sql-data: sql-data:

18
docker/bin/entrypoint.sh Normal file
View File

@ -0,0 +1,18 @@
#!/bin/bash
set -e
if [ "$1" = "app" ]; then
echo "Starting app server..."
shift
exec /usr/local/bin/rails_service.sh "$@"
elif [ "$1" = "web" ]; then
echo "Starting nginx server..."
shift
exec /usr/local/bin/nginx_service.sh "$@"
else
exec "$@"
fi

View File

@ -0,0 +1,8 @@
#!/bin/bash
set -e
# output logs to stdout and stderr
ln -sf /dev/stdout /var/log/nginx/access.log && ln -sf /dev/stderr /var/log/nginx/error.log
exec nginx -g "daemon off;" "$@"

View File

@ -0,0 +1,9 @@
#!/bin/bash
set -e
cd /parsley
bundle exec rails db:migrate
exec bundle exec puma "$@"

View File

@ -1,4 +0,0 @@
#!/bin/sh
cd /home/app/parsley/
RAILS_ENV=$PASSENGER_APP_ENV bundle exec rails db:migrate

View File

@ -1,9 +0,0 @@
env RAILS_LOG_TO_STDOUT;
env RAILS_USE_MEMCACHE;
env RAILS_MEMCACHE_HOST;
env PARSLEY_DB_HOST;
env PARSLEY_DB_USER;
env PARSLEY_DB_PASSWORD;
env PARSLEY_DB_NAME;
env SECRET_KEY_BASE;
env PARSLEY_PG_PASSWORD;

View File

@ -1,15 +1,30 @@
upstream parsley_app {
ip_hash;
server app;
}
server { server {
listen 80; listen 80;
root /home/app/parsley/public; root /parsley/public;
passenger_enabled on; location / {
passenger_user app; try_files $uri @rails;
}
passenger_ruby /usr/bin/ruby; location ~ ^/(assets|packs)/ {
try_files $uri @rails;
gzip_static on;
expires 1y;
add_header Cache-Control public;
add_header ETag "";
break;
}
location ~ ^/(assets|packs)/ { location @rails {
gzip_static on; proxy_pass http://parsley_app;
expires max; proxy_http_version 1.1;
add_header Cache-Control public; proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
} }
} }

View File

@ -1,6 +1,6 @@
{ {
"dependencies": { "dependencies": {
"@rails/webpacker": "4.2.2", "@rails/webpacker": "5.1.1",
"@tweenjs/tween.js": "^18.5.0", "@tweenjs/tween.js": "^18.5.0",
"autosize": "^4.0.2", "autosize": "^4.0.2",
"bulma": "^0.8.0", "bulma": "^0.8.0",

606
yarn.lock

File diff suppressed because it is too large Load Diff