fix: use dynamic BACKEND_URL for nginx reverse proxy (#118)

Fixes #96

- nginx.conf converted to template processed by envsubst at container start
- BACKEND_URL env var (default: backend:3000) replaces hardcoded container name
- Docker DNS resolver used for dynamic upstream resolution
- Dockerfile copies nginx.conf as template to /etc/nginx/templates/

This prevents frontend breakage when users customize container names
in their docker-compose.yml.
This commit is contained in:
Daniel Volz
2026-02-08 12:05:43 +01:00
committed by GitHub
parent 7d6664e684
commit 78a0d3ac8e
3 changed files with 14 additions and 4 deletions
+4 -3
View File
@@ -32,8 +32,9 @@ RUN npm run build
# -----------------------------------------------------------------------------
FROM nginxinc/nginx-unprivileged:1.27-alpine AS runner
# Copy custom nginx config (must listen on 8080, not 80)
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Copy custom nginx config as template for envsubst processing
# nginx-unprivileged automatically substitutes env vars in .template files
COPY nginx.conf /etc/nginx/templates/default.conf.template
# Copy built static files with correct ownership (nginx user = uid 101)
COPY --from=builder --chown=101:101 /app/dist /usr/share/nginx/html
@@ -44,5 +45,5 @@ EXPOSE 8080
# Already runs as non-root (nginx user, uid 101)
USER nginx
# Start nginx
# Start nginx (entrypoint processes templates automatically)
CMD ["nginx", "-g", "daemon off;"]