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>
This commit is contained in:
2026-06-06 07:25:55 +02:00
parent adea82a0e7
commit 2f2e5b1f56
5 changed files with 60 additions and 42 deletions

View File

@@ -1,20 +1,23 @@
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 80
# Build context: repo root (includes GerbilManager.ServiceDefaults).
# docker build -f GerbilManagerWebAPI/Dockerfile -t gerbilmanager-api .
ENV ASPNETCORE_URLS=http://+:80
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:7.0 AS build
ARG configuration=Release
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
COPY ["GerbilManagerWebAPI/GerbilManagerWebAPI.csproj", "GerbilManagerWebAPI/"]
RUN dotnet restore "GerbilManagerWebAPI/GerbilManagerWebAPI.csproj"
COPY . .
WORKDIR "/src/GerbilManagerWebAPI"
ARG configuration=Release
RUN dotnet publish "GerbilManagerWebAPI.csproj" -c $configuration -o /app/publish /p:UseAppHost=false
FROM base AS final
# Restore: project files only for layer-cache efficiency.
COPY GerbilManager.ServiceDefaults/GerbilManager.ServiceDefaults.csproj GerbilManager.ServiceDefaults/
COPY GerbilManagerWebAPI/GerbilManagerWebAPI.csproj GerbilManagerWebAPI/
RUN dotnet restore GerbilManagerWebAPI/GerbilManagerWebAPI.csproj
# Full source copy + publish.
COPY GerbilManager.ServiceDefaults/ GerbilManager.ServiceDefaults/
COPY GerbilManagerWebAPI/ GerbilManagerWebAPI/
WORKDIR /src/GerbilManagerWebAPI
RUN dotnet publish GerbilManagerWebAPI.csproj -c Release -o /app/publish /p:UseAppHost=false
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS final
WORKDIR /app
# .NET 10 containers default to ASPNETCORE_HTTP_PORTS=8080 bound on all interfaces.
EXPOSE 8080
COPY --from=build /app/publish .
ENTRYPOINT ["dotnet", "GerbilManagerWebAPI.dll"]