Files
ExpenseTrackerApi/Dockerfile
T
Kevin Harlay ebfaf6f5ec Initial commit
2026-09-07 13:33:22 +02:00

21 lines
812 B
Docker

# Stage build
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["ExpenseTracker.Api.csproj", "."]
RUN dotnet restore
COPY . .
RUN dotnet publish -c Release -o /app/publish --no-restore
# Stage runtime
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
WORKDIR /app
RUN addgroup --gid 1001 appgroup && adduser --uid 1001 --ingroup appgroup --disabled-password --no-create-home appuser
COPY --from=build --chown=appuser:appgroup /app/publish .
USER 1001
EXPOSE 5000
# ASPNETCORE_URLS overrides the UseUrls("http://127.0.0.1:5000") in Program.cs
# so Kestrel binds on all container interfaces (needed for Docker networking).
# This is NOT a public 0.0.0.0 binding — the container port is not exposed to the host.
ENV ASPNETCORE_URLS=http://+:5000
ENTRYPOINT ["dotnet", "ExpenseTracker.Api.dll"]