From be29f1f3aa4e6b77a326f0a4f9332c6e33233626 Mon Sep 17 00:00:00 2001 From: SarathKrishnamurthy Date: Mon, 19 Aug 2024 11:22:19 +0200 Subject: [PATCH 01/13] test building images --- .github/workflows/staging.yaml | 54 +++++----------------------------- 1 file changed, 7 insertions(+), 47 deletions(-) diff --git a/.github/workflows/staging.yaml b/.github/workflows/staging.yaml index a624ffc..9a1de43 100644 --- a/.github/workflows/staging.yaml +++ b/.github/workflows/staging.yaml @@ -27,62 +27,22 @@ jobs: with: fetch-depth: 0 - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ secrets.GH_REGISTRY_URL }}/${{ env.IMAGE_NAME }},${{ secrets.AZURE_REGISTRY_URL }}/${{ env.IMAGE_NAME }} - tags: | - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=sha,format=long,suffix=,prefix= - - - name: ACR authentication - uses: azure/docker-login@v2 - with: - login-server: ${{ secrets.AZURE_REGISTRY_URL }} - username: ${{ secrets.AZURE_REGISTRY_USERNAME }} - password: ${{ secrets.AZURE_REGISTRY_PASSWORD }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - - name: GPR authentication - uses: azure/docker-login@v2 + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 with: - login-server: ${{ secrets.GH_REGISTRY_URL }} + registry: ghcr.io/SarathKrishnamurthy/httpstatus username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Build and push uses: docker/build-push-action@v6 with: context: . file: src/Teapot.Web/Dockerfile push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + tags: test + labels: fortest platforms: linux/amd64,linux/arm64 - - deploy-azure: - runs-on: ubuntu-latest - name: Deploy to Azure - environment: - name: production - needs: [build-images] - - steps: - - name: Azure authentication - uses: azure/login@v2 - with: - client-id: ${{ secrets.AZURE_CLIENT_ID }} - tenant-id: ${{ secrets.AZURE_TENANT_ID }} - subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} - - - name: Deploy to Azure WebApp - uses: azure/webapps-deploy@v3 - with: - app-name: ${{ env.AZURE_WEBAPP_NAME }} - images: ${{ secrets.AZURE_REGISTRY_URL }}/${{ env.IMAGE_NAME }}:${{ github.sha }} From fc2254c708a3a4acaca45ec7b6bc917c85e1e929 Mon Sep 17 00:00:00 2001 From: SarathKrishnamurthy Date: Mon, 19 Aug 2024 11:27:25 +0200 Subject: [PATCH 02/13] using docker buildx command --- .github/workflows/staging.yaml | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/.github/workflows/staging.yaml b/.github/workflows/staging.yaml index 9a1de43..bd01b16 100644 --- a/.github/workflows/staging.yaml +++ b/.github/workflows/staging.yaml @@ -16,8 +16,6 @@ jobs: build-images: runs-on: ubuntu-latest name: Build Docker images for Azure Container Registry and GitHub Container Registry - environment: - name: build permissions: contents: read packages: write @@ -37,12 +35,6 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push - uses: docker/build-push-action@v6 - with: - context: . - file: src/Teapot.Web/Dockerfile - push: true - tags: test - labels: fortest - platforms: linux/amd64,linux/arm64 + - name: docker buildx build + run: | + docker buildx build --push --platform linux/amd64,linux/arm64 -t test -f src/Teapot.Web/Dockerfile . From ff0c33f3d8c82fe3bfb0dcb9cd9cb41f9178a078 Mon Sep 17 00:00:00 2001 From: SarathKrishnamurthy Date: Mon, 19 Aug 2024 11:28:55 +0200 Subject: [PATCH 03/13] build arm image only --- .github/workflows/staging.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/staging.yaml b/.github/workflows/staging.yaml index bd01b16..b0e4f82 100644 --- a/.github/workflows/staging.yaml +++ b/.github/workflows/staging.yaml @@ -37,4 +37,4 @@ jobs: - name: docker buildx build run: | - docker buildx build --push --platform linux/amd64,linux/arm64 -t test -f src/Teapot.Web/Dockerfile . + docker buildx build --push --platform linux/arm64 -t test -f src/Teapot.Web/Dockerfile . From 260f426d2b4e9a283103f25ef55620a3abb12344 Mon Sep 17 00:00:00 2001 From: SarathKrishnamurthy Date: Mon, 19 Aug 2024 11:33:31 +0200 Subject: [PATCH 04/13] fix autherization --- .github/workflows/staging.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/staging.yaml b/.github/workflows/staging.yaml index b0e4f82..6620b52 100644 --- a/.github/workflows/staging.yaml +++ b/.github/workflows/staging.yaml @@ -37,4 +37,4 @@ jobs: - name: docker buildx build run: | - docker buildx build --push --platform linux/arm64 -t test -f src/Teapot.Web/Dockerfile . + docker buildx build --push --platform linux/arm64 -t SarathKrishnamurthy/httpstatus:test -f src/Teapot.Web/Dockerfile . From 9918f63ca3cab21fcca08e4a316f681310036337 Mon Sep 17 00:00:00 2001 From: SarathKrishnamurthy Date: Mon, 19 Aug 2024 11:34:58 +0200 Subject: [PATCH 05/13] fix repo url --- .github/workflows/staging.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/staging.yaml b/.github/workflows/staging.yaml index 6620b52..2be67e4 100644 --- a/.github/workflows/staging.yaml +++ b/.github/workflows/staging.yaml @@ -37,4 +37,4 @@ jobs: - name: docker buildx build run: | - docker buildx build --push --platform linux/arm64 -t SarathKrishnamurthy/httpstatus:test -f src/Teapot.Web/Dockerfile . + docker buildx build --push --platform linux/arm64 -t ghcr.io/SarathKrishnamurthy/httpstatus:test -f src/Teapot.Web/Dockerfile . From d938f8234c31234200ee64bc23e3b99a9c16f973 Mon Sep 17 00:00:00 2001 From: SarathKrishnamurthy Date: Mon, 19 Aug 2024 11:38:29 +0200 Subject: [PATCH 06/13] fix repo name --- .github/workflows/staging.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/staging.yaml b/.github/workflows/staging.yaml index 2be67e4..1c505b7 100644 --- a/.github/workflows/staging.yaml +++ b/.github/workflows/staging.yaml @@ -31,10 +31,10 @@ jobs: - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: - registry: ghcr.io/SarathKrishnamurthy/httpstatus + registry: ghcr.io/sarathkrishnamurthy/httpstatus username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: docker buildx build run: | - docker buildx build --push --platform linux/arm64 -t ghcr.io/SarathKrishnamurthy/httpstatus:test -f src/Teapot.Web/Dockerfile . + docker buildx build --push --platform linux/arm64 -t ghcr.io/sarathkrishnamurthy/httpstatus:test -f src/Teapot.Web/Dockerfile . From 57349f9bf246c565ef119815bcb8886a26e99e64 Mon Sep 17 00:00:00 2001 From: SarathKrishnamurthy Date: Mon, 19 Aug 2024 12:03:03 +0200 Subject: [PATCH 07/13] trying qemu --- .github/workflows/staging.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/staging.yaml b/.github/workflows/staging.yaml index 1c505b7..6c99065 100644 --- a/.github/workflows/staging.yaml +++ b/.github/workflows/staging.yaml @@ -25,6 +25,9 @@ jobs: with: fetch-depth: 0 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -37,4 +40,4 @@ jobs: - name: docker buildx build run: | - docker buildx build --push --platform linux/arm64 -t ghcr.io/sarathkrishnamurthy/httpstatus:test -f src/Teapot.Web/Dockerfile . + docker buildx build --pull --push --platform linux/arm64,linux/amd64 -t ghcr.io/sarathkrishnamurthy/httpstatus:test1 -f src/Teapot.Web/Dockerfile . From c16e9426758a08d4146e7bc014d73bc0a587f797 Mon Sep 17 00:00:00 2001 From: SarathKrishnamurthy Date: Mon, 19 Aug 2024 14:32:39 +0200 Subject: [PATCH 08/13] arm/v8 --- .github/workflows/staging.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/staging.yaml b/.github/workflows/staging.yaml index 6c99065..de0952f 100644 --- a/.github/workflows/staging.yaml +++ b/.github/workflows/staging.yaml @@ -40,4 +40,4 @@ jobs: - name: docker buildx build run: | - docker buildx build --pull --push --platform linux/arm64,linux/amd64 -t ghcr.io/sarathkrishnamurthy/httpstatus:test1 -f src/Teapot.Web/Dockerfile . + docker buildx build --pull --push --platform linux/arm/v8,linux/amd64 -t ghcr.io/sarathkrishnamurthy/httpstatus:test2 -f src/Teapot.Web/Dockerfile . From f80528df23bdc7221c01312053382aaa67941c01 Mon Sep 17 00:00:00 2001 From: SarathKrishnamurthy Date: Mon, 19 Aug 2024 18:00:30 +0200 Subject: [PATCH 09/13] v8 --- .github/workflows/staging.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/staging.yaml b/.github/workflows/staging.yaml index de0952f..5965dbe 100644 --- a/.github/workflows/staging.yaml +++ b/.github/workflows/staging.yaml @@ -40,4 +40,4 @@ jobs: - name: docker buildx build run: | - docker buildx build --pull --push --platform linux/arm/v8,linux/amd64 -t ghcr.io/sarathkrishnamurthy/httpstatus:test2 -f src/Teapot.Web/Dockerfile . + docker buildx build --pull --push --platform linux/arm64v8,linux/amd64 -t ghcr.io/sarathkrishnamurthy/httpstatus:test2 -f src/Teapot.Web/Dockerfile . From c83ade65a62c0eab5dbb88e0671494b843aa67de Mon Sep 17 00:00:00 2001 From: SarathKrishnamurthy Date: Tue, 20 Aug 2024 14:27:23 +0200 Subject: [PATCH 10/13] fix target arch --- src/Teapot.Web/Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Teapot.Web/Dockerfile b/src/Teapot.Web/Dockerfile index 543a7cc..3b7ca03 100644 --- a/src/Teapot.Web/Dockerfile +++ b/src/Teapot.Web/Dockerfile @@ -6,17 +6,18 @@ EXPOSE 80 EXPOSE 443 FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build +ARG TARGETARCH WORKDIR /src COPY ["src/Teapot.Web/Teapot.Web.csproj", "Teapot.Web/"] COPY [".git", ".git"] RUN dotnet restore "Teapot.Web/Teapot.Web.csproj" COPY src/Teapot.Web Teapot.Web WORKDIR "/src/Teapot.Web" -RUN dotnet build "Teapot.Web.csproj" -c Release -o /app/build +RUN dotnet build "Teapot.Web.csproj" -c Release -o /app/build --arch $TARGETARCH FROM build AS publish ARG TARGETARCH -RUN dotnet publish "Teapot.Web.csproj" -c Release -o /app/publish -a $TARGETARCH +RUN dotnet publish "Teapot.Web.csproj" -c Release -o /app/publish --arch $TARGETARCH FROM base AS final WORKDIR /app From c438a391ec6603cb65d55402ebc6b1d813afde56 Mon Sep 17 00:00:00 2001 From: SarathKrishnamurthy Date: Tue, 20 Aug 2024 14:28:17 +0200 Subject: [PATCH 11/13] use arm 64 after fix --- .github/workflows/staging.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/staging.yaml b/.github/workflows/staging.yaml index 5965dbe..db17199 100644 --- a/.github/workflows/staging.yaml +++ b/.github/workflows/staging.yaml @@ -40,4 +40,4 @@ jobs: - name: docker buildx build run: | - docker buildx build --pull --push --platform linux/arm64v8,linux/amd64 -t ghcr.io/sarathkrishnamurthy/httpstatus:test2 -f src/Teapot.Web/Dockerfile . + docker buildx build --pull --push --platform linux/arm64,linux/amd64 -t ghcr.io/sarathkrishnamurthy/httpstatus:test3 -f src/Teapot.Web/Dockerfile . From 12d2dbc422e9c7dd1797fe9441cfe9d40d61729f Mon Sep 17 00:00:00 2001 From: SarathKrishnamurthy Date: Tue, 20 Aug 2024 14:52:05 +0200 Subject: [PATCH 12/13] redefining the docker layer --- .github/workflows/staging.yaml | 2 +- src/Teapot.Web/Dockerfile | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/staging.yaml b/.github/workflows/staging.yaml index db17199..78f7eb2 100644 --- a/.github/workflows/staging.yaml +++ b/.github/workflows/staging.yaml @@ -40,4 +40,4 @@ jobs: - name: docker buildx build run: | - docker buildx build --pull --push --platform linux/arm64,linux/amd64 -t ghcr.io/sarathkrishnamurthy/httpstatus:test3 -f src/Teapot.Web/Dockerfile . + docker buildx build --pull --push --platform linux/arm64,linux/amd64 -t ghcr.io/sarathkrishnamurthy/httpstatus:test4 -f src/Teapot.Web/Dockerfile . diff --git a/src/Teapot.Web/Dockerfile b/src/Teapot.Web/Dockerfile index 3b7ca03..05d3c9c 100644 --- a/src/Teapot.Web/Dockerfile +++ b/src/Teapot.Web/Dockerfile @@ -1,9 +1,5 @@ #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. -FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS base -WORKDIR /app -EXPOSE 80 -EXPOSE 443 FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build ARG TARGETARCH @@ -19,7 +15,9 @@ FROM build AS publish ARG TARGETARCH RUN dotnet publish "Teapot.Web.csproj" -c Release -o /app/publish --arch $TARGETARCH -FROM base AS final +FROM mcr.microsoft.com/dotnet/sdk:8.0 WORKDIR /app +EXPOSE 80 +EXPOSE 443 COPY --from=publish /app/publish . ENTRYPOINT ["dotnet", "Teapot.Web.dll"] From f7f483771e5ebae6b4cb2bb8e569df824be45fad Mon Sep 17 00:00:00 2001 From: SarathKrishnamurthy Date: Tue, 20 Aug 2024 15:45:53 +0200 Subject: [PATCH 13/13] testing with existing setup --- .github/workflows/staging.yaml | 14 ++++++++++---- src/Teapot.Web/Dockerfile | 13 +++++++------ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/.github/workflows/staging.yaml b/.github/workflows/staging.yaml index 78f7eb2..9ac4718 100644 --- a/.github/workflows/staging.yaml +++ b/.github/workflows/staging.yaml @@ -36,8 +36,14 @@ jobs: with: registry: ghcr.io/sarathkrishnamurthy/httpstatus username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + password: ${{ secrets.GITHUB_TOKEN }} - - name: docker buildx build - run: | - docker buildx build --pull --push --platform linux/arm64,linux/amd64 -t ghcr.io/sarathkrishnamurthy/httpstatus:test4 -f src/Teapot.Web/Dockerfile . + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + file: src/Teapot.Web/Dockerfile + push: true + tags: ghcr.io/sarathkrishnamurthy/httpstatus:test5 + labels: test-label + platforms: linux/amd64,linux/arm64 diff --git a/src/Teapot.Web/Dockerfile b/src/Teapot.Web/Dockerfile index 05d3c9c..3db683d 100644 --- a/src/Teapot.Web/Dockerfile +++ b/src/Teapot.Web/Dockerfile @@ -1,23 +1,24 @@ #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS base +WORKDIR /app +EXPOSE 80 +EXPOSE 443 FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build -ARG TARGETARCH WORKDIR /src COPY ["src/Teapot.Web/Teapot.Web.csproj", "Teapot.Web/"] COPY [".git", ".git"] RUN dotnet restore "Teapot.Web/Teapot.Web.csproj" COPY src/Teapot.Web Teapot.Web WORKDIR "/src/Teapot.Web" -RUN dotnet build "Teapot.Web.csproj" -c Release -o /app/build --arch $TARGETARCH +RUN dotnet build "Teapot.Web.csproj" -c Release -o /app/build FROM build AS publish ARG TARGETARCH -RUN dotnet publish "Teapot.Web.csproj" -c Release -o /app/publish --arch $TARGETARCH +RUN dotnet publish "Teapot.Web.csproj" -c Release -o /app/publish -a $TARGETARCH -FROM mcr.microsoft.com/dotnet/sdk:8.0 +FROM base AS final WORKDIR /app -EXPOSE 80 -EXPOSE 443 COPY --from=publish /app/publish . ENTRYPOINT ["dotnet", "Teapot.Web.dll"]