Multi-stage Dockerfile cho .NET
Multi-stage build giữ image production nhỏ gọn bằng cách tách build environment ra khỏi runtime.
dockerfile# ===== Stage 1: Build ===== FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build WORKDIR /src # Copy csproj trước để tận dụng Docker layer cache COPY ["src/MyApp.Api/MyApp.Api.csproj", "MyApp.Api/"] COPY ["src/MyApp.Core/MyApp.Core.csproj", "MyApp.Core/"] COPY ["src/MyApp.Infrastructure/MyApp.Infrastructure.csproj", "MyApp.Infrastructure/"] RUN dotnet restore "MyApp.Api/MyApp.Api.csproj"