0
0
mirror of https://github.com/alex289/CleanArchitecture.git synced 2025-07-01 11:02:57 +00:00

fix: Docker build for arm and amd

This commit is contained in:
alex289 2024-03-24 15:42:29 +01:00
parent 633944e6fb
commit 6dc4517ea7
No known key found for this signature in database
GPG Key ID: 573F77CD2D87F863
2 changed files with 7 additions and 5 deletions

View File

@ -57,7 +57,7 @@ jobs:
- name: Build and push
uses: docker/build-push-action@v5
with:
# platforms: linux/amd64,linux/arm64
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.DOCKER_IMAGE }}:latest

View File

@ -1,16 +1,18 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG TARGETARCH
WORKDIR /app
# copy csproj and restore as distinct layers
COPY . .
RUN dotnet restore
RUN dotnet restore -a $TARGETARCH
# copy everything else and build app
COPY CleanArchitecture.Api/. ./CleanArchitecture.Api/
WORKDIR /app/CleanArchitecture.Api
RUN dotnet publish -c Release -o out
RUN dotnet publish -c Release -o out -a $TARGETARCH
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
ARG TARGETARCH
WORKDIR /app
COPY --from=build /app/CleanArchitecture.Api/out ./