Skip to content

Commit

Permalink
relocate prestate builds
Browse files Browse the repository at this point in the history
  • Loading branch information
clabby committed Jan 26, 2025
1 parent 3f5de4a commit 20d45af
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 45 deletions.
44 changes: 26 additions & 18 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -25,25 +24,35 @@ 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 }}
- name: Docker meta
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"
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)
14 changes: 7 additions & 7 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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="<target_name>-<version>"
git tag -a $TAG "<tag description>" && git push origin tag $TAG
# - `kona-host/v0.1.0-beta.8`
# - `cannon-builder/v1.2.0`
TAG="<target_name>/<version>"
git tag -a $TAG -m "<tag description>" && 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
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
12 changes: 12 additions & 0 deletions docker/fpvm-prestates/README.md
Original file line number Diff line number Diff line change
@@ -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 <kona_tag> <asterisc_tag>
```
File renamed without changes.
27 changes: 27 additions & 0 deletions docker/fpvm-prestates/justfile
Original file line number Diff line number Diff line change
@@ -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
19 changes: 0 additions & 19 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 20d45af

Please sign in to comment.