Skip to content

Commit

Permalink
Build testnet-v1.38.2 and improve image caching
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonxh committed Nov 27, 2024
1 parent 7f6317a commit c6785ce
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
32 changes: 21 additions & 11 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,23 @@ on:
- main

env:
SUI_GIT_REVISION: testnet-v1.38.0
SUI_GIT_REF: testnet-v1.38.2

concurrency: docker

jobs:
prep:
runs-on: ubuntu-latest
outputs:
sui_git_sha: ${{ steps.checkout.outputs.commit }}
steps:
- name: Checkout sui
id: checkout
uses: actions/checkout@v4
with:
repository: MystenLabs/sui
ref: ${{ env.SUI_GIT_REF }}

build_push:
permissions:
contents: read
Expand All @@ -28,6 +40,10 @@ jobs:
- runner: ARM64
platform: linux/arm64

needs: prep
env:
SUI_GIT_REF: ${{ needs.prep.outputs.sui_git_sha }}
PLATFORM: ${{ matrix.platform }}
runs-on:
- self-hosted
- ${{ matrix.runner }}
Expand All @@ -50,23 +66,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: sui-node,sui
push: ${{ github.event_name == 'push' }}
env:
PLATFORM: ${{ matrix.platform }}

manifest:
permissions:
Expand All @@ -77,7 +87,7 @@ jobs:
matrix:
target: [sui-node, sui]

needs: build_push
needs: [prep, build_push]
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
Expand All @@ -90,6 +100,6 @@ jobs:

- name: Create manifest
run: |
docker buildx imagetools create -t ghcr.io/shinamicorp/${{ matrix.target }}:${{ env.SUI_GIT_REVISION }} \
ghcr.io/shinamicorp/${{ matrix.target }}:${{ env.SUI_GIT_REVISION }}-linux-amd64 \
ghcr.io/shinamicorp/${{ matrix.target }}:${{ env.SUI_GIT_REVISION }}-linux-arm64 \
docker buildx imagetools create -t ghcr.io/shinamicorp/${{ matrix.target }}:${{ env.SUI_GIT_REF }} \
ghcr.io/shinamicorp/${{ matrix.target }}:${{ needs.prep.outputs.sui_git_sha }}-linux-amd64 \
ghcr.io/shinamicorp/${{ matrix.target }}:${{ needs.prep.outputs.sui_git_sha }}-linux-arm64 \
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ FROM builder-base AS builder
WORKDIR /usr/src/sui

# Shallow clone of a specific commit
ARG SUI_GIT_REVISION
ARG SUI_GIT_REF
RUN git init && \
git remote add origin https://github.com/MystenLabs/sui.git && \
git fetch --depth 1 origin ${SUI_GIT_REVISION} && \
git fetch --depth 1 origin ${SUI_GIT_REF} && \
git checkout FETCH_HEAD

RUN cargo build --locked --release --bin sui-node
Expand Down
8 changes: 4 additions & 4 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
variable "SUI_GIT_REVISION" {}
variable "SUI_GIT_REF" {}

variable "PLATFORM" {}

Expand All @@ -15,12 +15,12 @@ variable "_REMOTE_CACHE_RUNTIME_BASE" {
}

variable "_REMOTE_CACHE_BINARIES" {
default = "type=registry,ref=ghcr.io/shinamicorp/sui:cache-binaries-${SUI_GIT_REVISION}-${_PLATFORM_TAG}"
default = "type=registry,ref=ghcr.io/shinamicorp/sui:cache-binaries-${SUI_GIT_REF}-${_PLATFORM_TAG}"
}

function "tag" {
params = [target]
result = "ghcr.io/shinamicorp/${target}:${SUI_GIT_REVISION}-${_PLATFORM_TAG}"
result = "ghcr.io/shinamicorp/${target}:${SUI_GIT_REF}-${_PLATFORM_TAG}"
}

function "local_cache_dir" {
Expand All @@ -31,7 +31,7 @@ function "local_cache_dir" {
target "_common" {
platforms = [PLATFORM]
args = {
SUI_GIT_REVISION = SUI_GIT_REVISION
SUI_GIT_REF = SUI_GIT_REF
}
cache-from = [
"type=local,src=${local_cache_dir("builder-base")}",
Expand Down

0 comments on commit c6785ce

Please sign in to comment.