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 - && \
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 && \
apt-get update && \
apt-get -y dist-upgrade && \
apt-get install -y --no-install-recommends yarn nodejs && \
apt-get update && apt-get dist-upgrade -y && \
apt-get install -y \
nodejs \
yarn \
nginx && \
apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/*
RUN gem update --system && gem install bundler
# Enable Nginx / Passenger
RUN rm -f /etc/service/nginx/down
# Install nginx config files
RUN rm /etc/nginx/sites-enabled/default
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
RUN mkdir -p /etc/my_init.d
ADD docker/db_migrate.sh /etc/my_init.d/db_migrate.sh
RUN chmod +x /etc/my_init.d/db_migrate.sh
# Add scripts
ADD docker/bin/* /usr/local/bin/
RUN chmod +x /usr/local/bin/entrypoint.sh /usr/local/bin/nginx_service.sh /usr/local/bin/rails_service.sh
# Set Default RAILS_ENV
ENV RAILS_ENV docker
ENV PASSENGER_APP_ENV docker
# Setup directory and install gems
RUN mkdir -p /home/app/parsley/log /home/app/parsley/tmp
RUN chown -R app:app /home/app/parsley/
WORKDIR /home/app/parsley/
RUN mkdir -p /parsley
WORKDIR /parsley
COPY Gemfile* ./
RUN su app -c "bundle install --deployment --jobs 4 --without development test"
RUN bundle install
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 --chown="app" . .
COPY . .
# 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'
gem 'rails', '5.2.4.1'
gem 'rails', '6.0.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 '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 'redcarpet', '~> 3.5.0'
gem 'dalli', '~> 2.7.10'
# Use ActiveModel has_secure_password
gem 'puma', '~> 4.3.3'
gem 'bcrypt', '~> 3.1.13'
gem 'tzinfo-data'
group :development, :test do
gem 'puma', '~> 4.3.1'
gem 'sqlite3', '~> 1.4.2'
gem 'guard', '~> 2.16.1'
gem 'guard', '~> 2.16.2'
gem 'guard-rspec', require: false
gem 'rspec-rails', '~> 3.9.0'
gem 'rspec-rails', '~> 3.9.1'
gem 'rails-controller-testing'
gem 'factory_bot_rails', '~> 5.1.1'
gem 'database_cleaner', '~> 1.7.0'
gem 'factory_bot_rails', '~> 5.2.0'
gem 'database_cleaner', '~> 1.8.4'
end

View File

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

2
Jenkinsfile vendored
View File

@ -20,7 +20,7 @@ node {
if (env.BRANCH_NAME == "production") {
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
require 'pathname'
require 'fileutils'
include FileUtils
# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
APP_ROOT = File.expand_path('..', __dir__)
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end
chdir APP_ROOT do
# This script is a starting point to setup your application.
FileUtils.chdir APP_ROOT do
# 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.
puts '== Installing dependencies =='
@ -20,11 +19,11 @@ chdir APP_ROOT do
# puts "\n== Copying sample files =="
# unless File.exist?('config/database.yml')
# cp 'config/database.yml.sample', 'config/database.yml'
# FileUtils.cp 'config/database.yml.sample', 'config/database.yml'
# end
puts "\n== Preparing database =="
system! 'bin/rails db:setup'
system! 'bin/rails db:prepare'
puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'

View File

@ -8,30 +8,31 @@ require "active_record/railtie"
# require "active_storage/engine"
require "action_controller/railtie"
require "action_mailer/railtie"
# require "action_mailbox/engine"
# require "action_text/engine"
require "action_view/railtie"
# require "action_cable/engine"
# require "sprockets/railtie"
require "rails/test_unit/railtie"
require "active_support/core_ext/string/inquiry"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Parsley
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
config.load_defaults 5.2
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 6.0
if ENV['RAILS_USE_MEMCACHE'] == 'true'
config.cache_store = :mem_cache_store, ENV['RAILS_MEMCACHE_HOST'] || 'memcache'
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)'
# 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

View File

@ -1,6 +1,4 @@
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.
# In the development environment your application's code is reloaded on
@ -14,18 +12,15 @@ Rails.application.configure do
# Show full error reports.
config.consider_all_requests_local = true
memcache_enabled = ENV['RAILS_USE_MEMCACHE'] == 'true'
# 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.enable_fragment_cache_logging = true
unless memcache_enabled
config.cache_store = :memory_store
end
config.public_file_server.headers = {
'Cache-Control' => 'public, max-age=172800'
'Cache-Control' => "public, max-age=#{2.days.to_i}"
}
else
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.
config.active_record.migration_error = :page_load
# # Debug mode disables concatenation and preprocessing of assets.
# # This option may cause significant delays in view rendering with a large
# # number of complex assets.
# config.assets.debug = true
#
# # Suppress logger output for asset requests.
# config.assets.quiet = true
# Highlight code that triggered database queries in logs.
config.active_record.verbose_query_logs = true
# Raises error for missing translations
# Raises error for missing translations.
# config.action_view.raise_on_missing_translations = true
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
end

View File

@ -1,6 +1,4 @@
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.
# Code is not reloaded between requests.
@ -13,22 +11,17 @@ Rails.application.configure do
config.eager_load = true
# 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
# 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
# Apache or NGINX already handles this.
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.
# 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-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.
# config.force_ssl = true
@ -54,9 +42,10 @@ Rails.application.configure do
# Use a different cache store in production.
# 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_name_prefix = "parsley_#{Rails.env}"
# config.active_job.queue_name_prefix = "parsley_production"
config.action_mailer.perform_caching = false
# Ignore bad email addresses and do not raise email delivery errors.
@ -85,4 +74,25 @@ Rails.application.configure do
# Do not dump schema after migrations.
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

View File

@ -1,6 +1,4 @@
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.
# Code is not reloaded between requests.
@ -16,19 +14,14 @@ Rails.application.configure do
config.consider_all_requests_local = false
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
# Apache or NGINX already handles this.
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.
# 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-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.
# config.force_ssl = true
@ -54,9 +42,10 @@ Rails.application.configure do
# Use a different cache store in production.
# 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_name_prefix = "parsley_#{Rails.env}"
# config.active_job.queue_name_prefix = "parsley_production"
config.action_mailer.perform_caching = false
# Ignore bad email addresses and do not raise email delivery errors.
@ -85,4 +74,25 @@ Rails.application.configure do
# Do not dump schema after migrations.
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

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
# 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
# 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.
config.public_file_server.enabled = true
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.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.cache_store = :null_store
# Raise exceptions instead of rendering exception templates.
config.action_dispatch.show_exceptions = false
# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false
config.action_mailer.perform_caching = false
# 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.
config.active_support.deprecation = :stderr
# Raises error for missing translations
# Raises error for missing translations.
# config.action_view.raise_on_missing_translations = true
end

View File

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

View File

@ -1,13 +1,12 @@
# 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'
#
# # Add additional assets to the asset load path
# # Rails.application.config.assets.paths << Emoji.images_path
#
# # Precompile additional assets.
# # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# # Rails.application.config.assets.precompile += %w( search.js )
#
# Rails.application.config.assets.precompile << Proc.new { |filename, path| %w(.eot .svg .tff .woff .woff2).include?(File.extname(filename)) }
# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
# Rails.application.config.assets.precompile += %w( admin.js admin.css )

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.
#
# 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
# available at http://guides.rubyonrails.org/i18n.html.
# available at https://guides.rubyonrails.org/i18n.html.
en:
hello: "Hello world"

View File

@ -1,13 +1,14 @@
# 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
# 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
threads threads_count, threads_count
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
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 }
@ -15,8 +16,11 @@ port ENV.fetch("PORT") { 3000 }
#
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.
# 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`.
# Workers do not work on JRuby or Windows (both of which do not support
# processes).
@ -26,22 +30,9 @@ environment ENV.fetch("RAILS_ENV") { "development" }
# Use the `preload_app!` method when specifying a `workers` number.
# This directive tells Puma to first boot the application and load code
# before forking the application. This takes advantage of Copy On Write
# process behavior so workers use less memory. If you use this option
# you need to make sure to reconnect any threads in the `on_worker_boot`
# block.
# process behavior so workers use less memory.
#
# 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.
plugin :tmp_restart

View File

@ -8,10 +8,26 @@ services:
web:
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
environment:
- PORT=80
- RAILS_USE_MEMCACHE=true
- PASSENGER_APP_ENV=production
- RAILS_LOG_TO_STDOUT=true
- RAILS_ENV=production
- SECRET_KEY_BASE=${SECRET_KEY_BASE}
- PARSLEY_DB_HOST=${PARSLEY_DB_HOST}
@ -21,14 +37,7 @@ services:
- PARSLEY_PG_PASSWORD=${PARSLEY_PG_PASSWORD}
networks:
- default
- traefik
- 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:
traefik:

View File

@ -16,13 +16,23 @@ services:
web:
build: .
image: registry.elbert.us/parsley:latest
environment:
- RAILS_USE_MEMCACHE=true
- RAILS_LOG_TO_STDOUT=true
command: web
ports:
- "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:
- postgres
- memcache
volumes:
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 {
listen 80;
root /home/app/parsley/public;
root /parsley/public;
passenger_enabled on;
passenger_user app;
passenger_ruby /usr/bin/ruby;
location / {
try_files $uri @rails;
}
location ~ ^/(assets|packs)/ {
try_files $uri @rails;
gzip_static on;
expires max;
expires 1y;
add_header Cache-Control public;
add_header ETag "";
break;
}
location @rails {
proxy_pass http://parsley_app;
proxy_http_version 1.1;
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": {
"@rails/webpacker": "4.2.2",
"@rails/webpacker": "5.1.1",
"@tweenjs/tween.js": "^18.5.0",
"autosize": "^4.0.2",
"bulma": "^0.8.0",

606
yarn.lock

File diff suppressed because it is too large Load Diff