lib/generators/templates/Dockerfile.erb in dockerfile-rails-1.6.25 vs lib/generators/templates/Dockerfile.erb in dockerfile-rails-1.7.0

- old
+ new

@@ -1,8 +1,17 @@ -# syntax = docker/dockerfile:1 +# syntax=docker/dockerfile:1 +# check=error=true +<% if using_kamal? -%> -# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile +# This Dockerfile is designed for production, not development. Use with Kamal or build'n'run by hand: +# docker build -t demo . +# docker run -d -p 80:80 -e RAILS_MASTER_KEY=<value from config/master.key> --name demo demo + +# For a containerized dev environment, see Dev Containers: https://guides.rubyonrails.org/getting_started_with_devcontainer.html +<% end -%> + +# Make sure RUBY_VERSION matches the Ruby version in .ruby-version ARG RUBY_VERSION=<%= RUBY_VERSION %> <% if api_client_dir -%> <%= render partial: 'node_client' %> @@ -25,22 +34,22 @@ <% unless base_args.empty? -%> # Base build arguments ARG <%= base_args.map {|key, value| "#{key}=#{value.inspect}"}.join(" \\\n ") %> <% end -%> -# Set production environment -ENV <%= base_env.join(" \\\n ") %> - # Update gems and bundler RUN gem update --system <% if RUBY_VERSION.start_with? '2' %>3.4.22 <% end %>--no-document && \ gem install -N <%= base_gems.join(" ") %> <% unless base_packages.empty? -%> -# Install packages<% unless base_requirements.empty? -%> needed to install <%= base_requirements %><% end %> +# Install base packages<% unless base_requirements.empty? -%> needed to install <%= base_requirements %><% end %> <%= render partial: 'apt_install', locals: {packages: base_packages, clean: true, repos: base_repos} %> <% end -%> +# Set production environment +ENV <%= base_env.join(" \\\n ") %> + <% if using_execjs? and node_version != 'lts' -%> <%= render partial: 'install_node', locals: {yarn_version: nil} %> <% end -%> <% if base_instructions -%> @@ -52,11 +61,11 @@ # Throw-away build stage<%= parallel? ? 's' : '' %> to reduce size of final image FROM base AS <%= parallel? ? 'pre' : '' %>build <% end -%> # Install packages needed to build gems<%= using_node? ? " and node modules" : "" %> -<%= render partial: 'apt_install', locals: {packages: build_packages, clean: false, repos: ''} %> +<%= render partial: 'apt_install', locals: {packages: build_packages, clean: true, repos: ''} %> <% if parallel? -%> FROM prebuild AS <% if using_bun? %>bun<% else %>node<% end %> @@ -111,17 +120,16 @@ <% else -%> <% if private_gemserver_env_variable_name -%> RUN --mount=type=secret,id=gemserver_credentials,target=/kaniko/gemserver_credentials \ <%= private_gemserver_env_variable_name %>="$(cat /kaniko/gemserver_credentials)" && \ export <%= private_gemserver_env_variable_name %> && \ - bundle install<% if depend_on_bootsnap? && options.precompile != "defer" -%> && \ - bundle exec bootsnap precompile --gemfile<% end %> && \ + bundle install && \ <% else -%> -RUN <% if options["precompiled-gems"] != true %>bundle config set force_ruby_platform true && \<%= "\n " %><% end %>bundle install<% if depend_on_bootsnap? && options.precompile != "defer" -%> && \ - bundle exec bootsnap precompile --gemfile<% end %> && \ +RUN <% if options["precompiled-gems"] != true %>bundle config set force_ruby_platform true && \<%= "\n " %><% end %>bundle install && \ <% end -%> - rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git + rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git<% if depend_on_bootsnap? && options.precompile != "defer" -%> && \ + bundle exec bootsnap precompile --gemfile<% end %> <% end -%> <% if using_passenger? -%> # Compile passenger native support RUN passenger-config build-native-support @@ -296,10 +304,14 @@ <%= name %>: <%= command %> <% end -%> EOF <% end -%> +<% if using_thruster? -%> +# Start server via Thruster by default, this can be overwritten at runtime +<% else -%> # Start the server by default, this can be overwritten at runtime +<% end -%> EXPOSE <%= using_thruster? ? '80' : '3000' %> <% if deploy_database == 'sqlite3' -%> VOLUME /data <% end -%> <% unless fly_processes && !using_thruster? -%>