Skip to content

Commit

Permalink
fix(image-build): change from emulation to cross-compile (#37)
Browse files Browse the repository at this point in the history
for building multi-platform images
eclipse-tractusx/portal-backend#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 Phil91 committed Jul 2, 2024
1 parent 3aafbc6 commit 348a7ef
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 26 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/migrations-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@2b51285047da1547ffb1b2203d8be4c0af6b1f20 # v3.2.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-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@2b51285047da1547ffb1b2203d8be4c0af6b1f20 # v3.2.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 @@ -112,9 +112,6 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@2b51285047da1547ffb1b2203d8be4c0af6b1f20 # v3.2.0

- name: Set up QEMU
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0

# Create SemVer or ref tags dependent of trigger event
- name: Docker meta
id: meta
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/service-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@2b51285047da1547ffb1b2203d8be4c0af6b1f20 # v3.2.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
7 changes: 3 additions & 4 deletions docker/Dockerfile-dim-migrations
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@
# 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
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS publish
ARG TARGETARCH
WORKDIR /
COPY LICENSE /
COPY /src/database /src/database
COPY /src/processes/Processes.Worker.Library /src/processes/Processes.Worker.Library
WORKDIR /src/database/Dim.Migrations
RUN dotnet publish "Dim.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
7 changes: 3 additions & 4 deletions docker/Dockerfile-dim-processes-worker
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@
# 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
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS publish
ARG TARGETARCH
WORKDIR /
COPY LICENSE /
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
12 changes: 6 additions & 6 deletions docker/Dockerfile-dim-service
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@
# 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 /
COPY src/ src/
WORKDIR /src/web/Dim.Web
RUN dotnet publish "Dim.Web.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
EXPOSE 8080
RUN chown -R 1000:3000 /app
USER 1000:3000
Expand Down

0 comments on commit 348a7ef

Please sign in to comment.