From 442eeadae33824671c0ceeb1eb2a4ca46a76fcb9 Mon Sep 17 00:00:00 2001 From: hriprsd Date: Wed, 9 Oct 2024 15:43:39 +0530 Subject: [PATCH 1/5] Creating unified Dockerfile for arm/amd arch --- Dockerfile | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6e03a4942..bfa23c20a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,8 @@ -FROM mcr.microsoft.com/dotnet/sdk:8.0-jammy AS build-env +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env WORKDIR /app ARG COMMIT +ARG TARGETPLATFORM +ARG BUILDPLATFORM # Copy csproj and restore as distinct layers COPY ./Lib9c/Lib9c/Lib9c.csproj ./Lib9c/ @@ -16,23 +18,40 @@ RUN dotnet restore NineChronicles.Headless.Executable # Copy everything else and build COPY . ./ -RUN dotnet publish NineChronicles.Headless.Executable/NineChronicles.Headless.Executable.csproj \ +RUN < Date: Wed, 9 Oct 2024 15:47:59 +0530 Subject: [PATCH 2/5] creating unified ACC dockerfile to support multiple arch --- Dockerfile.ACC | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Dockerfile.ACC b/Dockerfile.ACC index 515c74228..cfe01cbf5 100644 --- a/Dockerfile.ACC +++ b/Dockerfile.ACC @@ -2,6 +2,8 @@ FROM mcr.microsoft.com/dotnet/sdk:8.0-jammy AS build-env WORKDIR /app ARG COMMIT +ARG TARGETPLATFORM +ARG BUILDPLATFORM # Copy csproj and restore as distinct layers COPY ./Lib9c/Lib9c/Lib9c.csproj ./Lib9c/ @@ -13,15 +15,33 @@ RUN dotnet restore NineChronicles.Headless.AccessControlCenter # Copy everything else and build COPY . ./ -RUN dotnet publish NineChronicles.Headless.AccessControlCenter/NineChronicles.Headless.AccessControlCenter.csproj \ +RUN < Date: Wed, 9 Oct 2024 15:51:32 +0530 Subject: [PATCH 3/5] updating build ARGS for multi arch support --- .github/workflows/push_docker_image.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/push_docker_image.yml b/.github/workflows/push_docker_image.yml index 90bde4c02..445c39e18 100644 --- a/.github/workflows/push_docker_image.yml +++ b/.github/workflows/push_docker_image.yml @@ -54,6 +54,8 @@ jobs: -f ${{ matrix.docker.dockerfile }}.amd64 \ -t ${{ matrix.docker.repo }}:git-${{ github.sha }}-amd64 \ --build-arg COMMIT=git-${{ github.sha }} + --build-arg TARGETPLATFORM=linux/amd64 + --build-arg BUILDPLATFORM=linux/amd64 docker push ${{ matrix.docker.repo }}:git-${{ github.sha }}-amd64 - name: build-and-push-arm64v8 run: | @@ -61,6 +63,8 @@ jobs: -f ${{ matrix.docker.dockerfile }}.arm64v8 \ -t ${{ matrix.docker.repo }}:git-${{ github.sha }}-arm64v8 \ --build-arg COMMIT=git-${{ github.sha }} + --build-arg TARGETPLATFORM=linux/arm64 + --build-arg BUILDPLATFORM=linux/arm64 docker push ${{ matrix.docker.repo }}:git-${{ github.sha }}-arm64v8 - name: merge-manifest-and-push run: | From d4ed30312a9ac70a928ca20734bd5975b0de177d Mon Sep 17 00:00:00 2001 From: hprasa638 Date: Mon, 14 Oct 2024 12:12:18 +0530 Subject: [PATCH 4/5] fix:build arg, base image --- .github/workflows/push_docker_image.yml | 2 -- Dockerfile | 3 +-- Dockerfile.ACC | 3 +-- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/push_docker_image.yml b/.github/workflows/push_docker_image.yml index 445c39e18..b05186d10 100644 --- a/.github/workflows/push_docker_image.yml +++ b/.github/workflows/push_docker_image.yml @@ -55,7 +55,6 @@ jobs: -t ${{ matrix.docker.repo }}:git-${{ github.sha }}-amd64 \ --build-arg COMMIT=git-${{ github.sha }} --build-arg TARGETPLATFORM=linux/amd64 - --build-arg BUILDPLATFORM=linux/amd64 docker push ${{ matrix.docker.repo }}:git-${{ github.sha }}-amd64 - name: build-and-push-arm64v8 run: | @@ -64,7 +63,6 @@ jobs: -t ${{ matrix.docker.repo }}:git-${{ github.sha }}-arm64v8 \ --build-arg COMMIT=git-${{ github.sha }} --build-arg TARGETPLATFORM=linux/arm64 - --build-arg BUILDPLATFORM=linux/arm64 docker push ${{ matrix.docker.repo }}:git-${{ github.sha }}-arm64v8 - name: merge-manifest-and-push run: | diff --git a/Dockerfile b/Dockerfile index bfa23c20a..cea86d51d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,6 @@ FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env WORKDIR /app ARG COMMIT ARG TARGETPLATFORM -ARG BUILDPLATFORM # Copy csproj and restore as distinct layers COPY ./Lib9c/Lib9c/Lib9c.csproj ./Lib9c/ @@ -44,7 +43,7 @@ fi EOF # Build runtime image -FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0-bookworm-slim +FROM --platform=$TARGETPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0 WORKDIR /app COPY --from=build-env /app/out . diff --git a/Dockerfile.ACC b/Dockerfile.ACC index cfe01cbf5..da97859a6 100644 --- a/Dockerfile.ACC +++ b/Dockerfile.ACC @@ -3,7 +3,6 @@ FROM mcr.microsoft.com/dotnet/sdk:8.0-jammy AS build-env WORKDIR /app ARG COMMIT ARG TARGETPLATFORM -ARG BUILDPLATFORM # Copy csproj and restore as distinct layers COPY ./Lib9c/Lib9c/Lib9c.csproj ./Lib9c/ @@ -41,7 +40,7 @@ fi EOF # Build runtime image -FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0-bookworm-slim +FROM --platform=$TARGETPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0 WORKDIR /app RUN apt-get update && apt-get install -y libc6-dev COPY --from=build-env /app/out . From 2355b36203f5e065786d9f3a2298779c51084e61 Mon Sep 17 00:00:00 2001 From: hriprsd Date: Tue, 15 Oct 2024 12:04:40 +0530 Subject: [PATCH 5/5] adding \ to treat line breaks as single command --- .github/workflows/push_docker_image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push_docker_image.yml b/.github/workflows/push_docker_image.yml index b05186d10..bd0911e71 100644 --- a/.github/workflows/push_docker_image.yml +++ b/.github/workflows/push_docker_image.yml @@ -53,7 +53,7 @@ jobs: docker build . \ -f ${{ matrix.docker.dockerfile }}.amd64 \ -t ${{ matrix.docker.repo }}:git-${{ github.sha }}-amd64 \ - --build-arg COMMIT=git-${{ github.sha }} + --build-arg COMMIT=git-${{ github.sha }} \ --build-arg TARGETPLATFORM=linux/amd64 docker push ${{ matrix.docker.repo }}:git-${{ github.sha }}-amd64 - name: build-and-push-arm64v8 @@ -61,7 +61,7 @@ jobs: docker build . \ -f ${{ matrix.docker.dockerfile }}.arm64v8 \ -t ${{ matrix.docker.repo }}:git-${{ github.sha }}-arm64v8 \ - --build-arg COMMIT=git-${{ github.sha }} + --build-arg COMMIT=git-${{ github.sha }} \ --build-arg TARGETPLATFORM=linux/arm64 docker push ${{ matrix.docker.repo }}:git-${{ github.sha }}-arm64v8 - name: merge-manifest-and-push