Skip to content

Commit

Permalink
Merge pull request #6270 from alphagov/sengi/dockerfile
Browse files Browse the repository at this point in the history
Dockerfile cleanup + enable bootsnap.
  • Loading branch information
sengi authored Jan 16, 2023
2 parents f71d0ae + 5cb4639 commit 46894fd
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 18 deletions.
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
.dockerignore
.git
.github
.gitignore
Dockerfile
Jenkinsfile
Procfile
README.md
app.json
coverage
docs
features
log
node_modules
package.json
script
spec
startup.sh
test
tmp
yarn.lock
33 changes: 15 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
ARG base_image=ghcr.io/alphagov/govuk-ruby-base:3.1.2
ARG builder_image=ghcr.io/alphagov/govuk-ruby-builder:3.1.2
ARG ruby_version=3.1.2
ARG base_image=ghcr.io/alphagov/govuk-ruby-base:$ruby_version
ARG builder_image=ghcr.io/alphagov/govuk-ruby-builder:$ruby_version

FROM $builder_image AS builder

ENV BUNDLE_WITHOUT="development test webkit"
FROM $builder_image AS builder

RUN mkdir -p /app && ln -fs /tmp /app/tmp && ln -fs /tmp /home/app
WORKDIR /app
COPY Gemfile Gemfile.lock .ruby-version /app/
WORKDIR $APP_HOME
COPY Gemfile* .ruby-version ./
RUN bundle install
COPY . /app
RUN bundle exec rails assets:precompile && rm -fr /app/log
COPY . .
RUN bootsnap precompile --gemfile .
RUN rails assets:precompile && rm -fr log


FROM $base_image

ENV GOVUK_APP_NAME=smartanswers
ENV GOVUK_APP_NAME=smart-answers

RUN mkdir -p /app && ln -fs /tmp /app/tmp && ln -fs /tmp /home/app
WORKDIR /app

COPY --from=builder /usr/bin/node* /usr/bin/
COPY --from=builder /usr/local/bundle/ /usr/local/bundle/
COPY --from=builder /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

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 @@ -5,6 +5,7 @@ ruby File.read(".ruby-version").chomp
gem "rails", "7.0.4"

gem "ast"
gem "bootsnap", require: false
gem "gds-api-adapters"
gem "gds_zendesk"
gem "govspeak"
Expand Down
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ GEM
rack (>= 0.9.0)
binding_of_caller (1.0.0)
debug_inspector (>= 0.0.1)
bootsnap (1.15.0)
msgpack (~> 1.2)
brakeman (5.2.3)
builder (3.2.4)
byebug (11.1.3)
Expand Down Expand Up @@ -218,6 +220,7 @@ GEM
minitest (>= 4, < 6)
mocha (2.0.2)
ruby2_keywords (>= 0.0.5)
msgpack (1.6.0)
multi_xml (0.6.0)
multipart-post (2.1.1)
net-imap (0.3.4)
Expand Down Expand Up @@ -430,6 +433,7 @@ DEPENDENCIES
ast
better_errors
binding_of_caller
bootsnap
byebug
gds-api-adapters
gds_zendesk
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 46894fd

Please sign in to comment.