Files
webapitest/Dockerfile
2026-03-03 17:26:54 +02:00

22 lines
679 B
Docker

# STAGE 1: Build
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
# Copy the solution and all project files to restore dependencies first (better caching)
COPY . .
# Run publish.
# We use --no-self-contained to keep it small since the runtime image has the shared framework.
RUN dotnet publish "SampleApi/SampleApi.csproj" -c Release -o /app/publish /p:UseAppHost=false
# STAGE 2: Runtime
FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
# Copy the contents of the publish folder directly into /app
COPY --from=build /app/publish .
# Pro-tip: Ensure the port matches your docker-compose
ENV ASPNETCORE_HTTP_PORTS=8081
ENTRYPOINT ["dotnet", "SampleApi.dll"]