From b565e56d6698570807579eae4cbdc2b2950a20ff Mon Sep 17 00:00:00 2001 From: Evelyn Gurschler Date: Mon, 24 Jun 2024 11:36:15 +0200 Subject: [PATCH] fix(image-build): change from emulation to cross-compile (#803) * fix(image-build): change from emulation to cross-compile for building multi-platform images https://github.com/eclipse-tractusx/portal-backend/issues/802 https://docs.docker.com/build/building/multi-platform https://devblogs.microsoft.com/dotnet/improving-multiplatform-container-support also improve dockerfiles by removing unnecessary base stage and aligning environment variables --- .github/workflows/iam-seeding.yml | 3 --- .github/workflows/maintenance-service.yml | 3 --- .github/workflows/marketplace-app-service.yml | 3 --- .github/workflows/notification-service.yml | 3 --- .github/workflows/portal-migrations.yml | 3 --- .github/workflows/processes-worker.yml | 3 --- .github/workflows/provisioning-migrations.yml | 3 --- .github/workflows/registration-service.yml | 3 --- .github/workflows/release.yml | 3 --- .github/workflows/release_candidate.yml | 3 --- .github/workflows/release_iam-seeding.yml | 3 --- .github/workflows/release_release_candidate.yml | 3 --- .github/workflows/services-service.yml | 3 --- docker/Dockerfile-administration-service | 11 ++++++----- docker/Dockerfile-iam-seeding | 8 +++----- docker/Dockerfile-maintenance-service | 8 +++----- docker/Dockerfile-marketplace-app-service | 11 ++++++----- docker/Dockerfile-notification-service | 11 ++++++----- docker/Dockerfile-portal-migrations | 8 +++----- docker/Dockerfile-processes-worker | 8 +++----- docker/Dockerfile-provisioning-migrations | 8 +++----- docker/Dockerfile-registration-service | 11 ++++++----- docker/Dockerfile-services-service | 11 ++++++----- 23 files changed, 45 insertions(+), 89 deletions(-) diff --git a/.github/workflows/iam-seeding.yml b/.github/workflows/iam-seeding.yml index d3c4762bed..439a8c75db 100644 --- a/.github/workflows/iam-seeding.yml +++ b/.github/workflows/iam-seeding.yml @@ -58,9 +58,6 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 - - name: Set up QEMU - uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 - - name: Docker meta id: meta uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 diff --git a/.github/workflows/maintenance-service.yml b/.github/workflows/maintenance-service.yml index 6c54a9aa77..ab6bd7bf8a 100644 --- a/.github/workflows/maintenance-service.yml +++ b/.github/workflows/maintenance-service.yml @@ -59,9 +59,6 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 - - name: Set up QEMU - uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 - - name: Docker meta id: meta uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 diff --git a/.github/workflows/marketplace-app-service.yml b/.github/workflows/marketplace-app-service.yml index 582d5fade2..5e48af5c90 100644 --- a/.github/workflows/marketplace-app-service.yml +++ b/.github/workflows/marketplace-app-service.yml @@ -64,9 +64,6 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 - - name: Set up QEMU - uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 - - name: Docker meta id: meta uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 diff --git a/.github/workflows/notification-service.yml b/.github/workflows/notification-service.yml index d0bbb1f9cd..24be91d82f 100644 --- a/.github/workflows/notification-service.yml +++ b/.github/workflows/notification-service.yml @@ -62,9 +62,6 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 - - name: Set up QEMU - uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 - - name: Docker meta id: meta uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 diff --git a/.github/workflows/portal-migrations.yml b/.github/workflows/portal-migrations.yml index 047d8c698a..7f17607d26 100644 --- a/.github/workflows/portal-migrations.yml +++ b/.github/workflows/portal-migrations.yml @@ -59,9 +59,6 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 - - name: Set up QEMU - uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 - - name: Docker meta id: meta uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 diff --git a/.github/workflows/processes-worker.yml b/.github/workflows/processes-worker.yml index ebe9aba2b2..70bebed216 100644 --- a/.github/workflows/processes-worker.yml +++ b/.github/workflows/processes-worker.yml @@ -66,9 +66,6 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 - - name: Set up QEMU - uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 - - name: Docker meta id: meta uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 diff --git a/.github/workflows/provisioning-migrations.yml b/.github/workflows/provisioning-migrations.yml index b0d7b0b9a2..38811666fb 100644 --- a/.github/workflows/provisioning-migrations.yml +++ b/.github/workflows/provisioning-migrations.yml @@ -59,9 +59,6 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 - - name: Set up QEMU - uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 - - name: Docker meta id: meta uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 diff --git a/.github/workflows/registration-service.yml b/.github/workflows/registration-service.yml index 69b26c7d09..fdf529a129 100644 --- a/.github/workflows/registration-service.yml +++ b/.github/workflows/registration-service.yml @@ -63,9 +63,6 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 - - name: Set up QEMU - uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 - - name: Docker meta id: meta uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0f532a91fe..fa18c1921d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -82,9 +82,6 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 - - name: Set up QEMU - uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 - - name: Docker meta id: meta uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 diff --git a/.github/workflows/release_candidate.yml b/.github/workflows/release_candidate.yml index 3291721f07..970ad87214 100644 --- a/.github/workflows/release_candidate.yml +++ b/.github/workflows/release_candidate.yml @@ -82,9 +82,6 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 - - name: Set up QEMU - uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 - - name: Docker meta id: meta uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 diff --git a/.github/workflows/release_iam-seeding.yml b/.github/workflows/release_iam-seeding.yml index a072653916..36dc3dab13 100644 --- a/.github/workflows/release_iam-seeding.yml +++ b/.github/workflows/release_iam-seeding.yml @@ -49,9 +49,6 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 - - name: Set up QEMU - uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 - - name: Docker meta id: meta uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 diff --git a/.github/workflows/release_release_candidate.yml b/.github/workflows/release_release_candidate.yml index f6e66463fe..71dffb63ac 100644 --- a/.github/workflows/release_release_candidate.yml +++ b/.github/workflows/release_release_candidate.yml @@ -81,9 +81,6 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 - - name: Set up QEMU - uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 - - name: Docker meta id: meta uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 diff --git a/.github/workflows/services-service.yml b/.github/workflows/services-service.yml index 718399d7f0..ff9c88e741 100644 --- a/.github/workflows/services-service.yml +++ b/.github/workflows/services-service.yml @@ -63,9 +63,6 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 - - name: Set up QEMU - uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 - - name: Docker meta id: meta uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 diff --git a/docker/Dockerfile-administration-service b/docker/Dockerfile-administration-service index 40342922da..fdb12e281b 100644 --- a/docker/Dockerfile-administration-service +++ b/docker/Dockerfile-administration-service @@ -17,17 +17,18 @@ # SPDX-License-Identifier: Apache-2.0 ############################################################### -FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS base - -FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine-amd64 AS publish +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS publish +ARG TARGETARCH WORKDIR / COPY LICENSE NOTICE.md DEPENDENCIES / COPY src/ src/ WORKDIR /src/administration/Administration.Service RUN dotnet publish "Administration.Service.csproj" -c Release -o /app/publish -FROM base AS final -ENV COMPlus_EnableDiagnostics=0 +FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine +ENV \ + COMPlus_EnableDiagnostics=0 \ + ASPNETCORE_URLS=http://+:8080 WORKDIR /app COPY --from=publish /app/publish . ENV ASPNETCORE_URLS http://+:8080 diff --git a/docker/Dockerfile-iam-seeding b/docker/Dockerfile-iam-seeding index 0781114715..00afa9066c 100644 --- a/docker/Dockerfile-iam-seeding +++ b/docker/Dockerfile-iam-seeding @@ -17,10 +17,8 @@ # SPDX-License-Identifier: Apache-2.0 ############################################################### -FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine AS base - -FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine-amd64 AS publish -WORKDIR / +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS publish +ARG TARGETARCH COPY LICENSE NOTICE.md DEPENDENCIES / COPY /src/framework/Framework.Async /src/framework/Framework.Async COPY /src/framework/Framework.ErrorHandling /src/framework/Framework.ErrorHandling @@ -34,7 +32,7 @@ COPY /src/keycloak/Keycloak.Seeding /src/keycloak/Keycloak.Seeding WORKDIR /src/keycloak/Keycloak.Seeding RUN dotnet publish "Keycloak.Seeding.csproj" -c Release -o /app/publish -FROM base AS final +FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine ENV COMPlus_EnableDiagnostics=0 WORKDIR /app COPY --from=publish /app/publish . diff --git a/docker/Dockerfile-maintenance-service b/docker/Dockerfile-maintenance-service index e1bf499351..928b7622f2 100644 --- a/docker/Dockerfile-maintenance-service +++ b/docker/Dockerfile-maintenance-service @@ -17,10 +17,8 @@ # SPDX-License-Identifier: Apache-2.0 ############################################################### -FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine AS base - -FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine-amd64 AS publish -WORKDIR / +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS publish +ARG TARGETARCH COPY LICENSE NOTICE.md DEPENDENCIES / COPY src/maintenance/Maintenance.App/ src/maintenance/Maintenance.App/ COPY src/portalbackend/PortalBackend.DBAccess/ src/portalbackend/PortalBackend.DBAccess/ @@ -37,7 +35,7 @@ RUN dotnet restore "src/maintenance/Maintenance.App/Maintenance.App.csproj" WORKDIR /src/maintenance/Maintenance.App RUN dotnet publish "Maintenance.App.csproj" -c Release -o /app/publish -FROM base AS final +FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine ENV COMPlus_EnableDiagnostics=0 WORKDIR /app COPY --from=publish /app/publish . diff --git a/docker/Dockerfile-marketplace-app-service b/docker/Dockerfile-marketplace-app-service index c0a6b29378..0fb61ab91a 100644 --- a/docker/Dockerfile-marketplace-app-service +++ b/docker/Dockerfile-marketplace-app-service @@ -17,17 +17,18 @@ # SPDX-License-Identifier: Apache-2.0 ############################################################### -FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS base - -FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine-amd64 AS publish +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS publish +ARG TARGETARCH WORKDIR / COPY LICENSE NOTICE.md DEPENDENCIES / COPY src/ src/ WORKDIR /src/marketplace/Apps.Service RUN dotnet publish "Apps.Service.csproj" -c Release -o /app/publish -FROM base AS final -ENV COMPlus_EnableDiagnostics=0 +FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine +ENV \ + COMPlus_EnableDiagnostics=0 \ + ASPNETCORE_URLS=http://+:8080 WORKDIR /app COPY --from=publish /app/publish . ENV ASPNETCORE_URLS http://+:8080 diff --git a/docker/Dockerfile-notification-service b/docker/Dockerfile-notification-service index b5e1b6147c..a7f73c0c3d 100644 --- a/docker/Dockerfile-notification-service +++ b/docker/Dockerfile-notification-service @@ -17,17 +17,18 @@ # SPDX-License-Identifier: Apache-2.0 ############################################################### -FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS base - -FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine-amd64 AS publish +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS publish +ARG TARGETARCH WORKDIR / COPY LICENSE NOTICE.md DEPENDENCIES / COPY src/ src/ WORKDIR /src/notifications/Notifications.Service RUN dotnet publish "Notifications.Service.csproj" -c Release -o /app/publish -FROM base AS final -ENV COMPlus_EnableDiagnostics=0 +FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine +ENV \ + COMPlus_EnableDiagnostics=0 \ + ASPNETCORE_URLS=http://+:8080 WORKDIR /app COPY --from=publish /app/publish . ENV ASPNETCORE_URLS http://+:8080 diff --git a/docker/Dockerfile-portal-migrations b/docker/Dockerfile-portal-migrations index 98ff6657bc..64f717e549 100644 --- a/docker/Dockerfile-portal-migrations +++ b/docker/Dockerfile-portal-migrations @@ -17,10 +17,8 @@ # SPDX-License-Identifier: Apache-2.0 ############################################################### -FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine AS base - -FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine-amd64 AS publish -WORKDIR / +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS publish +ARG TARGETARCH COPY LICENSE NOTICE.md DEPENDENCIES / COPY /src/portalbackend /src/portalbackend COPY /src/framework/Framework.DBAccess /src/framework/Framework.DBAccess @@ -34,7 +32,7 @@ COPY /src/processes/Processes.ProcessIdentity/ /src/processes/Processes.ProcessI WORKDIR /src/portalbackend/PortalBackend.Migrations RUN dotnet publish "PortalBackend.Migrations.csproj" -c Release -o /migrations/publish -FROM base AS final +FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine ENV COMPlus_EnableDiagnostics=0 WORKDIR /migrations COPY --from=publish /migrations/publish . diff --git a/docker/Dockerfile-processes-worker b/docker/Dockerfile-processes-worker index 47e1cb59c2..88c8a4b718 100644 --- a/docker/Dockerfile-processes-worker +++ b/docker/Dockerfile-processes-worker @@ -17,17 +17,15 @@ # SPDX-License-Identifier: Apache-2.0 ############################################################### -FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine AS base - -FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine-amd64 AS publish -WORKDIR / +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS publish +ARG TARGETARCH COPY LICENSE NOTICE.md DEPENDENCIES / COPY src/ src/ RUN dotnet restore "src/processes/Processes.Worker/Processes.Worker.csproj" WORKDIR /src/processes/Processes.Worker RUN dotnet publish "Processes.Worker.csproj" -c Release -o /app/publish -FROM base AS final +FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine ENV COMPlus_EnableDiagnostics=0 WORKDIR /app COPY --from=publish /app/publish . diff --git a/docker/Dockerfile-provisioning-migrations b/docker/Dockerfile-provisioning-migrations index dfbc26581c..ffa44ee1d9 100644 --- a/docker/Dockerfile-provisioning-migrations +++ b/docker/Dockerfile-provisioning-migrations @@ -17,10 +17,8 @@ # SPDX-License-Identifier: Apache-2.0 ############################################################### -FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine AS base - -FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine-amd64 AS publish -WORKDIR / +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS publish +ARG TARGETARCH COPY LICENSE NOTICE.md DEPENDENCIES / COPY /src/provisioning /src/provisioning COPY /src/framework/Framework.ErrorHandling /src/framework/Framework.ErrorHandling @@ -31,7 +29,7 @@ COPY /src/framework/Framework.Logging /src/framework/Framework.Logging WORKDIR /src/provisioning/Provisioning.Migrations RUN dotnet publish "Provisioning.Migrations.csproj" -c Release -o /migrations/publish -FROM base AS final +FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine ENV COMPlus_EnableDiagnostics=0 WORKDIR /migrations COPY --from=publish /migrations/publish . diff --git a/docker/Dockerfile-registration-service b/docker/Dockerfile-registration-service index 5e897bdaa8..b6cdbf2dfe 100644 --- a/docker/Dockerfile-registration-service +++ b/docker/Dockerfile-registration-service @@ -17,17 +17,18 @@ # SPDX-License-Identifier: Apache-2.0 ############################################################### -FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS base - -FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine-amd64 AS publish +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS publish +ARG TARGETARCH WORKDIR / COPY LICENSE NOTICE.md DEPENDENCIES / COPY src/ src/ WORKDIR /src/registration/Registration.Service RUN dotnet publish "Registration.Service.csproj" -c Release -o /app/publish -FROM base AS final -ENV COMPlus_EnableDiagnostics=0 +FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine +ENV \ + COMPlus_EnableDiagnostics=0 \ + ASPNETCORE_URLS=http://+:8080 WORKDIR /app COPY --from=publish /app/publish . ENV ASPNETCORE_URLS http://+:8080 diff --git a/docker/Dockerfile-services-service b/docker/Dockerfile-services-service index 59a249d07e..38881f33b9 100644 --- a/docker/Dockerfile-services-service +++ b/docker/Dockerfile-services-service @@ -17,17 +17,18 @@ # SPDX-License-Identifier: Apache-2.0 ############################################################### -FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS base - -FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine-amd64 AS publish +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS publish +ARG TARGETARCH WORKDIR / COPY LICENSE NOTICE.md DEPENDENCIES / COPY src/ src/ WORKDIR /src/marketplace/Services.Service RUN dotnet publish "Services.Service.csproj" -c Release -o /app/publish -FROM base AS final -ENV COMPlus_EnableDiagnostics=0 +FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine +ENV \ + COMPlus_EnableDiagnostics=0 \ + ASPNETCORE_URLS=http://+:8080 WORKDIR /app COPY --from=publish /app/publish . ENV ASPNETCORE_URLS http://+:8080