-
-
Save musghost/a444b99689c4d4deee9f0260e91828bd to your computer and use it in GitHub Desktop.
How to dockerize rails app with puma. Edit config/application.rb and config/puma.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module YourApplicationName | |
class Application < Rails::Application | |
# ... | |
# We want to set up a custom logger which logs to STDOUT. | |
# Docker expects your application to log to STDOUT/STDERR and to be ran | |
# in the foreground. | |
config.log_level = ENV.fetch('LOG_LEVEL', :debug) | |
config.log_tags = [:subdomain, :uuid] | |
config.logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT)) | |
# ... | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
api: bundle exec puma -C config/puma.rb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Before configuring Puma, you should look up the number of CPU cores your server has, change this to match your CPU core count | |
workers Integer(ENV['WEB_CONCURRENCY'] || [1, `grep -c processor /proc/cpuinfo`.to_i].max) | |
threads_count = Integer(ENV['MAX_THREADS'] || 5) | |
threads threads_count, threads_count | |
preload_app! | |
rackup DefaultRackup | |
# HTTP interface | |
port 3000 | |
# HTTPS inteface | |
# How to generate certificate: https://gist.github.com/tadast/9932075 | |
ssl_bind '0.0.0.0', '3001', { key: 'ssl/server.key', cert: 'ssl/server.crt' } | |
environment ENV['RACK_ENV'] || 'development' | |
stdout_redirect(stdout = '/dev/stdout', stderr = '/dev/stderr', append = true) | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment