diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..80100df1e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,14 @@ +.dockerignore +.git +.gitignore +Dockerfile +Jenkinsfile +Procfile +README.md +coverage +docs +features +log +spec +test +tmp diff --git a/Dockerfile b/Dockerfile index 42dd54b6d..7f6c9a2ad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,24 +3,22 @@ ARG builder_image=ghcr.io/alphagov/govuk-ruby-builder:3.1.2 FROM $builder_image AS builder -WORKDIR /app - +WORKDIR $APP_HOME COPY Gemfile* .ruby-version ./ RUN bundle install - -COPY . /app -RUN bundle exec rails assets:precompile && rm -rf /app/log +COPY . ./ +RUN bundle exec bootsnap precompile --gemfile . +RUN bundle exec rails assets:precompile && rm -rf log FROM $base_image -# TODO: remove PORT and set it in publishing-e2e-tests instead. -ENV GOVUK_APP_NAME=government-frontend PORT=3090 +ENV GOVUK_APP_NAME=government-frontend -COPY --from=builder /usr/local/bundle/ /usr/local/bundle/ -COPY --from=builder /app /app/ +WORKDIR $APP_HOME +COPY --from=builder $BUNDLE_PATH/ $BUNDLE_PATH/ +COPY --from=builder $BOOTSNAP_CACHE_DIR/ $BOOTSNAP_CACHE_DIR/ +COPY --from=builder $APP_HOME ./ USER app -WORKDIR /app - -CMD ["bundle", "exec", "puma"] +CMD ["puma"] diff --git a/Gemfile b/Gemfile index 5e6fadcbd..38a19fa1a 100644 --- a/Gemfile +++ b/Gemfile @@ -2,6 +2,7 @@ source "https://rubygems.org" gem "rails", "7.0.4" +gem "bootsnap", require: false gem "dalli" gem "gds-api-adapters" gem "govuk_ab_testing" diff --git a/Gemfile.lock b/Gemfile.lock index 67174d32a..7139c0c0c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -83,6 +83,8 @@ GEM smart_properties binding_of_caller (1.0.0) debug_inspector (>= 0.0.1) + bootsnap (1.15.0) + msgpack (~> 1.2) brakeman (5.3.1) builder (3.2.4) capybara (3.38.0) @@ -206,6 +208,8 @@ GEM ruby2_keywords (>= 0.0.5) net-imap (0.3.2) date + msgpack (1.6.0) + net-imap (0.3.1) net-protocol net-pop (0.1.2) net-protocol @@ -395,6 +399,7 @@ PLATFORMS DEPENDENCIES better_errors binding_of_caller + bootsnap capybara climate_control dalli diff --git a/config/boot.rb b/config/boot.rb index 282011619..997563c2a 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,3 +1,4 @@ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) require "bundler/setup" # Set up gems listed in the Gemfile. +require "bootsnap/setup"