From d416f37195dc29161e5593328b595c04f06a63ca Mon Sep 17 00:00:00 2001 From: Ethen Pociask Date: Wed, 18 Dec 2024 02:15:10 +0700 Subject: [PATCH] fix: Update docker builds for amd64 images - consolidate to single build target --- .github/workflows/docker-upload.yml | 191 ++++++++++++---------------- 1 file changed, 80 insertions(+), 111 deletions(-) diff --git a/.github/workflows/docker-upload.yml b/.github/workflows/docker-upload.yml index 68525c756..0d01f69c2 100644 --- a/.github/workflows/docker-upload.yml +++ b/.github/workflows/docker-upload.yml @@ -3,81 +3,65 @@ on: workflow_dispatch: jobs: - # docker-amd64: - # runs-on: linux-2xl - - # steps: - # - name: Checkout - # uses: actions/checkout@v4 - # with: - # submodules: 'recursive' - - # - name: Set up QEMU - # uses: docker/setup-qemu-action@v3 - - # - name: Set up Docker Buildx - # uses: docker/setup-buildx-action@v3 - # with: - # install: true - - # # - name: Cache Docker layers - # # uses: actions/cache@v3 - # # with: - # # path: /tmp/.buildx-cache - # # key: ${{ runner.os }}-buildx-${{ hashFiles('Dockerfile') }} - # # restore-keys: ${{ runner.os }}-buildx- - - # - name: Login to GitHub Container Registry - # uses: docker/login-action@v2 - # with: - # registry: ghcr.io - # username: ${{ github.actor }} - # password: ${{ secrets.GITHUB_TOKEN }} - - # - name: Docker meta - # id: meta - # uses: docker/metadata-action@v5 - # with: - # images: | - # ghcr.io/${{ github.repository_owner }}/nitro-eigenda - # tags: | - # type=ref,event=branch - # type=ref,event=pr - # type=ref,event=tag - # type=ref,event=tag,suffix={{sha}} - # type=semver,pattern={{version}} - # type=semver,pattern={{major}}.{{minor}} - # type=sha,prefix=,format=short,enable=true - # type=raw,value=latest,enable={{is_default_branch}} - # type=match,pattern=^(v\d+\.\d+\.\d+-\w*)\..*$,value=$1,enable={{is_default_branch}} - - # - name: "Build and push amd64" - # uses: docker/build-push-action@v3 - # with: - # target: nitro-node-dev - # context: . - # push: true - # platforms: linux/amd64 - # provenance: false - # tags: ${{ steps.meta.outputs.tags }} - # labels: ${{ steps.meta.outputs.labels }} - # # cache-from: type=local,src=/tmp/.buildx-cache - # # cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - - # # - name: Move cache - # # run: | - # # rm -rf /tmp/.buildx-cache - # # mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - # # - name: Clear cache on failure - # # if: failure() - # # run: | - # # keys=(${{ runner.os }}-buildx- ${{ runner.os }}-buildx-${{ hashFiles('Dockerfile') }}) - # # for key in "${keys[@]}"; do - # # curl -X DELETE -H "Accept: application/vnd.github.v3+json" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/actions/caches/$key" - # # done - - docker-arm64: + build-linux-amd64: + runs-on: linux-2xl + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: 'recursive' + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + install: true + + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache-amd64 + key: linux-amd64-buildx-${{ hashFiles('Dockerfile') }} + restore-keys: linux-amd64-buildx- + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ghcr.io/${{ github.repository_owner }}/nitro-eigenda + tags: | + ${{ github.ref_name }}-linux-amd64 + latest-linux-amd64 + + - name: Build and push for linux/amd64 + uses: docker/build-push-action@v5 + with: + platform: linux/amd64 + target: nitro-node-dev + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=local,src=/tmp/.buildx-cache-amd64 + cache-to: type=local,dest=/tmp/.buildx-cache-amd64-new,mode=max + + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache-amd64 + mv /tmp/.buildx-cache-amd64-new /tmp/.buildx-cache-amd64 + + build-linux-arm64: runs-on: linux-xl-arm steps: @@ -87,19 +71,19 @@ jobs: submodules: 'recursive' - name: Set up QEMU - uses: docker/setup-qemu-action@v3.2.0 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3.8.0 + uses: docker/setup-buildx-action@v3 with: install: true - # - name: Cache Docker layers - # uses: actions/cache@v3 - # with: - # path: /tmp/.buildx-cache - # key: ${{ runner.os }}-buildx-${{ hashFiles('Dockerfile') }} - # restore-keys: ${{ runner.os }}-buildx- + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache-arm64 + key: linux-arm64-buildx-${{ hashFiles('Dockerfile') }} + restore-keys: linux-arm64-buildx- - name: Login to GitHub Container Registry uses: docker/login-action@v2 @@ -115,37 +99,22 @@ jobs: images: | ghcr.io/${{ github.repository_owner }}/nitro-eigenda tags: | - type=ref,event=branch - type=ref,event=pr - type=ref,event=tag - type=ref,event=tag,suffix={{sha}} - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=sha,prefix=,format=short,enable=true - type=raw,value=latest,enable={{is_default_branch}} - type=match,pattern=^(v\d+\.\d+\.\d+-\w*)\..*$,value=$1,enable={{is_default_branch}} - - - name: "Build and push arm64" - uses: docker/build-push-action@v6.10.0 + ${{ github.ref_name }}-linux-arm64 + latest-linux-arm64 + + - name: Build and push for linux/arm64 + uses: docker/build-push-action@v5 with: + platform: linux/arm64/v8 target: nitro-node-dev context: . - platforms: linux/arm64, linux/amd64 push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - # cache-from: type=local,src=/tmp/.buildx-cache - # cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - - # - name: Move cache - # run: | - # rm -rf /tmp/.buildx-cache - # mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - # - name: Clear cache on failure - # if: failure() - # run: | - # keys=(${{ runner.os }}-buildx- ${{ runner.os }}-buildx-${{ hashFiles('Dockerfile') }}) - # for key in "${keys[@]}"; do - # curl -X DELETE -H "Accept: application/vnd.github.v3+json" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/actions/caches/$key" - # done \ No newline at end of file + cache-from: type=local,src=/tmp/.buildx-cache-arm64 + cache-to: type=local,dest=/tmp/.buildx-cache-arm64-new,mode=max + + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache-arm64 + mv /tmp/.buildx-cache-arm64-new /tmp/.buildx-cache-arm64 \ No newline at end of file