frontend/Dockerfile — Added ARG + ENV for build-time variables
docker-compose.yml — Added build.args to pass the values into the Docker build:
This commit is contained in:
@@ -39,6 +39,10 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: ./frontend
|
context: ./frontend
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
|
args:
|
||||||
|
NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL}
|
||||||
|
UPLOAD_R2_WORKER_API: ${UPLOAD_R2_WORKER_API}
|
||||||
|
R2_UPLOAD_API_KEY: ${R2_UPLOAD_API_KEY}
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL}
|
NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL}
|
||||||
|
|||||||
@@ -3,6 +3,16 @@ WORKDIR /app
|
|||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
RUN npm ci
|
RUN npm ci
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
# Build args for NEXT_PUBLIC_ vars (baked in at build time)
|
||||||
|
ARG NEXT_PUBLIC_API_URL
|
||||||
|
ARG UPLOAD_R2_WORKER_API
|
||||||
|
ARG R2_UPLOAD_API_KEY
|
||||||
|
|
||||||
|
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
|
||||||
|
ENV UPLOAD_R2_WORKER_API=$UPLOAD_R2_WORKER_API
|
||||||
|
ENV R2_UPLOAD_API_KEY=$R2_UPLOAD_API_KEY
|
||||||
|
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
FROM node:20-alpine AS production
|
FROM node:20-alpine AS production
|
||||||
@@ -12,4 +22,4 @@ RUN npm ci --omit=dev
|
|||||||
COPY --from=base /app/.next ./.next
|
COPY --from=base /app/.next ./.next
|
||||||
COPY --from=base /app/public ./public
|
COPY --from=base /app/public ./public
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
CMD ["npm", "start"]
|
CMD ["npm", "start"]
|
||||||
|
|||||||
Reference in New Issue
Block a user