44FROM node:20-slim AS builder
55WORKDIR /app
66
7+ # ---- MODIFIED SECTION ----
8+ # Declare all build-time arguments that your application needs.
9+ # Anything prefixed with NEXT_PUBLIC_ is needed for the client-side bundle.
10+ # Others are needed for server-side logic during the build (if any).
11+ ARG NEXT_PUBLIC_APP_SERVER_URL
12+ ARG AUTH0_SECRET
13+ ARG AUTH0_BASE_URL # This is a legacy var in the template, you have APP_BASE_URL
14+ ARG APP_BASE_URL
15+ ARG AUTH0_ISSUER_BASE_URL
16+ ARG AUTH0_CLIENT_ID
17+ ARG AUTH0_CLIENT_SECRET
18+ ARG AUTH0_AUDIENCE
19+ ARG AUTH0_SCOPE
20+
21+ # Set them as environment variables for the build process
22+ ENV NEXT_PUBLIC_APP_SERVER_URL=$NEXT_PUBLIC_APP_SERVER_URL
23+ ENV AUTH0_SECRET=$AUTH0_SECRET
24+ ENV AUTH0_BASE_URL=$AUTH0_BASE_URL
25+ ENV APP_BASE_URL=$APP_BASE_URL
26+ ENV AUTH0_ISSUER_BASE_URL=$AUTH0_ISSUER_BASE_URL
27+ ENV AUTH0_CLIENT_ID=$AUTH0_CLIENT_ID
28+ ENV AUTH0_CLIENT_SECRET=$AUTH0_CLIENT_SECRET
29+ ENV AUTH0_AUDIENCE=$AUTH0_AUDIENCE
30+ ENV AUTH0_SCOPE=$AUTH0_SCOPE
31+ # --------------------------
32+
733# Copy package.json and lock file to leverage Docker cache
834COPY package.json ./
935RUN npm install
@@ -12,7 +38,7 @@ RUN npm install
1238COPY . .
1339
1440# Build the Next.js application for production
15- # This creates the .next/standalone folder
41+ # This command will now have access to all the ENV vars
1642RUN npm run build
1743
1844
@@ -33,5 +59,6 @@ COPY --from=builder /app/.next/static ./.next/static
3359# Expose the port the app will run on
3460EXPOSE 3000
3561
62+ # The runner stage will get its env vars from the docker-compose 'env_file'
3663# The command to start the optimized Next.js server
3764CMD ["node" , "server.js" ]
0 commit comments