diff --git a/.github/workflows/docker-images.yml b/.github/workflows/docker-images.yml new file mode 100644 index 0000000000000..3d010c48127e6 --- /dev/null +++ b/.github/workflows/docker-images.yml @@ -0,0 +1,139 @@ +name: Build and Push Docker Images + +on: + push: + branches: [main, celo*] + paths: + - 'espresso/docker/**' + - 'espresso/docker-compose.yml' + - 'config/**' + pull_request: + paths: + - 'espresso/docker/**' + - 'espresso/docker-compose.yml' + - 'config/**' + workflow_dispatch: + +env: + REGISTRY: ghcr.io + IMAGE_PREFIX: ghcr.io/${{ github.repository }} + +jobs: + build-l1-geth: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.IMAGE_PREFIX }}/l1-geth + tags: | + type=ref,event=branch + type=ref,event=pr + type=sha,prefix={{branch}}-,enable={{is_default_branch}} + type=raw,value=latest,enable={{is_default_branch}} + type=raw,value=pr-${{ github.event.number }},enable=${{ github.event_name == 'pull_request' }} + + - name: Build and push L1 Geth + uses: docker/build-push-action@v5 + with: + context: espresso/docker/l1-geth + file: espresso/docker/l1-geth/Dockerfile + platforms: linux/amd64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + build-op-geth: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.IMAGE_PREFIX }}/op-geth + tags: | + type=ref,event=branch + type=ref,event=pr + type=sha,prefix={{branch}}-,enable={{is_default_branch}} + type=raw,value=latest,enable={{is_default_branch}} + type=raw,value=pr-${{ github.event.number }},enable=${{ github.event_name == 'pull_request' }} + + - name: Build and push OP Geth + uses: docker/build-push-action@v5 + with: + context: espresso/docker/op-geth + file: espresso/docker/op-geth/Dockerfile + platforms: linux/amd64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + build-op-node: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.IMAGE_PREFIX }}/op-node + tags: | + type=ref,event=branch + type=ref,event=pr + type=sha,prefix={{branch}}-,enable={{is_default_branch}} + type=raw,value=latest,enable={{is_default_branch}} + type=raw,value=pr-${{ github.event.number }},enable=${{ github.event_name == 'pull_request' }} + + - name: Build and push OP Node + uses: docker/build-push-action@v5 + with: + context: . + file: espresso/docker/op-stack/Dockerfile + target: op-node-target + platforms: linux/amd64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + TARGET_BASE_IMAGE=ubuntu:22.04 + TARGETOS=linux + TARGETARCH=amd64 diff --git a/.gitignore b/.gitignore index b08cc2028d20d..456927c212e93 100644 --- a/.gitignore +++ b/.gitignore @@ -62,9 +62,5 @@ gha-creds-*.json # Ignore generated credentials from google-github-actions/auth gha-creds-*.json -# Ignore the JWT secret for devnet. -config/jwt.txt - - # Ignore keys *.pem diff --git a/espresso/.env b/espresso/.env index 5c68331577409..1e013b5ee95f8 100644 --- a/espresso/.env +++ b/espresso/.env @@ -1,7 +1,7 @@ # Environment variables for internal devnet. ESPRESSO_L1_PORT=8545 -ESPRESSO_L1_PROVIDER=http://l1:8545 +ESPRESSO_L1_PROVIDER=http://l1-geth:8545 ESPRESSO_ROLLUP_PORT=9545 ESPRESSO_ROLLUP_PROVIDER=http://op-node-sequencer:9545 diff --git a/espresso/docker-compose.yml b/espresso/docker-compose.yml index 515e0c61c3292..894d6f51cc8c3 100644 --- a/espresso/docker-compose.yml +++ b/espresso/docker-compose.yml @@ -1,80 +1,36 @@ # Espresso OP Integration Docker Setup services: - l1: + l1-geth: healthcheck: test: ["CMD", "curl", "-f", "http://localhost:${ESPRESSO_L1_PORT}"] interval: 3s timeout: 2s retries: 40 build: - context: ../ops/docker/deployment-utils + context: ./docker/l1-geth image: l1-geth:espresso volumes: - - ../config/l1-genesis-devnet.json:/l1-genesis-devnet.json:ro - - l1-data:/data - command: - - sh - - -c - # Initialize with the L1 genesis file. - # Enable `dev` to automatically create blocks in the dev mode. - # Set `dev.period=1` to create a block every 1 second. - - | - set -e - rm -rf /data/geth || true - geth --datadir /data init /l1-genesis-devnet.json - exec geth --datadir /data \ - --http \ - --http.addr=0.0.0.0 \ - --http.api=eth,net,web3,admin \ - --http.port=${ESPRESSO_L1_PORT} \ - --http.vhosts=* \ - --http.corsdomain=* \ - --nodiscover \ - --dev \ - --dev.period=12 \ - --miner.etherbase=0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC \ - --mine \ - --allow-insecure-unlock \ - --rpc.allow-unprotected-txs + - l1-geth-data:/data + environment: + ESPRESSO_L1_PORT: ${ESPRESSO_L1_PORT} ports: - "${ESPRESSO_L1_PORT}:${ESPRESSO_L1_PORT}" # L1 RPC op-geth: - # If the version below is updated, update the version for `images/op-geth` in the Docker - # Compose section in README_ESPRESSO.md as well. - image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-geth:v1.101503.2-rc.3 + build: + context: ./docker/op-geth + image: op-geth:espresso depends_on: - l1: + l1-geth: condition: service_healthy volumes: - - ../config:/config + - ./docker/op-geth:/config - op-geth-data:/data environment: L1_RPC: ${ESPRESSO_L1_PROVIDER} - entrypoint: ["/bin/sh", "-c"] - command: - # Initialize with the L2 genesis file. - - | - if [ ! -d "/data/geth" ]; then - geth init --datadir=/data /config/l2-genesis-devnet.json - fi - exec geth \ - --datadir=/data \ - --networkid=1 \ - --http \ - --http.addr=0.0.0.0 \ - --http.port=${ESPRESSO_L1_PORT} \ - --http.api=eth,net,web3,debug,admin,txpool \ - --http.vhosts=* \ - --http.corsdomain=* \ - --authrpc.addr=0.0.0.0 \ - --authrpc.port=${ESPRESSO_GETH_PORT} \ - --authrpc.vhosts=* \ - --authrpc.jwtsecret=/config/jwt.txt \ - --rollup.disabletxpoolgossip=true \ - --rollup.halt=major \ - --nodiscover + ESPRESSO_L1_PORT: ${ESPRESSO_L1_PORT} + ESPRESSO_GETH_PORT: ${ESPRESSO_GETH_PORT} ports: - "8546:${ESPRESSO_L1_PORT}" # L2 RPC - "${ESPRESSO_GETH_PORT}:${ESPRESSO_GETH_PORT}" # Engine API @@ -82,7 +38,7 @@ services: op-node-sequencer: build: context: ../ - dockerfile: ./ops/docker/op-stack-go/Dockerfile + dockerfile: espresso/docker/op-stack/Dockerfile target: op-node-target image: op-node-sequencer:espresso depends_on: @@ -94,19 +50,19 @@ services: OP_NODE_L2_ENGINE_RPC: ${ESPRESSO_GETH_PROVIDER} OP_NODE_RPC_PORT: ${ESPRESSO_ROLLUP_PORT} volumes: - - ../config:/config + - ./docker/op-geth:/config - /etc/localtime:/etc/localtime:ro command: - op-node - --l2.jwt-secret=/config/jwt.txt - - --rollup.config=/config/op-node/rollup-devnet.json + - --rollup.config=/config/rollup-devnet.json - --sequencer.enabled=true - --rpc.addr=0.0.0.0 op-node-verifier: build: context: ../ - dockerfile: ./ops/docker/op-stack-go/Dockerfile + dockerfile: espresso/docker/op-stack/Dockerfile target: op-node-target image: op-node-verifier:espresso depends_on: @@ -117,16 +73,16 @@ services: OP_NODE_L1_ETH_RPC: ${ESPRESSO_L1_PROVIDER} OP_NODE_L2_ENGINE_RPC: ${ESPRESSO_GETH_PROVIDER} volumes: - - ../config:/config + - ./docker/op-geth:/config command: - op-node - --l2.jwt-secret=/config/jwt.txt - - --rollup.config=/config/op-node/rollup-devnet.json + - --rollup.config=/config/rollup-devnet.json caff-node: build: context: ../ - dockerfile: ./ops/docker/op-stack-go/Dockerfile + dockerfile: espresso/docker/op-stack/Dockerfile target: op-node-target image: caff-node:espresso depends_on: @@ -141,11 +97,11 @@ services: CAFF_ESPRESSO_LIGHT_CLIENT_ADDR: "0x703848f4c85f18e3acd8196c8ec91eb0b7bd0797" CAFF_HOTSHOT_URLS: ${ESPRESSO_URL} volumes: - - ../config:/config + - ./docker/op-geth:/config command: - op-node - --l2.jwt-secret=/config/jwt.txt - - --rollup.config=/config/op-node/rollup-devnet.json + - --rollup.config=/config/rollup-devnet.json - --caff.node=true - --sequencer.enabled=false - --verifier.l1-confs=0 @@ -161,12 +117,12 @@ services: op-batcher: build: context: ../ - dockerfile: ./ops/docker/op-stack-go/Dockerfile + dockerfile: espresso/docker/op-stack/Dockerfile target: op-batcher-target image: op-batcher:espresso # It is not necessary to specify all dependencies, but a good practice. depends_on: - l1: + l1-geth: condition: service_healthy op-geth: condition: service_started @@ -192,11 +148,12 @@ services: op-proposer: build: context: ../ - dockerfile: ./ops/docker/op-stack-go/Dockerfile + dockerfile: espresso/docker/op-stack/Dockerfile target: op-proposer-target image: op-proposer:espresso depends_on: - - op-node-sequencer + op-node-sequencer: + condition: service_started environment: OP_PROPOSER_L1_ETH_RPC: ${ESPRESSO_L1_PROVIDER} OP_PROPOSER_ROLLUP_RPC: ${ESPRESSO_ROLLUP_PROVIDER} @@ -221,7 +178,7 @@ services: dockerfile: ./op-deployer/Dockerfile.default image: op-deployer:espresso depends_on: - - l1 + - l1-geth volumes: - ../packages/contracts-bedrock/lib/superchain-registry/ops/testdata/monorepo:/config restart: "no" @@ -229,7 +186,7 @@ services: espresso-dev-node: image: ghcr.io/espressosystems/espresso-sequencer/espresso-dev-node:release-colorful-snake depends_on: - l1: + l1-geth: condition: service_healthy ports: - "${ESPRESSO_SEQUENCER_API_PORT}:${ESPRESSO_SEQUENCER_API_PORT}" @@ -251,6 +208,6 @@ services: ESPRESSO_BUILDER_PORT: ${ESPRESSO_BUILDER_PORT} volumes: - l1-data: + l1-geth-data: op-geth-data: espresso-data: diff --git a/espresso/docker/l1-geth/Dockerfile b/espresso/docker/l1-geth/Dockerfile new file mode 100644 index 0000000000000..95fde8d476bd6 --- /dev/null +++ b/espresso/docker/l1-geth/Dockerfile @@ -0,0 +1,58 @@ +# L1 Geth Dockerfile, simplified from ops/docker/deployment-utils/Dockerfile +FROM debian:12.7-slim + +ENV DEBIAN_FRONTEND=noninteractive + +# Install runtime dependencies +RUN apt-get update && apt-get install -y \ + curl \ + jq \ + ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +# Install Geth for the given architecture. +RUN ARCH=$(dpkg --print-architecture) && \ + echo "Detected architecture: $ARCH" && \ + case "$ARCH" in \ + "amd64") \ + GETH_URL="https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.15.11-36b2371c.tar.gz" && \ + GETH_SHA="a14a4285daedf75ea04a7a298e6caa48d566a2786c93fc5e86ec2c5998c92455" && \ + GETH_DIR="geth-linux-amd64-1.15.11-36b2371c" && \ + VERIFY_SHA="true" \ + ;; \ + "arm64") \ + GETH_URL="https://gethstore.blob.core.windows.net/builds/geth-linux-arm64-1.15.11-36b2371c.tar.gz" && \ + GETH_SHA="148ec84db2268fa846ae68f6445f0c98d33e95069e40fe8c74b43ea5eb53df7b" && \ + GETH_DIR="geth-linux-arm64-1.15.11-36b2371c" && \ + VERIFY_SHA="true" \ + ;; \ + *) \ + echo "Unsupported architecture: $ARCH" && exit 1 \ + ;; \ + esac && \ + echo "Downloading: $GETH_URL" && \ + curl -L "$GETH_URL" -o geth.tar.gz && \ + echo "$GETH_SHA geth.tar.gz" | sha256sum -c - && \ + tar -xvf geth.tar.gz && \ + mv "$GETH_DIR/geth" /usr/local/bin/geth && \ + rm -rf geth.tar.gz "$GETH_DIR" && \ + chmod +x /usr/local/bin/geth + +# Create data directory +RUN mkdir -p /data + +# Expose the RPC port +EXPOSE 8545 + +# Set working directory +WORKDIR /data + +# Include the genesis file and the initialization script. +COPY l1-genesis-devnet.json /l1-genesis-devnet.json +COPY l1-geth-init.sh /l1-geth-init.sh + +# Run the initialization script. +RUN chmod +x /l1-geth-init.sh + +# Use the initialization script as the entrypoint. +ENTRYPOINT ["/l1-geth-init.sh"] diff --git a/config/l1-genesis-devnet.json b/espresso/docker/l1-geth/l1-genesis-devnet.json similarity index 100% rename from config/l1-genesis-devnet.json rename to espresso/docker/l1-geth/l1-genesis-devnet.json diff --git a/espresso/docker/l1-geth/l1-geth-init.sh b/espresso/docker/l1-geth/l1-geth-init.sh new file mode 100644 index 0000000000000..074b4d88361d6 --- /dev/null +++ b/espresso/docker/l1-geth/l1-geth-init.sh @@ -0,0 +1,31 @@ +#!/bin/bash +set -e + +# Set the default port if not provided. +ESPRESSO_L1_PORT=${ESPRESSO_L1_PORT:-8545} + +# Initialize database if not already done. +if [ ! -f /data/geth/chaindata/CURRENT ]; then + echo "Initializing L1 Geth database..." + rm -rf /data/geth || true + geth --datadir /data init /l1-genesis-devnet.json + echo "L1 Geth initialization completed" +else + echo "L1 Geth database already initialized, skipping..." +fi + +# Start Geth with the specified configuration. +exec geth --datadir /data \ + --http \ + --http.addr=0.0.0.0 \ + --http.api=eth,net,web3,admin \ + --http.port=${ESPRESSO_L1_PORT} \ + --http.vhosts=* \ + --http.corsdomain=* \ + --nodiscover \ + --dev \ + --dev.period=12 \ + --miner.etherbase=0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC \ + --mine \ + --allow-insecure-unlock \ + --rpc.allow-unprotected-txs diff --git a/espresso/docker/op-geth/Dockerfile b/espresso/docker/op-geth/Dockerfile new file mode 100644 index 0000000000000..d3eb48b1c7c11 --- /dev/null +++ b/espresso/docker/op-geth/Dockerfile @@ -0,0 +1,17 @@ +# OP Geth Dockerfile + +FROM us-docker.pkg.dev/oplabs-tools-artifacts/images/op-geth:v1.101503.2-rc.3 + +# Add a cache-busting layer +RUN echo "Cache bust: $(date)" > /cache-bust.txt + +# Include the genesis file, the secret file, and the initialization script. +COPY l2-genesis-devnet.json /l2-genesis-devnet.json +COPY jwt.txt /config/jwt.txt +COPY op-geth-init.sh /op-geth-init.sh + +# Run the initialization script. +RUN chmod +x /op-geth-init.sh + +# Use the initialization script as the entrypoint. +ENTRYPOINT ["/op-geth-init.sh"] diff --git a/espresso/docker/op-geth/jwt.txt b/espresso/docker/op-geth/jwt.txt new file mode 100644 index 0000000000000..64a5a0ab929df --- /dev/null +++ b/espresso/docker/op-geth/jwt.txt @@ -0,0 +1 @@ +0x94262cfb7f33ec719340a6c49188113b3e9f4d7d7f5101f14a1e3ccb16a80e2f diff --git a/config/l2-genesis-devnet.json b/espresso/docker/op-geth/l2-genesis-devnet.json similarity index 100% rename from config/l2-genesis-devnet.json rename to espresso/docker/op-geth/l2-genesis-devnet.json diff --git a/espresso/docker/op-geth/op-geth-init.sh b/espresso/docker/op-geth/op-geth-init.sh new file mode 100644 index 0000000000000..a8ee70cbd9084 --- /dev/null +++ b/espresso/docker/op-geth/op-geth-init.sh @@ -0,0 +1,33 @@ +#!/bin/sh +set -e + +# Set the default ports if not provided. +ESPRESSO_L1_PORT=${ESPRESSO_L1_PORT:-8545} +ESPRESSO_GETH_PORT=${ESPRESSO_GETH_PORT:-8551} + +# Initialize database if not already done. +if [ ! -f /data/geth/chaindata/CURRENT ]; then + echo "Initializing op-geth database..." + geth init --datadir=/data --state.scheme=path /l2-genesis-devnet.json + echo "op-geth initialization completed" +else + echo "op-geth database already initialized, skipping..." +fi + +# Start op-geth with the specified configuration +exec geth \ + --datadir=/data \ + --networkid=1 \ + --http \ + --http.addr=0.0.0.0 \ + --http.port=${ESPRESSO_L1_PORT} \ + --http.api=eth,net,web3,debug,admin,txpool \ + --http.vhosts=* \ + --http.corsdomain=* \ + --authrpc.addr=0.0.0.0 \ + --authrpc.port=${ESPRESSO_GETH_PORT} \ + --authrpc.vhosts=* \ + --authrpc.jwtsecret=/config/jwt.txt \ + --rollup.disabletxpoolgossip=true \ + --rollup.halt=major \ + --nodiscover diff --git a/config/op-node/rollup-devnet.json b/espresso/docker/op-geth/rollup-devnet.json similarity index 100% rename from config/op-node/rollup-devnet.json rename to espresso/docker/op-geth/rollup-devnet.json diff --git a/espresso/docker/op-stack/Dockerfile b/espresso/docker/op-stack/Dockerfile new file mode 100644 index 0000000000000..00cb7fa3fcb35 --- /dev/null +++ b/espresso/docker/op-stack/Dockerfile @@ -0,0 +1,125 @@ +# OP Stack Dockerfile, simplified from ops/docker/op-stack-go/Dockerfile + +# Build arguments +ARG TARGET_BASE_IMAGE=ubuntu:22.04 +ARG TARGETOS +ARG TARGETARCH + +# Base builder image +FROM golang:1.22.7-alpine3.20 AS builder + +RUN apk add --no-cache curl tar gzip make gcc musl-dev linux-headers git jq bash + +# Install mise for toolchain management +RUN curl https://mise.run | MISE_INSTALL_PATH=/usr/local/bin/mise sh + +# Install yq +RUN case "$TARGETARCH" in \ + "amd64") YQ_ARCH="amd64" ;; \ + "arm64") YQ_ARCH="arm64" ;; \ + *) YQ_ARCH="amd64" ;; \ + esac && \ + wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_$YQ_ARCH -O /usr/local/bin/yq && \ + chmod +x /usr/local/bin/yq + +# Install versioned toolchain +COPY ./mise.toml . +RUN mise trust && mise install -v -y just && cp $(mise which just) /usr/local/bin/just && just --version + +# Copy and download Go dependencies +COPY ./go.mod /app/go.mod +COPY ./go.sum /app/go.sum +WORKDIR /app +RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build go mod download + +# Copy source code +COPY . /app + +# Build arguments for git metadata +ARG GIT_COMMIT +ARG GIT_DATE + +# Rust builder for Espresso crypto libraries +FROM rust:1.84.1-alpine3.20 AS rust-builder +# TODO: Check the hash of the Espresso GO library when switch to the new one. +# +ARG ESPRESSO_NETWORK_GO_VER=0.0.34 +RUN apk add perl make openssl-dev musl-dev gcc +ADD https://github.com/EspressoSystems/espresso-network-go/archive/refs/tags/v$ESPRESSO_NETWORK_GO_VER.tar.gz /source.tgz +RUN tar -oxzf /source.tgz +WORKDIR /espresso-network-go-$ESPRESSO_NETWORK_GO_VER +RUN --mount=type=cache,target=/usr/local/cargo/registry \ + --mount=type=cache,target=/usr/local/cargo/git/db \ + --mount=type=cache,target=/espresso-network-go/verification/rust/target \ + cargo build --release --locked --manifest-path ./verification/rust/Cargo.toml +RUN mkdir -p /libespresso +RUN cp ./verification/rust/target/release/libespresso_crypto_helper.a \ + /libespresso/libespresso_crypto_helper-aarch64-unknown-linux-gnu.a +RUN cp ./verification/rust/target/release/libespresso_crypto_helper.a \ + /libespresso/libespresso_crypto_helper-x86_64-unknown-linux-gnu.a + +# CGO builder for components that need Espresso crypto linking +FROM alpine:3.20 AS op-cgo-builder +# Install dependencies +RUN apk add musl-dev gcc go g++ curl tar gzip make gcc linux-headers git jq bash yq +# Install just from mise +COPY ./mise.toml . +RUN curl -L https://github.com/casey/just/releases/download/$(yq '.tools.just' mise.toml)/just-$(yq '.tools.just' mise.toml)-x86_64-unknown-linux-musl.tar.gz | \ + tar xz -C /usr/local/bin just +# Go sources +COPY ./go.mod /app/go.mod +COPY ./go.sum /app/go.sum +# Copy rust libs for dynamic linking +COPY --from=rust-builder /libespresso/* /lib +# Warm-up the cache +WORKDIR /app +RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build go mod download +COPY . /app + +# Build op-node +FROM op-cgo-builder AS op-node-builder +ARG OP_NODE_VERSION=v0.0.0 +RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build cd op-node && \ + CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH \ + go build -a -ldflags '-extldflags "-static"' \ + -o bin/op-node ./cmd/main.go + +# Build op-batcher +FROM op-cgo-builder AS op-batcher-builder +ARG OP_BATCHER_VERSION=v0.0.0 +WORKDIR /app/op-batcher +ENV GOOS=$TARGETOS GOARCH=$TARGETARCH GITCOMMIT=$GIT_COMMIT GITDATE=$GIT_DATE VERSION="$OP_BATCHER_VERSION" +RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build just op-batcher + +# Build op-proposer +FROM builder AS op-proposer-builder +ARG OP_PROPOSER_VERSION=v0.0.0 +RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build cd op-proposer && make op-proposer \ + GOOS=$TARGETOS GOARCH=$TARGETARCH GITCOMMIT=$GIT_COMMIT GITDATE=$GIT_DATE VERSION="$OP_PROPOSER_VERSION" + +# Final runtime images +FROM $TARGET_BASE_IMAGE AS op-node-target +RUN apt-get update && apt-get install -y gcc && rm -rf /var/lib/apt/lists/* +ENV AZTEC_SRS_PATH /aztec/kzg10-aztec20-srs-1048584.bin +ADD "https://github.com/EspressoSystems/ark-srs/releases/download/v0.2.0/kzg10-aztec20-srs-1048584.bin" /aztec/kzg10-aztec20-srs-1048584.bin +COPY --from=op-node-builder /app/op-node/bin/op-node /usr/local/bin/ + +# Create config directory +RUN mkdir -p /config + +# Include the secret and the rollup files. +COPY espresso/docker/op-geth/jwt.txt /config/jwt.txt +COPY espresso/docker/op-geth/rollup-devnet.json /config/rollup-devnet.json + +CMD ["op-node"] + +FROM $TARGET_BASE_IMAGE AS op-batcher-target +RUN apt-get update && apt-get install -y gcc && rm -rf /var/lib/apt/lists/* +ENV AZTEC_SRS_PATH /aztec/kzg10-aztec20-srs-1048584.bin +ADD "https://github.com/EspressoSystems/ark-srs/releases/download/v0.2.0/kzg10-aztec20-srs-1048584.bin" /aztec/kzg10-aztec20-srs-1048584.bin +COPY --from=op-batcher-builder /app/op-batcher/bin/op-batcher /usr/local/bin/ +CMD ["op-batcher"] + +FROM $TARGET_BASE_IMAGE AS op-proposer-target +COPY --from=op-proposer-builder /app/op-proposer/bin/op-proposer /usr/local/bin/ +CMD ["op-proposer"]