diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 4d74602..b65317b 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -104,6 +104,6 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} build-args: | - NEXT_PUBLIC_API_URL=${{ vars.NEXT_PUBLIC_API_URL }} + NEXT_PUBLIC_API_URL=${{ vars.NEXT_PUBLIC_API_URL != '' && vars.NEXT_PUBLIC_API_URL || 'http://localhost:8080/api' }} cache-from: type=gha cache-to: type=gha,mode=max diff --git a/apps/web/Dockerfile b/apps/web/Dockerfile index b2cba90..fcc60c3 100644 --- a/apps/web/Dockerfile +++ b/apps/web/Dockerfile @@ -50,9 +50,10 @@ COPY --from=deps /app/packages/tailwind-config/node_modules ./packages/tailwind- # Copy source code COPY . . -# Build arguments for environment variables needed at build time -ARG NEXT_PUBLIC_API_URL -ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL +# Build arguments for environment variables needed at build time. +# Default keeps CI/CD builds working even when build-arg is omitted. +ARG NEXT_PUBLIC_API_URL=http://localhost:8080/api +ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL} # Build the web app (standalone output configured in next.config.ts) RUN pnpm --filter @repo/web build