Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Commit

Permalink
fix(docker): pass .env.local to the final stage of docker image bui…
Browse files Browse the repository at this point in the history
…lding

  ## problem
  - the app would not load because the `.env.local` file was not present
    - this is an issue because iron-session uses an ENV to encrypt session cookie content using a password
    - this password is loaded from `.env.local` file
    - if the ENV is not present, the rest of the app will not work

  ## solution
  - copy `.env.local` file from the building stage to the running stage of building docker image

  ## why
  - without the solution
    - iron-session will not work
    - iron-session in NextJS middleware will not work

  ## where
  - ./dockerfile

  ## usage
  • Loading branch information
Clumsy-Coder committed Jul 29, 2023
1 parent 1cccaeb commit 981a4be
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

####################################################################################################

# Base on offical Node.js Alpine image
# Base on official Node.js Alpine image
FROM node:alpine as builder

# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
Expand Down Expand Up @@ -70,6 +70,7 @@ COPY --from=builder --chown=node:node /usr/app/package.json ./package.json
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=node:node /usr/app/.next/standalone ./
COPY --from=builder --chown=node:node /usr/app/.next/static ./.next/static
COPY --from=builder --chown=node:node /usr/app/.env.local ./.env.local

USER node

Expand Down

0 comments on commit 981a4be

Please sign in to comment.