diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2e11d80..f6b2de8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -205,6 +205,7 @@ jobs: uses: docker/build-push-action@v6 with: context: . + platforms: linux/amd64,linux/arm64 push: true build-args: | GITHUB_TOKEN=${{ secrets.PAT_DISPATCH }} diff --git a/Dockerfile b/Dockerfile index fdbc2d0..995efe0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ -# Build stage -FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build +# Build stage with multi-platform support +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:10.0 AS build +ARG TARGETARCH +ARG BUILDPLATFORM ARG GITHUB_TOKEN ARG NUGET_SOURCE=github WORKDIR /src @@ -21,13 +23,21 @@ RUN if [ "${NUGET_SOURCE}" = "github" ]; then \ --store-password-in-clear-text; \ fi -# Restore dependencies (cached layer) -RUN dotnet restore "PayrollEngine.PayrollConsole.sln" +# Restore with architecture-specific runtime +RUN if [ "$TARGETARCH" = "arm64" ]; then \ + dotnet restore "PayrollEngine.PayrollConsole.sln" --runtime linux-arm64; \ + else \ + dotnet restore "PayrollEngine.PayrollConsole.sln" --runtime linux-x64; \ + fi -# Copy remaining source files and publish +# Copy remaining source files and publish with architecture-specific runtime COPY . . WORKDIR "/src/PayrollConsole" -RUN dotnet publish "PayrollEngine.PayrollConsole.csproj" -c Release -o /app/publish --no-restore +RUN if [ "$TARGETARCH" = "arm64" ]; then \ + dotnet publish "PayrollEngine.PayrollConsole.csproj" -c Release -o /app/publish --runtime linux-arm64 --self-contained false; \ + else \ + dotnet publish "PayrollEngine.PayrollConsole.csproj" -c Release -o /app/publish --runtime linux-x64 --self-contained false; \ + fi # Runtime stage FROM mcr.microsoft.com/dotnet/aspnet:10.0