35 lines
982 B
Docker
35 lines
982 B
Docker
# =========================
|
|
# 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 SimpleIdp.Server/SimpleIdp.csproj
|
|
RUN dotnet publish SimpleIdp.Server/SimpleIdp.csproj -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"] |