Files
GerbilManager/gerbil-manager-web/Dockerfile
Gulum 2f2e5b1f56 OPS-1: Dockerfiles (net10 API + nginx frontend) + production config
- GerbilManagerWebAPI/Dockerfile: net7->net10 multi-stage; build context=repo
  root (includes ServiceDefaults); port 8080 (.NET 10 container default)
- gerbil-manager-web/Dockerfile: drop VITE_API_BASE_URL build-arg; nginx proxies
  /api/* to api:8080 (strip prefix), /scalar, /openapi/ -- one published port 80
- gerbil-manager-web/src/api/client.ts: default API_BASE_URL /api (relative),
  no hostname coupling at build time; Aspire still injects absolute LAN URL in dev
- GerbilManagerWebAPI/Program.cs: run EF Migrate() at startup always (not Dev-only)
- GerbilManager.ServiceDefaults/Extensions.cs: expose /health + /alive in all
  environments (compose healthcheck requires them in Production)

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
2026-06-06 07:31:19 +02:00

49 lines
1.6 KiB
Docker

# Build context: repo root (Dockerfile liest aus gerbil-manager-web/).
# docker build -f gerbil-manager-web/Dockerfile -t gerbilmanager-frontend .
#
# Produktion: kein VITE_API_BASE_URL nötig — client.ts fällt auf '/api' zurück,
# nginx proxyt /api/* transparent zum API-Container (keine Host-Kopplung zur Build-Zeit).
FROM node:22-alpine AS build
WORKDIR /app
COPY gerbil-manager-web/package.json gerbil-manager-web/package-lock.json ./
RUN npm ci
COPY gerbil-manager-web/ .
RUN npm run build
FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html
# nginx: SPA-Fallback + Reverse-Proxy für /api, /scalar, /openapi zum API-Container.
RUN printf 'server {\n\
listen 80;\n\
root /usr/share/nginx/html;\n\
index index.html;\n\
\n\
# API-Aufrufe: /api/* -> API-Container /* (Praefix wird entfernt)\n\
location /api/ {\n\
proxy_pass http://api:8080/;\n\
proxy_set_header Host $host;\n\
proxy_set_header X-Real-IP $remote_addr;\n\
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n\
}\n\
\n\
# Scalar API-Doku und OpenAPI-Spec direkt vom Backend\n\
location /scalar {\n\
proxy_pass http://api:8080/scalar;\n\
proxy_set_header Host $host;\n\
}\n\
location /openapi/ {\n\
proxy_pass http://api:8080/openapi/;\n\
proxy_set_header Host $host;\n\
}\n\
\n\
# SPA-Fallback: alle anderen Pfade laden index.html (React Router)\n\
location / {\n\
try_files $uri $uri/ /index.html;\n\
}\n\
}\n' > /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]