diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b7cc026 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +# ========================= +# Build stage +# ========================= +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +ARG BUILD_CONFIGURATION=Release +WORKDIR /src + +# Copy everything (simple + reliable for single-project Razor Pages apps) +COPY . . + +# Restore & publish (self-contained trimming can be added later if desired) +RUN dotnet restore +RUN dotnet publish -c $BUILD_CONFIGURATION -o /app/publish --no-restore + +# ========================= +# Runtime stage +# ========================= +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final +WORKDIR /app + +# (Optional) Create non-root user for better security +RUN useradd -m appuser +ENV ASPNETCORE_URLS=http://+:8080 \ + ASPNETCORE_ENVIRONMENT=Production \ + DOTNET_RUNNING_IN_CONTAINER=true +EXPOSE 8080 + +# Copy published output +COPY --from=build /app/publish ./ + +# Switch to non-root +USER appuser + +# Start the Razor Pages app +ENTRYPOINT ["dotnet", "SimpleIdp.dll"] \ No newline at end of file