EngineeringSolution ArchitectPlatform and DevOps

Session 05 - Containerization & Docker

Premium

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"
Premium

Continue with premium access

Session 05 - Containerization & Docker is part of the premium library. Sign in with a premium account to unlock the full lesson and the rest of this track.

01 Full premium lesson access
02 Deeper implementation notes
03 Ongoing content updates