Skip to content

Commit

Permalink
fix(image-build): change from emulation to cross-compile (eclipse-tra…
Browse files Browse the repository at this point in the history
…ctusx#803)

* fix(image-build): change from emulation to cross-compile
for building multi-platform images
eclipse-tractusx#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
  • Loading branch information
evegufy authored and dhiren-singh-007 committed Jul 4, 2024
1 parent d35f0c2 commit b565e56
Show file tree
Hide file tree
Showing 23 changed files with 45 additions and 89 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/iam-seeding.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/maintenance-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/marketplace-app-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/notification-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/portal-migrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/processes-worker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/provisioning-migrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/registration-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/release_candidate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/release_iam-seeding.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/release_release_candidate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/services-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions docker/Dockerfile-administration-service
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions docker/Dockerfile-iam-seeding
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 .
Expand Down
8 changes: 3 additions & 5 deletions docker/Dockerfile-maintenance-service
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand All @@ -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 .
Expand Down
11 changes: 6 additions & 5 deletions docker/Dockerfile-marketplace-app-service
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions docker/Dockerfile-notification-service
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions docker/Dockerfile-portal-migrations
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 .
Expand Down
8 changes: 3 additions & 5 deletions docker/Dockerfile-processes-worker
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
Expand Down
8 changes: 3 additions & 5 deletions docker/Dockerfile-provisioning-migrations
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 .
Expand Down
11 changes: 6 additions & 5 deletions docker/Dockerfile-registration-service
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions docker/Dockerfile-services-service
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b565e56

Please sign in to comment.