@@ -8,49 +8,28 @@ ARG TARGETARCH
88# Base builder image
99FROM golang:1.23.8-alpine3.20 AS builder
1010
11- RUN apk add --no-cache curl netcat-openbsd tar gzip make gcc musl-dev linux-headers git jq bash
11+ RUN apk add --no-cache \
12+ curl netcat-openbsd tar gzip make gcc g++ musl-dev \
13+ linux-headers git bash jq yq
1214
1315# Install mise for toolchain management
1416RUN curl https://mise.run | MISE_INSTALL_PATH=/usr/local/bin/mise sh
1517
16- # Install yq
18+ # Install yq and dasel
1719RUN case "$TARGETARCH" in \
18- "amd64" ) YQ_ARCH ="amd64" ;; \
19- "arm64" ) YQ_ARCH ="arm64" ;; \
20- *) YQ_ARCH ="amd64" ;; \
20+ "amd64" ) ARCH ="amd64" ;; \
21+ "arm64" ) ARCH ="arm64" ;; \
22+ *) ARCH ="amd64" ;; \
2123 esac && \
22- wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_$YQ_ARCH -O /usr/local/bin/yq && \
23- chmod +x /usr/local/bin/yq
24+ wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_$ARCH -O /usr/local/bin/yq && \
25+ chmod +x /usr/local/bin/yq && \
26+ wget https://github.com/TomWright/dasel/releases/latest/download/dasel_linux_$ARCH -O /usr/local/bin/dasel && \
27+ chmod +x /usr/local/bin/dasel
2428
2529# Install versioned toolchain
2630COPY ./mise.toml .
2731RUN mise trust && mise install -v -y just && cp $(mise which just) /usr/local/bin/just && just --version
2832
29- # Copy and download Go dependencies
30- COPY ./go.mod /app/go.mod
31- COPY ./go.sum /app/go.sum
32- WORKDIR /app
33- RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build go mod download
34-
35- # Copy source code
36- COPY . /app
37-
38- # Build arguments for git metadata
39- ARG GIT_COMMIT
40- ARG GIT_DATE
41-
42- # CGO builder for components that need Espresso crypto linking
43- FROM golang:1.23.8-alpine3.20 AS op-cgo-builder
44- # Install dependencies
45- RUN apk add musl-dev gcc g++ curl tar gzip make linux-headers git jq bash yq
46- # Install just from mise
47- COPY ./mise.toml .
48- RUN case $(uname -m) in \
49- "arm64" |"aarch64" ) JUST_ARCH="aarch64" ;; \
50- *) JUST_ARCH="x86_64" ;; \
51- esac && \
52- curl -L https://github.com/casey/just/releases/download/$(yq '.tools.just' mise.toml)/just-$(yq '.tools.just' mise.toml)-$JUST_ARCH-unknown-linux-musl.tar.gz | \
53- tar xz -C /usr/local/bin just
5433# Fetch rust libs for dynamic linking
5534ARG ESPRESSO_SDK_VER=0.3.2
5635ARG ESPRESSO_SDK_HELPER_HASH_AARCH64=ec6ce7b37edd173206ad338c84a6a771a0e9dc8b184081af7440ebfc0c531a71
@@ -61,31 +40,37 @@ ADD --checksum=sha256:${ESPRESSO_SDK_HELPER_HASH_AARCH64} \
6140ADD --checksum=sha256:${ESPRESSO_SDK_HELPER_HASH_X86_64} \
6241 https://github.com/EspressoSystems/espresso-network/releases/download/sdks/go/v${ESPRESSO_SDK_VER}/libespresso_crypto_helper-x86_64-unknown-linux-gnu.so \
6342 /lib/
64- # Go sources
43+
44+ # Copy and download Go dependencies
6545COPY ./go.mod /app/go.mod
6646COPY ./go.sum /app/go.sum
67- # Warm-up the cache
6847WORKDIR /app
6948RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build go mod download
49+
50+ # Copy source code
7051COPY . /app
7152
53+ # Build arguments for git metadata
54+ ARG GIT_COMMIT
55+ ARG GIT_DATE
56+
7257# Build op-node
73- FROM op-cgo- builder AS op-node-builder
58+ FROM builder AS op-node-builder
7459ARG OP_NODE_VERSION=v0.0.0
7560RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build cd op-node && \
7661 CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH \
7762 go build -a -ldflags '-extldflags "-static"' \
7863 -o bin/op-node ./cmd/main.go
7964
8065# Build op-batcher
81- FROM op-cgo- builder AS op-batcher-builder
66+ FROM builder AS op-batcher-builder
8267ARG OP_BATCHER_VERSION=v0.0.0
8368WORKDIR /app/op-batcher
8469ENV GOOS=$TARGETOS GOARCH=$TARGETARCH GITCOMMIT=$GIT_COMMIT GITDATE=$GIT_DATE VERSION="$OP_BATCHER_VERSION"
8570RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build just op-batcher
8671
8772# Build enclave-tools
88- FROM op-cgo- builder AS enclave-tools-builder
73+ FROM builder AS enclave-tools-builder
8974ARG ENCLAVE_TOOLS_VERSION=v0.0.0
9075WORKDIR /app/op-batcher
9176ENV GOOS=$TARGETOS GOARCH=$TARGETARCH GITCOMMIT=$GIT_COMMIT GITDATE=$GIT_DATE VERSION="$ENCLAVE_TOOLS_VERSION"
@@ -99,11 +84,11 @@ RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache
9984RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build cd op-challenger && make op-challenger \
10085 GOOS=$TARGETOS GOARCH=$TARGETARCH GITCOMMIT=$GIT_COMMIT GITDATE=$GIT_DATE VERSION="$OP_PROPOSER_VERSION"
10186
102- FROM golang:1.23-alpine AS deployment-utils-builder
103- ENV GOOS=$TARGETOS GOARCH=$TARGETARCH GITCOMMIT=$GIT_COMMIT GITDATE=$GIT_DATE
104- RUN apk add gcc lld musl-dev # For CGO
105- RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build
go install -ldflags '-linkmode external -extldflags "-static"' github.com/tomwright/dasel/v2/cmd/[email protected] 106- RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build go install -ldflags '-linkmode external -extldflags "-static"' github.com/mikefarah/yq/[email protected] 87+ # Build op-deployer
88+ FROM builder AS op-deployer-builder
89+ ARG OP_DEPLOER_VERSION=v0.0.0
90+ RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build cd op-deployer && \
91+ GOOS=$TARGETOS GOARCH=$TARGETARCH GITCOMMIT=$GIT_COMMIT GITDATE=$GIT_DATE VERSION= "$OP_DEPLOYER_VERSION" just
10792
10893
10994# Final runtime images
@@ -133,7 +118,7 @@ RUN apk add gcc docker bash jq curl wget
133118# Install enclaver for EIF creation
134119RUN curl -L https://github.com/enclaver-io/enclaver/releases/download/v0.5.0/enclaver-linux-x86_64-v0.5.0.tar.gz | tar xz --strip-components=1 -C /usr/local/bin enclaver-linux-x86_64-v0.5.0/enclaver
135120# Copy source code
136- COPY --from=op-cgo- builder /app /source
121+ COPY --from=builder /app /source
137122WORKDIR /source
138123# Copy pre-built forge-artifacts from host (faster for development)
139124COPY packages/contracts-bedrock/forge-artifacts /source/packages/contracts-bedrock/forge-artifacts
@@ -178,6 +163,9 @@ CMD ["op-challenger"]
178163
179164FROM $TARGET_BASE_IMAGE AS op-deployer-target
180165RUN apk add jq curl bash openssl
181- COPY --from=deployment-utils-builder /go/bin/dasel /usr/local/bin/
182- COPY --from=deployment-utils-builder /go/bin/yq /usr/local/bin/
166+ COPY --from=builder /usr/local/bin/dasel /usr/local/bin/
167+ COPY --from=builder /usr/local/bin/yq /usr/local/bin/
168+ COPY --from=op-deployer-builder /app/op-deployer/bin/op-deployer /usr/local/bin
169+ COPY /packages/contracts-bedrock/forge-artifacts /contracts
170+ ENV DEPLOYER_ARTIFACT_LOCATOR=/contracts
183171CMD ["op-deployer" ]
0 commit comments