From 94c703ae7fd22284821a75cfbd067c22e0217363 Mon Sep 17 00:00:00 2001 From: Chris Banks Date: Sat, 14 Jan 2023 14:04:02 +0000 Subject: [PATCH] Clean up Dockerfile. - Parameterise the Ruby version. - Clean up paths slightly. - Remove unnecessary use of `bundle exec`. - Update `.dockerignore`. Tested: app boots with `docker run`. --- .dockerignore | 5 +++++ Dockerfile | 18 ++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.dockerignore b/.dockerignore index 80100df1e..edbe80040 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,6 +1,7 @@ .dockerignore .git .gitignore +.github Dockerfile Jenkinsfile Procfile @@ -9,6 +10,10 @@ coverage docs features log +node_modules +package.json +script spec test tmp +yarn.lock diff --git a/Dockerfile b/Dockerfile index 7f6c9a2ad..c88573b73 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,16 @@ -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 WORKDIR $APP_HOME COPY Gemfile* .ruby-version ./ RUN bundle install -COPY . ./ -RUN bundle exec bootsnap precompile --gemfile . -RUN bundle exec rails assets:precompile && rm -rf log +COPY . . +RUN bootsnap precompile --gemfile . +RUN rails assets:precompile && rm -fr log FROM $base_image @@ -16,9 +18,9 @@ FROM $base_image ENV GOVUK_APP_NAME=government-frontend WORKDIR $APP_HOME -COPY --from=builder $BUNDLE_PATH/ $BUNDLE_PATH/ -COPY --from=builder $BOOTSNAP_CACHE_DIR/ $BOOTSNAP_CACHE_DIR/ -COPY --from=builder $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 ["puma"]