feat: Externalize API URLs and JWT secret configuration using build arguments and environment variables with default fallbacks.

This commit is contained in:
2026-02-15 14:30:00 -03:00
parent b8827c67b9
commit bb4cd01d99
3 changed files with 16 additions and 5 deletions
+10 -5
View File
@@ -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"
+4
View File
@@ -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
+2
View File
@@ -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