# ABOUTME: Multi-stage Docker build for .NET Minimal API
# ABOUTME: Creates minimal production image with compiled application

# Build stage
FROM mcr.microsoft.com/dotnet/sdk:10.0-alpine AS builder

WORKDIR /app

# Copy project file and restore dependencies
COPY *.csproj ./
RUN dotnet restore

# Copy source and build
COPY . ./
RUN dotnet publish -c Release -o publish --no-restore

# Production stage
FROM mcr.microsoft.com/dotnet/aspnet:10.0-alpine

WORKDIR /app

# Copy published output from builder
COPY --from=builder /app/publish ./

# Run as non-root user for security
USER app

EXPOSE 8080

ENTRYPOINT ["dotnet", "Api.dll"]
