From bb4cd01d9998d8f092d05b4b9bd95f00156a0779 Mon Sep 17 00:00:00 2001 From: Nurfog Date: Sun, 15 Feb 2026 14:30:00 -0300 Subject: [PATCH] feat: Externalize API URLs and JWT secret configuration using build arguments and environment variables with default fallbacks. --- docker-compose.yml | 15 ++++++++++----- web/experience/Dockerfile | 4 ++++ web/studio/Dockerfile | 2 ++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 43890a6..97c98e0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,13 +14,15 @@ services: build: context: . dockerfile: web/studio/Dockerfile + args: + NEXT_PUBLIC_CMS_API_URL: ${NEXT_PUBLIC_CMS_API_URL:-http://localhost:3001} ports: - "3000:3000" - "3001:3001" environment: DATABASE_URL: postgresql://user:password@db:5432/openccb_cms - JWT_SECRET: openccb_secret_key_2025_production - NEXT_PUBLIC_CMS_API_URL: http://192.168.0.254:3001 + JWT_SECRET: ${JWT_SECRET:-openccb_secret_key_2025_production} + NEXT_PUBLIC_CMS_API_URL: ${NEXT_PUBLIC_CMS_API_URL:-http://localhost:3001} LMS_INTERNAL_URL: http://experience:3002 volumes: - uploads_data:/app/uploads @@ -34,14 +36,17 @@ services: build: context: . dockerfile: web/experience/Dockerfile + args: + NEXT_PUBLIC_LMS_API_URL: ${NEXT_PUBLIC_LMS_API_URL:-http://localhost:3002} + NEXT_PUBLIC_CMS_API_URL: ${NEXT_PUBLIC_CMS_API_URL:-http://localhost:3001} ports: - "3003:3003" - "3002:3002" environment: DATABASE_URL: postgresql://user:password@db:5432/openccb_lms - JWT_SECRET: openccb_secret_key_2025_production - NEXT_PUBLIC_LMS_API_URL: http://192.168.0.254:3002 - NEXT_PUBLIC_CMS_API_URL: http://192.168.0.254:3001 + JWT_SECRET: ${JWT_SECRET:-openccb_secret_key_2025_production} + NEXT_PUBLIC_LMS_API_URL: ${NEXT_PUBLIC_LMS_API_URL:-http://localhost:3002} + NEXT_PUBLIC_CMS_API_URL: ${NEXT_PUBLIC_CMS_API_URL:-http://localhost:3001} env_file: .env extra_hosts: - "host.docker.internal:host-gateway" diff --git a/web/experience/Dockerfile b/web/experience/Dockerfile index 64004a5..0d356f2 100644 --- a/web/experience/Dockerfile +++ b/web/experience/Dockerfile @@ -14,6 +14,10 @@ WORKDIR /app COPY web/experience/package*.json ./ RUN npm install COPY web/experience/ . +ARG NEXT_PUBLIC_LMS_API_URL +ENV NEXT_PUBLIC_LMS_API_URL=$NEXT_PUBLIC_LMS_API_URL +ARG NEXT_PUBLIC_CMS_API_URL +ENV NEXT_PUBLIC_CMS_API_URL=$NEXT_PUBLIC_CMS_API_URL RUN npm run build # Final stage diff --git a/web/studio/Dockerfile b/web/studio/Dockerfile index 5c87b4e..124cf40 100644 --- a/web/studio/Dockerfile +++ b/web/studio/Dockerfile @@ -14,6 +14,8 @@ WORKDIR /app COPY web/studio/package*.json ./ RUN npm install COPY web/studio/ . +ARG NEXT_PUBLIC_CMS_API_URL +ENV NEXT_PUBLIC_CMS_API_URL=$NEXT_PUBLIC_CMS_API_URL RUN npm run build # Final stage