From 2feec4ea9817fa0c9b37b66cbd8de27657a7a1d6 Mon Sep 17 00:00:00 2001 From: continuist Date: Sun, 21 Sep 2025 12:55:48 -0400 Subject: [PATCH] Change frontend build process to bring in correct backend host and port variables --- .forgejo/workflows/ci.yml | 14 ++++++++------ frontend/Dockerfile | 7 +++++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index 72cace3..8d525e6 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -128,8 +128,8 @@ jobs: test-frontend: runs-on: [ci] - if: false - needs: test-backend + # if: false + # needs: test-backend steps: - name: Checkout code @@ -176,9 +176,9 @@ jobs: build-frontend: runs-on: [ci] - if: false - needs: [test-backend, test-frontend] - # needs: [test-frontend] + # if: false + # needs: [test-backend, test-frontend] + needs: [test-frontend] env: CONTAINER_HOST: unix:///run/user/1001/podman/podman.sock @@ -200,6 +200,8 @@ jobs: - name: Build frontend container image run: | podman --remote build --no-cache \ + --build-arg NEXT_PUBLIC_API_HOST=${{ secrets.PROD_BACKEND_HOST }} \ + --build-arg NEXT_PUBLIC_API_PORT=${{ secrets.PROD_BACKEND_PORT }} \ -f frontend/Dockerfile \ -t "$FRONTEND_IMAGE:${{ github.sha }}" \ -t "$FRONTEND_IMAGE:latest" \ @@ -212,7 +214,7 @@ jobs: deploy-prod: runs-on: [prod] - # needs: [build-frontend] + needs: [build-frontend] # needs: [build-backend, build-frontend] env: diff --git a/frontend/Dockerfile b/frontend/Dockerfile index b0abf2d..bce53e2 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -11,6 +11,13 @@ COPY . . # disable telemetry; let Next control NODE_ENV during build ENV NEXT_TELEMETRY_DISABLED=1 + +# Build-time environment variables for Next.js public config +ARG NEXT_PUBLIC_API_HOST=127.0.0.1 +ARG NEXT_PUBLIC_API_PORT=3001 +ENV NEXT_PUBLIC_API_HOST=${NEXT_PUBLIC_API_HOST} +ENV NEXT_PUBLIC_API_PORT=${NEXT_PUBLIC_API_PORT} + RUN npm run build # ---------- runner (standalone) ----------