diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 30c9c6b03..ea915e508 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -3,7 +3,7 @@ name: Build and Publish Docker Image on: workflow_dispatch: inputs: - image_to_release: + target: type: choice description: Which image to release required: true @@ -12,11 +12,10 @@ on: - asterisc-builder - cannon-builder - kona-asterisc-prestate - override_tag: - type: string - description: A custom tag for the image - required: false - default: "" + push: + tags: + # matches tags like `service/v1.0.0` + - '*/*' env: REGISTRY: ghcr.io @@ -25,17 +24,27 @@ env: jobs: prepare: - name: Prepare Bake (${{ inputs.image_to_release }}) + name: Prepare Bake runs-on: ubuntu-latest outputs: matrix: ${{ steps.platforms.outputs.matrix }} + target: ${{ steps.target-spec.outputs.target }}} steps: - name: Checkout uses: actions/checkout@v4 + - name: Specify Target + id: target-spec + run: | + export TARGET="${{ inputs.target }}" + if [[ -z $TARGET ]]; then + export TARGET="${GIT_REF_NAME%/*}" + fi + echo "Target: $TARGET" + echo "target=$TARGET" >> $GITHUB_OUTPUT - name: Create matrix id: platforms run: | - echo "matrix=$(docker buildx bake -f docker/docker-bake.hcl ${{ inputs.image_to_release }} --print | jq -cr '.target."${{ inputs.image_to_release }}".platforms')" >>${GITHUB_OUTPUT} + echo "matrix=$(docker buildx bake -f docker/docker-bake.hcl ${{ steps.target-spec.outputs.target }} --print | jq -cr '.target."${{ steps.target-spec.outputs.target }}".platforms')" >> ${GITHUB_OUTPUT} - name: Show matrix run: | echo ${{ steps.platforms.outputs.matrix }} @@ -43,7 +52,7 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: ${{ env.REGISTRY_IMAGE }}/${{ inputs.image_to_release }} + images: ${{ env.REGISTRY_IMAGE }}/${{ steps.target-spec.outputs.target }} - name: Rename meta bake definition file run: | mv "${{ steps.meta.outputs.bake-file }}" "${{ runner.temp }}/bake-meta.json" @@ -56,7 +65,7 @@ jobs: retention-days: 1 build: - name: Build Image (${{ inputs.image_to_release }} - ${{ matrix.platform }}) + name: Build Image (${{ needs.prepare.outputs.target }} - ${{ matrix.platform }}) runs-on: ${{ matrix.platform == 'linux/amd64' && 'ubuntu-latest' || 'ubuntu-22.04-arm' }} needs: - prepare @@ -89,16 +98,15 @@ jobs: files: | ./docker/docker-bake.hcl cwd://${{ runner.temp }}/bake-meta.json - targets: ${{ inputs.image_to_release }} + targets: ${{ needs.prepare.outputs.target }} set: | *.tags= *.platform=${{ matrix.platform }} - *.output=type=image,"name=${{ env.REGISTRY_IMAGE }}/${{ inputs.image_to_release }}",push-by-digest=true,name-canonical=true,push=true + *.output=type=image,"name=${{ env.REGISTRY_IMAGE }}/${{ needs.prepare.outputs.target }}",push-by-digest=true,name-canonical=true,push=true - name: Export digest run: | mkdir -p ${{ runner.temp }}/digests - echo "${{ steps.bake.outputs.metadata }}" - digest="${{ fromJSON(steps.bake.outputs.metadata)[inputs.image_to_release]['containerimage.digest'] }}" + digest="${{ fromJSON(steps.bake.outputs.metadata)[needs.prepare.outputs.target]['containerimage.digest'] }}" touch "${{ runner.temp }}/digests/${digest#sha256:}" - name: Upload digest uses: actions/upload-artifact@v4 @@ -109,7 +117,7 @@ jobs: retention-days: 1 merge: - name: Publish Manifest (${{ inputs.image_to_release }}) + name: Publish Manifest (${{ needs.prepare.outputs.target }}) runs-on: ubuntu-latest needs: - build @@ -136,9 +144,9 @@ jobs: - name: Create manifest list and push working-directory: ${{ runner.temp }}/digests run: | - docker buildx imagetools create $(jq -cr '.target."docker-metadata-action".tags | map(select(startswith("${{ env.REGISTRY_IMAGE }}/${{ inputs.image_to_release }}")) | "-t " + .) | join(" ")' ${{ runner.temp }}/bake-meta.json) \ - $(printf '${{ env.REGISTRY_IMAGE }}/${{ inputs.image_to_release }}@sha256:%s ' *) + docker buildx imagetools create $(jq -cr '.target."docker-metadata-action".tags | map(select(startswith("${{ env.REGISTRY_IMAGE }}/${{ needs.prepare.outputs.target }}")) | "-t " + .) | join(" ")' ${{ runner.temp }}/bake-meta.json) \ + $(printf '${{ env.REGISTRY_IMAGE }}/${{ needs.prepare.outputs.target }}@sha256:%s ' *) - name: Inspect image run: | - docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}/${{ inputs.image_to_release }}:$(jq -r '.target."docker-metadata-action".args.DOCKER_META_VERSION' ${{ runner.temp }}/bake-meta.json) + docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}/${{ needs.prepare.outputs.target }}:$(jq -r '.target."docker-metadata-action".args.DOCKER_META_VERSION' ${{ runner.temp }}/bake-meta.json) diff --git a/docker/README.md b/docker/README.md index 0fa72b1d7..fca835308 100644 --- a/docker/README.md +++ b/docker/README.md @@ -39,18 +39,18 @@ docker buildx bake \ ## Cutting a Release (for maintainers / forks) -To cut a release for any of the targets, first cut a new annotated tag for the target like so: +To cut a release of the docker image for any of the targets, cut a new annotated tag for the target like so: ```sh # Example formats: -# - `kona-host-v0.1.0-beta.8` -# - `cannon-builder-v1.2.0` -TAG="-" -git tag -a $TAG "" && git push origin tag $TAG +# - `kona-host/v0.1.0-beta.8` +# - `cannon-builder/v1.2.0` +TAG="/" +git tag -a $TAG -m "" && git push origin tag $TAG ``` -Then, navigate over to the ["Build and Publish Docker Image"](https://github.com/op-rs/kona/actions/workflows/docker.yaml) action. -From there, run a `workflow_dispatch` trigger, select the tag you just pushed, and then finally select the image to release. +To run the workflow manually, navigate over to the ["Build and Publish Docker Image"](https://github.com/op-rs/kona/actions/workflows/docker.yaml) +action. From there, run a `workflow_dispatch` trigger, select the tag you just pushed, and then finally select the image to release. Or, if you prefer to use the `gh` CLI, you can run: ```sh diff --git a/docker/docker-bake.hcl b/docker/docker-bake.hcl index 6b5d5c08f..b40078f55 100644 --- a/docker/docker-bake.hcl +++ b/docker/docker-bake.hcl @@ -61,7 +61,7 @@ target "cannon-builder" { target "kona-asterisc-prestate" { inherits = ["docker-metadata-action"] context = "." - dockerfile = "docker/asterisc/asterisc-repro.dockerfile" + dockerfile = "docker/fpvm-prestates/asterisc-repro.dockerfile" args = { CLIENT_TAG = "${GIT_REF_NAME}" ASTERISC_TAG = "${ASTERISC_TAG}" diff --git a/docker/fpvm-prestates/README.md b/docker/fpvm-prestates/README.md new file mode 100644 index 000000000..41cdca213 --- /dev/null +++ b/docker/fpvm-prestates/README.md @@ -0,0 +1,12 @@ +# `fpvm-prestates` + +Images for creating reproducible prestate builds for various fault proof virtual machines. + +## Usage + +### `kona-client` + `asterisc` prestate artifacts + +```sh +# Produce the prestate artifacts for `kona-client` running on `asterisc` (version specified by `asterisc_tag`) +just asterisc +``` diff --git a/docker/asterisc/asterisc-repro.dockerfile b/docker/fpvm-prestates/asterisc-repro.dockerfile similarity index 100% rename from docker/asterisc/asterisc-repro.dockerfile rename to docker/fpvm-prestates/asterisc-repro.dockerfile diff --git a/docker/fpvm-prestates/justfile b/docker/fpvm-prestates/justfile new file mode 100644 index 000000000..40a54f518 --- /dev/null +++ b/docker/fpvm-prestates/justfile @@ -0,0 +1,27 @@ +set positional-arguments +alias asterisc := build-client-prestate-asterisc-artifacts + +# default recipe to display help information +default: + @just --list + +# Build the `kona-client` prestate artifacts for the latest release. +build-client-prestate-asterisc-artifacts kona_tag asterisc_tag out='./prestate-artifacts-asterisc': + #!/bin/bash + OUTPUT_DIR={{out}} + + # Docker bake env + export GIT_REF_NAME="{{kona_tag}}" + export DEFAULT_TAG="kona-asterisc-prestate:local" + + # Navigate to workspace root + cd ../.. + + # Create the output directory + mkdir -p $OUTPUT_DIR + + echo "Building kona-client prestate artifacts for the asterisc target. 🐚 Kona Tag: {{kona_tag}} | 🎇 Asterisc Tag: {{asterisc_tag}}" + docker buildx bake \ + --set "*.output=$OUTPUT_DIR" \ + -f docker/docker-bake.hcl \ + kona-asterisc-prestate diff --git a/justfile b/justfile index 0ebe318d0..a2715d12b 100644 --- a/justfile +++ b/justfile @@ -116,25 +116,6 @@ build-asterisc *args='': -w="/workdir" \ ghcr.io/op-rs/kona/asterisc-builder:main cargo build --workspace -Zbuild-std=core,alloc $@ --exclude kona-host -# Build the `kona-client` prestate artifacts for the latest release. -build-client-prestate-asterisc-artifacts kona_tag asterisc_tag out='./prestate-artifacts-asterisc': - #!/bin/bash - PATH_TO_REPRO_BUILDER=./build/asterisc/asterisc-repro.dockerfile - OUTPUT_DIR={{out}} - - # Docker bake env - export GIT_REF_NAME="{{kona_tag}}" - export DEFAULT_TAG="kona-asterisc-prestate:local" - - mkdir -p $OUTPUT_DIR - - echo "Building kona-client prestate artifacts for the asterisc target. 🐚 Kona Tag: {{kona_tag}} | 🎇 Asterisc Tag: {{asterisc_tag}}" - docker buildx bake \ - --progress plain \ - --set "*.output=$OUTPUT_DIR" \ - -f docker/docker-bake.hcl \ - kona-asterisc-prestate - # Clones and checks out the monorepo at the commit present in `.monorepo` monorepo: ([ ! -d monorepo ] && git clone https://github.com/ethereum-optimism/monorepo) || exit 0