1+ # Build stage with multi-platform support
2+ FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:9.0 AS build
3+ ARG TARGETARCH
4+ ARG BUILDPLATFORM
5+ WORKDIR /src
6+
7+ # copy solution and project files
8+ COPY ["PayrollEngine.WebApp.sln" , "./" ]
9+ COPY ["Core/PayrollEngine.WebApp.Core.csproj" , "Core/" ]
10+ COPY ["Presentation/PayrollEngine.WebApp.Presentation.csproj" , "Presentation/" ]
11+ COPY ["Server/PayrollEngine.WebApp.Server.csproj" , "Server/" ]
12+ COPY ["Shared/PayrollEngine.WebApp.Shared.csproj" , "Shared/" ]
13+ COPY ["ViewModel/PayrollEngine.WebApp.ViewModel.csproj" , "ViewModel/" ]
14+
15+ # copy Directory.Build.props
16+ COPY ["Directory.Build.props" , "./" ]
17+
18+ # Restore with architecture-specific runtime
19+ RUN if [ "$TARGETARCH" = "arm64" ]; then \
20+ dotnet restore "PayrollEngine.WebApp.sln" --runtime linux-arm64; \
21+ else \
22+ dotnet restore "PayrollEngine.WebApp.sln" --runtime linux-x64; \
23+ fi
24+
25+ # copy everything else
26+ COPY . .
27+ WORKDIR "/src/Server"
28+
29+ # Publish with architecture-specific runtime and restore included
30+ RUN if [ "$TARGETARCH" = "arm64" ]; then \
31+ dotnet publish "PayrollEngine.WebApp.Server.csproj" -c Release -o /app/publish --runtime linux-arm64 --self-contained false; \
32+ else \
33+ dotnet publish "PayrollEngine.WebApp.Server.csproj" -c Release -o /app/publish --runtime linux-x64 --self-contained false; \
34+ fi
35+
36+ # final stage
37+ FROM mcr.microsoft.com/dotnet/aspnet:9.0
38+ WORKDIR /app
39+ COPY --from=build /app/publish .
40+ ENTRYPOINT ["dotnet" , "PayrollEngine.WebApp.Server.dll" ]
0 commit comments