From be1ec4a8d496e746922224c31ca25685813d7cb1 Mon Sep 17 00:00:00 2001 From: Hao Xia Date: Thu, 21 Nov 2024 10:40:35 -0800 Subject: [PATCH 1/3] Build aptos-node-v1.23.3 --- .github/workflows/docker.yaml | 37 ++++++++++++++++++++++++----------- Dockerfile | 4 ++-- docker-bake.hcl | 8 ++++---- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 894f2bd..5e47d6e 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -10,11 +10,28 @@ on: - main env: - APTOS_GIT_REVISION: aptos-node-v1.23.2 + APTOS_GIT_REF: aptos-node-v1.23.3 concurrency: docker jobs: + prep: + runs-on: ubuntu-latest + outputs: + aptos_git_sha: $${{ steps.resolve.outputs.aptos_git_sha }} + steps: + - name: Checkout aptos-core + uses: actions/checkout@v4 + with: + repository: aptos-labs/aptos-core + ref: ${{ env.APTOS_GIT_REF }} + + - name: Resolve aptos-core commit SHA + id: resolve + run: | + sha=$(git rev-list -n1 HEAD) + echo "aptos_git_sha=$sha" | tee -a "$GITHUB_OUTPUT" + build_push: permissions: contents: read @@ -28,6 +45,10 @@ jobs: - runner: ARM64 platform: linux/arm64 + needs: prep + env: + APTOS_GIT_REF: ${{ needs.prep.outputs.aptos_git_sha }} + PLATFORM: ${{ matrix.platform }} runs-on: - self-hosted - ${{ matrix.runner }} @@ -50,23 +71,17 @@ jobs: uses: docker/bake-action@v5 with: targets: cache-builder-base,cache-runtime-base - env: - PLATFORM: ${{ matrix.platform }} - name: Bake and populate binaries cache uses: docker/bake-action@v5 with: targets: cache-binaries - env: - PLATFORM: ${{ matrix.platform }} - name: Bake images uses: docker/bake-action@v5 with: targets: aptos-node,aptos push: ${{ github.event_name == 'push' }} - env: - PLATFORM: ${{ matrix.platform }} manifest: permissions: @@ -77,7 +92,7 @@ jobs: matrix: target: [aptos-node, aptos] - needs: build_push + needs: [prep, build_push] if: github.event_name == 'push' runs-on: ubuntu-latest steps: @@ -90,6 +105,6 @@ jobs: - name: Create manifest run: | - docker buildx imagetools create -t ghcr.io/shinamicorp/${{ matrix.target }}:${{ env.APTOS_GIT_REVISION }} \ - ghcr.io/shinamicorp/${{ matrix.target }}:${{ env.APTOS_GIT_REVISION }}-linux-amd64 \ - ghcr.io/shinamicorp/${{ matrix.target }}:${{ env.APTOS_GIT_REVISION }}-linux-arm64 \ + docker buildx imagetools create -t ghcr.io/shinamicorp/${{ matrix.target }}:${{ env.APTOS_GIT_REF }} \ + ghcr.io/shinamicorp/${{ matrix.target }}:${{ needs.prep.outputs.aptos_git_sha }}-linux-amd64 \ + ghcr.io/shinamicorp/${{ matrix.target }}:${{ needs.prep.outputs.aptos_git_sha }}-linux-arm64 \ diff --git a/Dockerfile b/Dockerfile index 5467811..f175d23 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,10 +20,10 @@ FROM builder-base AS builder WORKDIR /usr/src/aptos # Shallow clone of a specific commit -ARG APTOS_GIT_REVISION +ARG APTOS_GIT_REF RUN git init && \ git remote add origin https://github.com/aptos-labs/aptos-core.git && \ - git fetch --depth 1 origin ${APTOS_GIT_REVISION} && \ + git fetch --depth 1 origin ${APTOS_GIT_REF} && \ git checkout FETCH_HEAD RUN cargo build --locked --release --package aptos-node diff --git a/docker-bake.hcl b/docker-bake.hcl index 42c1dc9..0ce62d0 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -1,4 +1,4 @@ -variable "APTOS_GIT_REVISION" {} +variable "APTOS_GIT_REF" {} variable "PLATFORM" {} @@ -15,12 +15,12 @@ variable "_REMOTE_CACHE_RUNTIME_BASE" { } variable "_REMOTE_CACHE_BINARIES" { - default = "type=registry,ref=ghcr.io/shinamicorp/aptos:cache-binaries-${APTOS_GIT_REVISION}-${_PLATFORM_TAG}" + default = "type=registry,ref=ghcr.io/shinamicorp/aptos:cache-binaries-${APTOS_GIT_REF}-${_PLATFORM_TAG}" } function "tag" { params = [target] - result = "ghcr.io/shinamicorp/${target}:${APTOS_GIT_REVISION}-${_PLATFORM_TAG}" + result = "ghcr.io/shinamicorp/${target}:${APTOS_GIT_REF}-${_PLATFORM_TAG}" } function "local_cache_dir" { @@ -31,7 +31,7 @@ function "local_cache_dir" { target "_common" { platforms = [PLATFORM] args = { - APTOS_GIT_REVISION = APTOS_GIT_REVISION + APTOS_GIT_REF = APTOS_GIT_REF } cache-from = [ "type=local,src=${local_cache_dir("builder-base")}", From 94f7120199f25f153ebe4f5787ef2bd7667010db Mon Sep 17 00:00:00 2001 From: Hao Xia Date: Thu, 21 Nov 2024 12:14:50 -0800 Subject: [PATCH 2/3] fix --- .github/workflows/docker.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 5e47d6e..205c984 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -18,7 +18,7 @@ jobs: prep: runs-on: ubuntu-latest outputs: - aptos_git_sha: $${{ steps.resolve.outputs.aptos_git_sha }} + aptos_git_sha: ${{ steps.resolve.outputs.aptos_git_sha }} steps: - name: Checkout aptos-core uses: actions/checkout@v4 From 872acb5b3286ff4b2a30978b8c81391e32c65046 Mon Sep 17 00:00:00 2001 From: Hao Xia Date: Thu, 21 Nov 2024 15:19:17 -0800 Subject: [PATCH 3/3] use checkout output --- .github/workflows/docker.yaml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 205c984..2376841 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -18,20 +18,15 @@ jobs: prep: runs-on: ubuntu-latest outputs: - aptos_git_sha: ${{ steps.resolve.outputs.aptos_git_sha }} + aptos_git_sha: ${{ steps.checkout.outputs.commit }} steps: - name: Checkout aptos-core + id: checkout uses: actions/checkout@v4 with: repository: aptos-labs/aptos-core ref: ${{ env.APTOS_GIT_REF }} - - name: Resolve aptos-core commit SHA - id: resolve - run: | - sha=$(git rev-list -n1 HEAD) - echo "aptos_git_sha=$sha" | tee -a "$GITHUB_OUTPUT" - build_push: permissions: contents: read