Skip to content

Commit

Permalink
Set no-op mandatory env vars for Docker build
Browse files Browse the repository at this point in the history
Our app requires some environment variables, and will refuse to boot if
they are not set to ensure we don't bring up the app without missing
config.

Unfortunately, this means we need to manually set these in the
Dockerfile build stage too so that the assets can be built.
  • Loading branch information
csutter committed Feb 5, 2025
1 parent 6acac82 commit 6d2500e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ COPY Gemfile* .ruby-version ./
RUN bundle install
COPY . .
RUN bootsnap precompile --gemfile .
RUN SECRET_KEY_BASE=none GOVUK_NOTIFY_API_KEY=none rails assets:precompile && rm -fr log

# Set mandatory env vars to allow Rails to boot for asset compilation. These are only set for the
# current build stage.
ENV SECRET_KEY_BASE=none
ENV GOVUK_NOTIFY_API_KEY=none
ENV DISCOVERY_ENGINE_DATASTORE=none
ENV DISCOVERY_ENGINE_DEFAULT_COLLECTION_NAME=none
RUN rails assets:precompile && rm -fr log


FROM --platform=$TARGETPLATFORM $base_image
Expand Down

0 comments on commit 6d2500e

Please sign in to comment.