fix: dynamic node environment variable

This commit is contained in:
theoleuthardt 2025-02-28 15:23:34 +01:00
parent a3e7998d11
commit 0505620145
4 changed files with 10 additions and 3 deletions

View file

@ -41,6 +41,7 @@ jobs:
tags: ${{ secrets.DOCKERHUB_USERNAME }}/werkzeugkiste-frontend:latest tags: ${{ secrets.DOCKERHUB_USERNAME }}/werkzeugkiste-frontend:latest
build-args: | build-args: |
NEXT_PUBLIC_BACKEND_URL=${{ secrets.NEXT_PUBLIC_BACKEND_URL }} NEXT_PUBLIC_BACKEND_URL=${{ secrets.NEXT_PUBLIC_BACKEND_URL }}
NODE_ENV=${{ secrets.NODE_ENV }}
- name: Build and Push Backend - name: Build and Push Backend
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
@ -50,6 +51,7 @@ jobs:
tags: ${{ secrets.DOCKERHUB_USERNAME }}/werkzeugkiste-backend:latest tags: ${{ secrets.DOCKERHUB_USERNAME }}/werkzeugkiste-backend:latest
build-args: | build-args: |
CORS_ALLOWED_ORIGIN=${{ secrets.CORS_ALLOWED_ORIGIN }} CORS_ALLOWED_ORIGIN=${{ secrets.CORS_ALLOWED_ORIGIN }}
NODE_ENV=${{ secrets.NODE_ENV }}
deploy-on-server: deploy-on-server:
needs: docker-build-push needs: docker-build-push

View file

@ -48,7 +48,8 @@ RUN \
FROM base AS runner FROM base AS runner
WORKDIR /app WORKDIR /app
ENV NODE_ENV=production ARG NODE_ENV
ENV NODE_ENV=$NODE_ENV
RUN addgroup --system --gid 1001 nodejs RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 fastify RUN adduser --system --uid 1001 fastify

View file

@ -6,6 +6,7 @@ services:
dockerfile: Dockerfile dockerfile: Dockerfile
args: args:
NEXT_PUBLIC_BACKEND_URL: ${NEXT_PUBLIC_BACKEND_URL} NEXT_PUBLIC_BACKEND_URL: ${NEXT_PUBLIC_BACKEND_URL}
NODE_ENV: ${NODE_ENV}
container_name: werkzeugkiste-frontend container_name: werkzeugkiste-frontend
environment: environment:
- NODE_ENV=${NODE_ENV} - NODE_ENV=${NODE_ENV}
@ -22,6 +23,7 @@ services:
dockerfile: Dockerfile dockerfile: Dockerfile
args: args:
CORS_ALLOWED_ORIGIN: ${CORS_ALLOWED_ORIGIN} CORS_ALLOWED_ORIGIN: ${CORS_ALLOWED_ORIGIN}
NODE_ENV: ${NODE_ENV}
container_name: werkzeugkiste-backend container_name: werkzeugkiste-backend
environment: environment:
- NODE_ENV=${NODE_ENV} - NODE_ENV=${NODE_ENV}

View file

@ -24,7 +24,8 @@ WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules COPY --from=deps /app/node_modules ./node_modules
COPY . . COPY . .
ENV NODE_ENV=production ARG NODE_ENV
ENV NODE_ENV=$NODE_ENV
ARG NEXT_PUBLIC_BACKEND_URL ARG NEXT_PUBLIC_BACKEND_URL
ENV NEXT_PUBLIC_BACKEND_URL=$NEXT_PUBLIC_BACKEND_URL ENV NEXT_PUBLIC_BACKEND_URL=$NEXT_PUBLIC_BACKEND_URL
@ -44,7 +45,8 @@ RUN \
FROM base AS runner FROM base AS runner
WORKDIR /app WORKDIR /app
ENV NODE_ENV=production ARG NODE_ENV
ENV NODE_ENV=$NODE_ENV
# Uncomment the following line in case you want to disable telemetry during runtime. # Uncomment the following line in case you want to disable telemetry during runtime.
# ENV NEXT_TELEMETRY_DISABLED=1 # ENV NEXT_TELEMETRY_DISABLED=1