Skip to content

Commit

Permalink
Updating base image to use a new base and builder image.
Browse files Browse the repository at this point in the history
  • Loading branch information
nsabri1 committed Aug 8, 2022
1 parent 4733fe3 commit d26f31d
Showing 1 changed file with 12 additions and 27 deletions.
39 changes: 12 additions & 27 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,44 +1,29 @@
ARG base_image=ruby:2.7.6-slim

FROM $base_image AS builder

ENV RAILS_ENV=production
# TODO: have a separate build image which already contains the build-only deps.
RUN apt-get update -qy && \
apt-get upgrade -y && \
apt-get install -y build-essential nodejs && \
apt-get clean

RUN bundle config set force_ruby_platform true
ARG base_image=ghcr.io/alphagov/govuk-ruby-base:2.7.6
ARG builder_image=ghcr.io/alphagov/govuk-ruby-builder:2.7.6

FROM $builder_image AS builder

RUN mkdir /app

WORKDIR /app

COPY Gemfile Gemfile.lock .ruby-version /app/
COPY Gemfile* .ruby-version /app/

RUN bundle config set deployment 'true' && \
bundle config set without 'development test' && \
bundle install --jobs 4 --retry=2
RUN bundle install

COPY . /app
# TODO: We probably don't want assets in the image; remove this once we have a proper deployment process which uploads to (e.g.) S3.
RUN GOVUK_APP_DOMAIN=www.gov.uk \
GOVUK_WEBSITE_ROOT=https://www.gov.uk \
bundle exec rails assets:precompile
RUN bundle exec rails assets:precompile && rm -rf /app/log


FROM $base_image

ENV GOVUK_PROMETHEUS_EXPORTER=true RAILS_ENV=production GOVUK_APP_NAME=government-frontend GOVUK_APP_DOMAIN=www.gov.uk GOVUK_WEBSITE_ROOT=https://www.gov.uk PORT=3090
ENV GOVUK_APP_NAME=government-frontend PORT=3090

RUN apt-get update -qy && \
apt-get upgrade -y && \
apt-get install -y nodejs && \
apt-get clean
COPY --from=builder /usr/local/bundle/ /usr/local/bundle/
COPY --from=builder /app /app/

USER app
WORKDIR /app

COPY --from=builder /usr/local/bundle/ /usr/local/bundle/
COPY --from=builder /app ./

CMD bundle exec puma

0 comments on commit d26f31d

Please sign in to comment.