Skip to content

Commit

Permalink
Merge pull request #2626 from alphagov/sengi/dockerfile-cleanup
Browse files Browse the repository at this point in the history
Use bootsnap to improve startup time.
  • Loading branch information
sengi authored Dec 13, 2022
2 parents e928965 + c5d5971 commit 9abb78b
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 12 deletions.
14 changes: 14 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.dockerignore
.git
.gitignore
Dockerfile
Jenkinsfile
Procfile
README.md
coverage
docs
features
log
spec
test
tmp
22 changes: 10 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -395,6 +399,7 @@ PLATFORMS
DEPENDENCIES
better_errors
binding_of_caller
bootsnap
capybara
climate_control
dalli
Expand Down
1 change: 1 addition & 0 deletions config/boot.rb
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 9abb78b

Please sign in to comment.