Fix: Pass FASTAPI_URL as build arg for Next.js rewrites
All checks were successful
Build and Push Docker Images / Build Backend (FastAPI) (push) Successful in 34s
Build and Push Docker Images / Build Frontend (Next.js) (push) Successful in 1m13s
Build and Push Docker Images / Trigger Portainer Update (push) Successful in 1s

Next.js rewrites are evaluated at build time, not runtime.
Without FASTAPI_URL set during build, the rewrite destination
defaults to localhost:8000 which fails in Docker.

- Add FASTAPI_URL build arg to nextjs-app/Dockerfile
- Pass build arg in docker-compose.yml
- Pass build arg in Gitea Actions workflow

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Tudor
2026-02-03 10:46:03 +00:00
parent 0e698d38d9
commit a3966e0c31
3 changed files with 8 additions and 0 deletions

View File

@@ -89,6 +89,8 @@ jobs:
push: ${{ gitea.event_name != 'pull_request' }}
tags: ${{ steps.meta-frontend.outputs.tags }}
labels: ${{ steps.meta-frontend.outputs.labels }}
build-args: |
FASTAPI_URL=http://backend:80/api
# Cache disabled due to registry size limits
# cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.FRONTEND_IMAGE_NAME }}:buildcache
# cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.FRONTEND_IMAGE_NAME }}:buildcache,mode=max

View File

@@ -54,6 +54,8 @@ services:
build:
context: ./nextjs-app
dockerfile: Dockerfile
args:
FASTAPI_URL: http://backend:80/api
container_name: schoolcompare_nextjs
ports:
- "3000:3000"

View File

@@ -22,6 +22,10 @@ COPY . .
ENV NEXT_TELEMETRY_DISABLED=1
ENV NODE_ENV=production
# Build argument for FastAPI URL (used by Next.js rewrites at build time)
ARG FASTAPI_URL=http://backend:80/api
ENV FASTAPI_URL=${FASTAPI_URL}
# Build application
RUN npm run build