From 4ab2d3d67ad3a3a489405e4952bbcec247d6ce17 Mon Sep 17 00:00:00 2001 From: Vederis Leunardus Date: Sat, 20 Apr 2024 17:14:35 +0800 Subject: [PATCH 1/5] feat: build for arm64 platform --- .github/workflows/build-deploy-container.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-deploy-container.yml b/.github/workflows/build-deploy-container.yml index 141368426..066b8af71 100644 --- a/.github/workflows/build-deploy-container.yml +++ b/.github/workflows/build-deploy-container.yml @@ -12,6 +12,12 @@ env: jobs: build-publish-webapp: + strategy: + fail-fast: false + matrix: + platform: + - linux/amd64 + - linux/arm64 name: Build and deploy webapp container runs-on: ubuntu-latest environment: production @@ -35,10 +41,11 @@ jobs: # Builds and push the Docker image. - name: Build and push Docker image - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v5 with: context: . file: ./packages/webapp/Dockerfile + platform: ${{ matrix.platform }} push: true tags: ghcr.io/bigcapitalhq/webapp:latest labels: ${{ steps.meta.outputs.labels }} @@ -66,10 +73,11 @@ jobs: # Builds and push the Docker image. - name: Build and push Docker image - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v5 with: context: ./ file: ./packages/server/Dockerfile + platform: ${{ matrix.platform }} push: true tags: ghcr.io/bigcapitalhq/server:latest labels: ${{ steps.meta.outputs.labels }} From ae2410dbe67e9c58f300dffc912dc2ac11cbea79 Mon Sep 17 00:00:00 2001 From: Vederis Leunardus Date: Sat, 20 Apr 2024 17:31:05 +0800 Subject: [PATCH 2/5] fix: typo and add buildx and qemu --- .github/workflows/build-deploy-container.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-deploy-container.yml b/.github/workflows/build-deploy-container.yml index 066b8af71..231148fb0 100644 --- a/.github/workflows/build-deploy-container.yml +++ b/.github/workflows/build-deploy-container.yml @@ -23,8 +23,11 @@ jobs: environment: production steps: - name: Checkout - uses: actions/checkout@v2 - + uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 # Login to Container registry. - name: Log in to the Container registry uses: docker/login-action@v1 @@ -45,7 +48,7 @@ jobs: with: context: . file: ./packages/webapp/Dockerfile - platform: ${{ matrix.platform }} + platforms: ${{ matrix.platform }} push: true tags: ghcr.io/bigcapitalhq/webapp:latest labels: ${{ steps.meta.outputs.labels }} @@ -60,6 +63,12 @@ jobs: name: Build and deploy server container runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - name: Checkout code uses: actions/checkout@v2 @@ -77,7 +86,7 @@ jobs: with: context: ./ file: ./packages/server/Dockerfile - platform: ${{ matrix.platform }} + platforms: ${{ matrix.platform }} push: true tags: ghcr.io/bigcapitalhq/server:latest labels: ${{ steps.meta.outputs.labels }} From 9d710bc64ba17226a81248c70ede18cd795c5925 Mon Sep 17 00:00:00 2001 From: Vederis Leunardus Date: Sat, 20 Apr 2024 17:33:59 +0800 Subject: [PATCH 3/5] feat: update the docker login-action version --- .github/workflows/build-deploy-container.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build-deploy-container.yml b/.github/workflows/build-deploy-container.yml index 231148fb0..4ed18d5d9 100644 --- a/.github/workflows/build-deploy-container.yml +++ b/.github/workflows/build-deploy-container.yml @@ -69,8 +69,6 @@ jobs: uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Checkout code - uses: actions/checkout@v2 # Login to Container registry. - name: Log in to the Container registry From 39d860ad1748abe1b1b74e047c865a9535f3a43c Mon Sep 17 00:00:00 2001 From: Vederis Leunardus Date: Sat, 20 Apr 2024 17:35:10 +0800 Subject: [PATCH 4/5] feat: update the docker login-action version --- .github/workflows/build-deploy-container.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-deploy-container.yml b/.github/workflows/build-deploy-container.yml index 4ed18d5d9..6f298d9ac 100644 --- a/.github/workflows/build-deploy-container.yml +++ b/.github/workflows/build-deploy-container.yml @@ -24,13 +24,16 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + - name: Set up QEMU uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + # Login to Container registry. - name: Log in to the Container registry - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} @@ -65,14 +68,16 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + - name: Set up QEMU uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 # Login to Container registry. - name: Log in to the Container registry - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} From 9adbbc2d33186376c25a18ab677c23ab20dca104 Mon Sep 17 00:00:00 2001 From: Vederis Leunardus Date: Sun, 21 Apr 2024 20:31:56 +0800 Subject: [PATCH 5/5] feat: add the digest --- .github/workflows/build-deploy-container.yml | 57 ++++++++++++++++---- 1 file changed, 48 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-deploy-container.yml b/.github/workflows/build-deploy-container.yml index 6f298d9ac..a3d19197f 100644 --- a/.github/workflows/build-deploy-container.yml +++ b/.github/workflows/build-deploy-container.yml @@ -22,6 +22,11 @@ jobs: runs-on: ubuntu-latest environment: production steps: + - name: Prepare + run: | + platform=${{ matrix.platform }} + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV + - name: Checkout uses: actions/checkout@v4 @@ -35,9 +40,9 @@ jobs: - name: Log in to the Container registry uses: docker/login-action@v3 with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GH_TOKEN }} + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GH_TOKEN }} - name: Extract metadata (tags, labels) for Docker id: meta @@ -48,14 +53,28 @@ jobs: # Builds and push the Docker image. - name: Build and push Docker image uses: docker/build-push-action@v5 + id: build with: - context: . - file: ./packages/webapp/Dockerfile - platforms: ${{ matrix.platform }} - push: true - tags: ghcr.io/bigcapitalhq/webapp:latest - labels: ${{ steps.meta.outputs.labels }} + context: . + file: ./packages/webapp/Dockerfile + platforms: ${{ matrix.platform }} + push: true + tags: ghcr.io/bigcapitalhq/webapp:latest + labels: ${{ steps.meta.outputs.labels }} + + - name: Export digest + run: | + mkdir -p /tmp/digests + digest="${{ steps.build.outputs.digest }}" + touch "/tmp/digests/${digest#sha256:}" + - name: Upload digest + uses: actions/upload-artifact@v4 + with: + name: digests-main-${{ env.PLATFORM_PAIR }} + path: /tmp/digests/* + if-no-files-found: error + retention-days: 1 # Send notification to Slack channel. - name: Slack Notification built and published webapp container successfully. uses: rtCamp/action-slack-notify@v2 @@ -66,6 +85,11 @@ jobs: name: Build and deploy server container runs-on: ubuntu-latest steps: + - name: Prepare + run: | + platform=${{ matrix.platform }} + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV + - name: Checkout uses: actions/checkout@v4 @@ -86,6 +110,7 @@ jobs: # Builds and push the Docker image. - name: Build and push Docker image uses: docker/build-push-action@v5 + id: build with: context: ./ file: ./packages/server/Dockerfile @@ -94,6 +119,20 @@ jobs: tags: ghcr.io/bigcapitalhq/server:latest labels: ${{ steps.meta.outputs.labels }} + - name: Export digest + run: | + mkdir -p /tmp/digests + digest="${{ steps.build.outputs.digest }}" + touch "/tmp/digests/${digest#sha256:}" + + - name: Upload digest + uses: actions/upload-artifact@v4 + with: + name: digests-main-${{ env.PLATFORM_PAIR }} + path: /tmp/digests/* + if-no-files-found: error + retention-days: 1 + # Send notification to Slack channel. - name: Slack Notification built and published server container successfully. uses: rtCamp/action-slack-notify@v2