lib/generators/dockerfile_generator.rb in dockerfile-rails-1.0.9 vs lib/generators/dockerfile_generator.rb in dockerfile-rails-1.0.10

- old
+ new

@@ -18,10 +18,11 @@ 'prepare' => true, 'redis' => false, 'swap' => nil, 'yjit' => false, 'label' => {}, + 'nginx' => false, ) @@labels = {} # load defaults from config file @@ -83,10 +84,13 @@ desc: 'enable YJIT optimizing compiler' class_option :label, type: :hash, default: {}, desc: 'Add Docker label(s)' + class_option :nginx, type: :boolean, default: OPTION_DEFAULTS.nginx, + desc: 'Serve static files with nginx' + def generate_app source_paths.push File.expand_path('./templates', __dir__) # merge options options.label.replace(@@labels.merge(options.label).select {|key, value| value != ''}) @@ -295,10 +299,13 @@ end # Puppeteer packages << 'google-chrome-stable' if using_puppeteer? + # nginx + packages << 'nginx' if options.nginx? + packages.sort end def deploy_repos repos = [] @@ -319,20 +326,22 @@ end def deploy_env env = [] + env << 'PORT="3001"' if options.nginx? + if Rails::VERSION::MAJOR<7 || Rails::VERSION::STRING.start_with?('7.0') env << 'RAILS_LOG_TO_STDOUT="1"' - env << 'RAILS_SERVE_STATIC_FILES="true"' + env << 'RAILS_SERVE_STATIC_FILES="true"' unless options.nginx? end - if options.yjit + if options.yjit? env << 'RUBY_YJIT_ENABLE="1"' end - if options.jemalloc and not options.fullstaq + if options.jemalloc? and not options.fullstaq? if (options.platform || Gem::Platform::local.cpu).include? 'arm' env << 'LD_PRELOAD="/usr/lib/aarch64-linux-gnu/libjemalloc.so.2"' else env << 'LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libjemalloc.so.2"' end @@ -469,8 +478,21 @@ def dbprep_command if Rails::VERSION::MAJOR >= 6 'db:prepare' else 'db:migrate' + end + end + + def procfile + if options.nginx? + { + nginx: 'nginx -g "daemon off;"', + rails: './bin/rails server -p 3001' + } + else + { + rails: './bin/rails server' + } end end end