From 15d4c5ffbeed5f9668e53980be06e196b70da706 Mon Sep 17 00:00:00 2001 From: clabby Date: Sun, 26 Jan 2025 12:54:25 -0500 Subject: [PATCH] chore(ci): Improve docker releases (#952) Co-authored-by: refcell --- .github/workflows/cross_docker.yaml | 40 ----- .github/workflows/docker.yaml | 157 ++++++++++++++++++ .github/workflows/issue_cycler.yaml | 20 --- .github/workflows/kona_fpp_docker.yaml | 54 ------ README.md | 5 - build/README.md | 33 ---- build/justfile | 15 -- docker/README.md | 74 +++++++++ docker/apps/kona_host.dockerfile | 33 ++++ .../asterisc/asterisc.dockerfile | 2 +- {build => docker}/cannon/cannon.dockerfile | 2 +- .../cannon/mips64-unknown-none.json | 0 docker/docker-bake.hcl | 71 ++++++++ docker/fpvm-prestates/README.md | 12 ++ .../fpvm-prestates}/asterisc-repro.dockerfile | 59 ++----- docker/fpvm-prestates/justfile | 27 +++ justfile | 31 ---- 17 files changed, 386 insertions(+), 249 deletions(-) delete mode 100644 .github/workflows/cross_docker.yaml create mode 100644 .github/workflows/docker.yaml delete mode 100644 .github/workflows/issue_cycler.yaml delete mode 100644 .github/workflows/kona_fpp_docker.yaml delete mode 100644 build/README.md delete mode 100644 build/justfile create mode 100644 docker/README.md create mode 100644 docker/apps/kona_host.dockerfile rename {build => docker}/asterisc/asterisc.dockerfile (96%) rename {build => docker}/cannon/cannon.dockerfile (96%) rename {build => docker}/cannon/mips64-unknown-none.json (100%) create mode 100644 docker/docker-bake.hcl create mode 100644 docker/fpvm-prestates/README.md rename {build/asterisc => docker/fpvm-prestates}/asterisc-repro.dockerfile (66%) create mode 100644 docker/fpvm-prestates/justfile diff --git a/.github/workflows/cross_docker.yaml b/.github/workflows/cross_docker.yaml deleted file mode 100644 index 59c56f062..000000000 --- a/.github/workflows/cross_docker.yaml +++ /dev/null @@ -1,40 +0,0 @@ -name: Build and Publish Cross Images - -on: [workflow_dispatch, workflow_call] - -env: - REGISTRY: ghcr.io - -jobs: - build-pipelines: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - strategy: - matrix: - target: ["cannon", "asterisc"] - env: - IMAGE_NAME: ${{ github.repository }}/${{ matrix.target }}-builder - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Authenticate with container registry - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Docker metadata - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - name: Build and Publish `${{ matrix.target }}-pipeline` - uses: docker/build-push-action@v6 - with: - file: build/${{ matrix.target }}/${{ matrix.target }}.dockerfile - context: build/${{ matrix.target }} - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml new file mode 100644 index 000000000..a4f027267 --- /dev/null +++ b/.github/workflows/docker.yaml @@ -0,0 +1,157 @@ +name: Build and Publish Docker Image + +on: + workflow_dispatch: + inputs: + target: + type: choice + description: Which image to release + required: true + options: + - kona-host + - asterisc-builder + - cannon-builder + - kona-asterisc-prestate + push: + tags: + # matches tags like `service/v1.0.0` + - '*/v*' + +env: + REGISTRY: ghcr.io + REGISTRY_IMAGE: ghcr.io/op-rs/kona + GIT_REF_NAME: ${{ github.ref_name }} + +jobs: + prepare: + 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 ${{ 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 }}/${{ steps.target-spec.outputs.target }} + tags: | + type=ref,event=branch + type=match,pattern=v(.*),group=1,event=tag + type=ref,event=pr + - name: Rename meta bake definition file + run: | + mv "${{ steps.meta.outputs.bake-file }}" "${{ runner.temp }}/bake-meta.json" + - name: Upload meta bake definition + uses: actions/upload-artifact@v4 + with: + name: bake-meta + path: ${{ runner.temp }}/bake-meta.json + if-no-files-found: error + retention-days: 1 + + build: + name: Build Image (${{ needs.prepare.outputs.target }} - ${{ matrix.platform }}) + runs-on: ${{ matrix.platform == 'linux/amd64' && 'ubuntu-latest' || 'ubuntu-22.04-arm' }} + needs: + - prepare + strategy: + fail-fast: false + matrix: + platform: ${{ fromJson(needs.prepare.outputs.matrix) }} + steps: + - name: Prepare + run: | + platform=${{ matrix.platform }} + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV + - name: Download meta bake definition + uses: actions/download-artifact@v4 + with: + name: bake-meta + path: ${{ runner.temp }} + - name: Authenticate with container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build + id: bake + uses: docker/bake-action@v6 + with: + files: | + ./docker/docker-bake.hcl + cwd://${{ runner.temp }}/bake-meta.json + targets: ${{ needs.prepare.outputs.target }} + set: | + *.tags= + *.platform=${{ matrix.platform }} + *.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 + 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 + with: + name: digests-${{ env.PLATFORM_PAIR }} + path: ${{ runner.temp }}/digests/* + if-no-files-found: error + retention-days: 1 + + merge: + name: Publish Manifest (${{ needs.prepare.outputs.target }}) + runs-on: ubuntu-latest + needs: + - build + - prepare + steps: + - name: Download meta bake definition + uses: actions/download-artifact@v4 + with: + name: bake-meta + path: ${{ runner.temp }} + - name: Download digests + uses: actions/download-artifact@v4 + with: + path: ${{ runner.temp }}/digests + pattern: digests-* + merge-multiple: true + - name: Authenticate with container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - 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 }}/${{ 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 }}/${{ needs.prepare.outputs.target }}:$(jq -r '.target."docker-metadata-action".args.DOCKER_META_VERSION' ${{ runner.temp }}/bake-meta.json) + diff --git a/.github/workflows/issue_cycler.yaml b/.github/workflows/issue_cycler.yaml deleted file mode 100644 index a321c5cc0..000000000 --- a/.github/workflows/issue_cycler.yaml +++ /dev/null @@ -1,20 +0,0 @@ -on: - schedule: - # Runs "at 05:00, only on Monday" (see https://crontab.guru) - - cron: "0 5 * * 1" - -jobs: - move-to-next-iteration: - name: Move to next iteration - runs-on: ubuntu-latest - - steps: - - uses: blombard/move-to-next-iteration@master - with: - owner: ethereum-optimism - number: 60 - token: ${{ secrets.GITHUB_TOKEN }} - iteration-field: Cycle - iteration: last - new-iteration: current - excluded-statuses: "Done" diff --git a/.github/workflows/kona_fpp_docker.yaml b/.github/workflows/kona_fpp_docker.yaml deleted file mode 100644 index df160e554..000000000 --- a/.github/workflows/kona_fpp_docker.yaml +++ /dev/null @@ -1,54 +0,0 @@ -name: Build and Publish Kona FPP Images - -on: - workflow_dispatch: - inputs: - asterisc_tag: - description: Tag for `asterisc` to build the prestate artifacts - required: true - type: string - -env: - REGISTRY: ghcr.io - -jobs: - build-fpp-images: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - strategy: - matrix: - fpvm: ["asterisc"] - env: - IMAGE_NAME: ${{ github.repository }}/kona-fpp-${{ matrix.fpvm }} - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Authenticate with container registry - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Docker metadata - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - name: Build and Publish `kona-fpp-${{ matrix.fpvm }}` - uses: docker/build-push-action@v6 - with: - file: build/${{ matrix.fpvm }}/${{ matrix.fpvm }}-repro.dockerfile - context: . - push: true - platforms: linux/amd64,linux/arm64 - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - build-args: | - CLIENT_TAG=${{ github.ref_name }} - ASTERISC_TAG=${{ inputs.asterisc_tag }} diff --git a/README.md b/README.md index b484c28fd..d7a7adfdb 100644 --- a/README.md +++ b/README.md @@ -50,11 +50,6 @@ see the [SDK section of the book](https://op-rs.github.io/kona/sdk/intro.html). - [`client`](./bin/client): The bare-metal program that runs on top of a [fault proof VM][g-fault-proof-vm]. - [`host`](./bin/host): The host program that runs natively alongside the FPVM, serving as the [Preimage Oracle][g-preimage-oracle] server. -**Build Pipelines** - -- [`cannon`](./build/cannon): Docker image for compiling to the bare-metal `mips64-unknown-none` target. -- [`asterisc`](./build/asterisc): Docker image for compiling to the bare-metal `riscv64imac-unknown-none-elf` target. - **Protocol** - [`mpt`](./crates/mpt): Utilities for interacting with the Merkle Patricia Trie in the client program. - [`executor`](./crates/executor): `no_std` stateless block executor for the [OP Stack][op-stack]. diff --git a/build/README.md b/build/README.md deleted file mode 100644 index f8c50cc65..000000000 --- a/build/README.md +++ /dev/null @@ -1,33 +0,0 @@ -# `kona-build` - -This directory contains the cross-compilation docker images and custom `rustc` targets used to build verifiable programs targeting various FPVMs. - -## Usage - -### Building Images - -To build the images, run `just` in the root of this directory. - -### Compiling Programs - -**cannon** - -``` -docker run \ - --rm \ - --platform linux/amd64 \ - -v `pwd`/:/workdir \ - -w="/workdir" \ - ghcr.io/op-rs/kona/cannon-builder:main cargo build --release -Zbuild-std=core,alloc -``` - -**asterisc** - -``` -docker run \ - --rm \ - --platform linux/amd64 \ - -v `pwd`/:/workdir \ - -w="/workdir" \ - ghcr.io/op-rs/kona/asterisc-builder:main cargo build --release -Zbuild-std=core,alloc -``` diff --git a/build/justfile b/build/justfile deleted file mode 100644 index 1bf29796f..000000000 --- a/build/justfile +++ /dev/null @@ -1,15 +0,0 @@ -set fallback := true - -# default recipe to display help information -default: - @just --list - -all: cannon asterisc - -# Build the `cannon` program builder image -cannon: - docker build -t cannon-pipeline:latest -f cannon/cannon.dockerfile ./cannon - -# Build the `asterisc` program builder image -asterisc: - docker build -t asterisc-pipeline:latest -f asterisc/asterisc.dockerfile ./asterisc diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 000000000..11dcd5d26 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,74 @@ +# `docker` + +This directory contains all of the repositories' dockerfiles as well as the [bake file](https://docs.docker.com/build/bake/) +used to define this repository's docker build configuration. + +## Install Dependencies + +* `docker`: https://www.docker.com/get-started/ +* `docker-buildx`: https://github.com/docker/buildx?tab=readme-ov-file#installing + +## Building Locally + +To build any image in the bake file locally, use `docker buildx bake`: + +```sh +export TARGET="" + +# Optional: adjust the tag for the image +# Defaults to `kona:local` +export DEFAULT_TAG="my-image:local" + +# Optional: Override the platforms to build the image for. +# Defaults to `linux/amd64,linux/arm64` +export PLATFORMS="" + +# Optional: Override the git ref to use for the current repo. Must exist +# on the `op-rs/kona` remote. +# +# Used by: +# - `kona-host` +# - `kona-asterisc-prestate` +export GIT_REF_NAME="my/feature/branch" + +docker buildx bake \ + --progress plain \ + -f docker/docker-bake.hcl \ + $TARGET +``` + +#### Troubleshooting + +If you receive an error like the following: + +``` +ERROR: Multi-platform build is not supported for the docker driver. +Switch to a different driver, or turn on the containerd image store, and try again. +Learn more at https://docs.docker.com/go/build-multi-platform/ +``` + +Create and activate a new builder and retry the bake command. + +```sh +docker buildx create --name kona-builder --use +``` + +## Cutting a Release (for maintainers / forks) + +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 -m "" && git push origin tag $TAG +``` + +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 +gh workflow run "Build and Publish Docker Image" --ref -f image_to_release= +``` diff --git a/docker/apps/kona_host.dockerfile b/docker/apps/kona_host.dockerfile new file mode 100644 index 000000000..1a39c8dcf --- /dev/null +++ b/docker/apps/kona_host.dockerfile @@ -0,0 +1,33 @@ +FROM ubuntu:22.04 AS host-build +SHELL ["/bin/bash", "-c"] + +ARG CLIENT_TAG + +# Install deps +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential \ + git \ + curl \ + ca-certificates \ + libssl-dev \ + clang \ + pkg-config + +# Install rust +ENV RUST_VERSION=1.81.0 +RUN curl https://sh.rustup.rs -sSf | bash -s -- -y --default-toolchain ${RUST_VERSION} --component rust-src +ENV PATH="/root/.cargo/bin:${PATH}" + +# Clone kona at the specified tag +RUN git clone https://github.com/op-rs/kona + +# Build kona-host on the selected tag +RUN cd kona && \ + git checkout $CLIENT_TAG && \ + cargo build --workspace --bin kona-host --release && \ + mv ./target/release/kona-host /kona-host + +FROM ubuntu:22.04 AS export-stage + +# Copy the kona-host binary +COPY --from=host-build /kona-host . diff --git a/build/asterisc/asterisc.dockerfile b/docker/asterisc/asterisc.dockerfile similarity index 96% rename from build/asterisc/asterisc.dockerfile rename to docker/asterisc/asterisc.dockerfile index 249975835..2abe5412c 100644 --- a/build/asterisc/asterisc.dockerfile +++ b/docker/asterisc/asterisc.dockerfile @@ -1,4 +1,4 @@ -FROM --platform=linux/amd64 ubuntu:22.04 +FROM ubuntu:22.04 ENV SHELL=/bin/bash ENV DEBIAN_FRONTEND noninteractive diff --git a/build/cannon/cannon.dockerfile b/docker/cannon/cannon.dockerfile similarity index 96% rename from build/cannon/cannon.dockerfile rename to docker/cannon/cannon.dockerfile index b504a8206..1ee23f211 100644 --- a/build/cannon/cannon.dockerfile +++ b/docker/cannon/cannon.dockerfile @@ -1,4 +1,4 @@ -FROM --platform=linux/amd64 ubuntu:22.04 +FROM ubuntu:22.04 ENV SHELL=/bin/bash ENV DEBIAN_FRONTEND=noninteractive diff --git a/build/cannon/mips64-unknown-none.json b/docker/cannon/mips64-unknown-none.json similarity index 100% rename from build/cannon/mips64-unknown-none.json rename to docker/cannon/mips64-unknown-none.json diff --git a/docker/docker-bake.hcl b/docker/docker-bake.hcl new file mode 100644 index 000000000..b40078f55 --- /dev/null +++ b/docker/docker-bake.hcl @@ -0,0 +1,71 @@ +variable "REGISTRY" { + default = "ghcr.io" +} + +variable "REPOSITORY" { + default = "op-rs/kona" +} + +variable "DEFAULT_TAG" { + default = "kona:local" +} + +variable "PLATFORMS" { + // Only specify a single platform when `--load` ing into docker. + // Multi-platform is supported when outputting to disk or pushing to a registry. + // Multi-platform builds can be tested locally with: --set="*.output=type=image,push=false" + default = "linux/amd64,linux/arm64" +} + +variable "GIT_REF_NAME" { + default = "main" +} + +variable "ASTERISC_TAG" { + // The tag of `asterisc` to use in the `kona-asterisc-prestate` target. + // + // You can override this if you'd like to use a different tag to generate the prestate. + // https://github.com/ethereum-optimism/asterisc/releases + default = "v1.2.0" +} + +// Special target: https://github.com/docker/metadata-action#bake-definition +target "docker-metadata-action" { + tags = ["${DEFAULT_TAG}"] +} + +target "kona-host" { + inherits = ["docker-metadata-action"] + context = "." + dockerfile = "docker/apps/kona_host.dockerfile" + args = { + CLIENT_TAG = "${GIT_REF_NAME}" + } + platforms = split(",", PLATFORMS) +} + +target "asterisc-builder" { + inherits = ["docker-metadata-action"] + context = "docker/asterisc" + dockerfile = "asterisc.dockerfile" + platforms = split(",", PLATFORMS) +} + +target "cannon-builder" { + inherits = ["docker-metadata-action"] + context = "docker/cannon" + dockerfile = "cannon.dockerfile" + platforms = split(",", PLATFORMS) +} + +target "kona-asterisc-prestate" { + inherits = ["docker-metadata-action"] + context = "." + dockerfile = "docker/fpvm-prestates/asterisc-repro.dockerfile" + args = { + CLIENT_TAG = "${GIT_REF_NAME}" + ASTERISC_TAG = "${ASTERISC_TAG}" + } + # Only build on linux/amd64 for reproducibility. + platforms = ["linux/amd64"] +} 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/build/asterisc/asterisc-repro.dockerfile b/docker/fpvm-prestates/asterisc-repro.dockerfile similarity index 66% rename from build/asterisc/asterisc-repro.dockerfile rename to docker/fpvm-prestates/asterisc-repro.dockerfile index 1dd7e52f6..16e49e47b 100644 --- a/build/asterisc/asterisc-repro.dockerfile +++ b/docker/fpvm-prestates/asterisc-repro.dockerfile @@ -5,16 +5,17 @@ FROM ubuntu:22.04 AS asterisc-build SHELL ["/bin/bash", "-c"] +ARG TARGETARCH ARG ASTERISC_TAG # Install deps RUN apt-get update && apt-get install -y --no-install-recommends git curl ca-certificates make -ENV GO_VERSION=1.21.1 +ENV GO_VERSION=1.22.7 # Fetch go manually, rather than using a Go base image, so we can copy the installation into the final stage -RUN curl -sL https://go.dev/dl/go$GO_VERSION.linux-amd64.tar.gz -o go$GO_VERSION.linux-amd64.tar.gz && \ - tar -C /usr/local/ -xzf go$GO_VERSION.linux-amd64.tar.gz +RUN curl -sL https://go.dev/dl/go$GO_VERSION.linux-$TARGETARCH.tar.gz -o go$GO_VERSION.linux-$TARGETARCH.tar.gz && \ + tar -C /usr/local/ -xzf go$GO_VERSION.linux-$TARGETARCH.tar.gz ENV GOPATH=/go ENV PATH=/usr/local/go/bin:$GOPATH/bin:$PATH @@ -34,57 +35,18 @@ SHELL ["/bin/bash", "-c"] ARG CLIENT_TAG -# Copy the Rust workspace from the host -COPY ./.git ./.git -COPY ./Cargo.toml ./Cargo.toml -COPY ./Cargo.lock ./Cargo.lock -COPY ./crates ./crates -COPY ./bin ./bin - # Install deps RUN apt-get update && apt-get install -y --no-install-recommends git +# Clone kona at the specified tag +RUN git clone https://github.com/op-rs/kona + # Build kona-client on the selected tag -RUN git checkout $CLIENT_TAG && \ +RUN cd kona && \ + git checkout $CLIENT_TAG && \ cargo build -Zbuild-std=core,alloc --workspace --bin kona --locked --profile release-client-lto --exclude kona-host && \ mv ./target/riscv64imac-unknown-none-elf/release-client-lto/kona /kona-client-elf -################################################################ -# Build kona-host @ `CLIENT_TAG` # -################################################################ - -FROM ubuntu:22.04 AS host-build -SHELL ["/bin/bash", "-c"] - -ARG CLIENT_TAG - -# Copy the Rust workspace from the host -COPY ./.git ./.git -COPY ./Cargo.toml ./Cargo.toml -COPY ./Cargo.lock ./Cargo.lock -COPY ./crates ./crates -COPY ./bin ./bin - -# Install deps -RUN apt-get update && apt-get install -y --no-install-recommends \ - build-essential \ - git \ - curl \ - ca-certificates \ - libssl-dev \ - clang \ - pkg-config - -# Install rust -ENV RUST_VERSION=1.81.0 -RUN curl https://sh.rustup.rs -sSf | bash -s -- -y --default-toolchain ${RUST_VERSION} --component rust-src -ENV PATH="/root/.cargo/bin:${PATH}" - -# Build kona-host on the selected tag -RUN git checkout $CLIENT_TAG && \ - cargo build --workspace --bin kona-host --release && \ - mv ./target/release/kona-host /kona-host - ################################################################ # Create `prestate.bin.gz` + `prestate-proof.json` # ################################################################ @@ -123,10 +85,9 @@ RUN $ASTERISC_BIN_PATH run \ # Export Artifacts # ################################################################ -FROM ubuntu:22.04 AS export-stage +FROM scratch AS export-stage COPY --from=prestate-build /asterisc . COPY --from=prestate-build /kona-client-elf . COPY --from=prestate-build /prestate.bin.gz . COPY --from=prestate-build /prestate-proof.json . -COPY --from=host-build /kona-host . 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 bdafb5d08..a2715d12b 100644 --- a/justfile +++ b/justfile @@ -116,37 +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}} - - echo "Building kona-client prestate artifacts for the asterisc target. 🐚 Kona Tag: {{kona_tag}} | 🎇 Asterisc Tag: {{asterisc_tag}}" - docker build \ - -f $PATH_TO_REPRO_BUILDER \ - --output $OUTPUT_DIR \ - --build-arg CLIENT_TAG={{kona_tag}} \ - --build-arg ASTERISC_TAG={{asterisc_tag}} \ - --platform linux/amd64 \ - . - -# Build the `kona-client` prestate artifacts for the latest release, with an image containing the resulting -# binaries. -build-client-prestate-asterisc-image kona_tag asterisc_tag out='./prestate-artifacts-asterisc': - #!/bin/bash - PATH_TO_REPRO_BUILDER=./build/asterisc/asterisc-repro.dockerfile - OUTPUT_DIR={{out}} - - echo "Building kona-client prestate artifacts for the asterisc target. 🐚 Kona Tag: {{kona_tag}} | 🎇 Asterisc Tag: {{asterisc_tag}}" - docker build \ - -f $PATH_TO_REPRO_BUILDER \ - -t kona-fpp-asterisc:latest \ - --build-arg CLIENT_TAG={{kona_tag}} \ - --build-arg ASTERISC_TAG={{asterisc_tag}} \ - --platform linux/amd64 \ - . - # 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