Repository navigation
Expand file tree
/
Copy pathDockerfile-opstack
More file actions
62 lines (55 loc) · 2.54 KB
/
Copy pathDockerfile-opstack
File metadata and controls
62 lines (55 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Single stage build with Go
#
ARG GO_VERSION=1.26.4
FROM golang:${GO_VERSION}
# Belt and braces: the image above already ships the toolchain go.mod asks for,
# but this lets a go.mod bump build without editing GO_VERSION first.
ENV GOTOOLCHAIN=auto
# jq, yq and zip are needed by op-core/superchain/sync-superchain.sh; git and the
# C toolchain come with the base image. Note that docker is deliberately NOT
# installed: only cannon's `cannon-stf-verify` recipe uses it, and none of the
# targets built below reach that recipe.
RUN apt-get update \
&& apt-get install -y --no-install-recommends wget zip jq \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# just and yq are installed as pinned prebuilt release binaries, since neither is
# packaged consistently across Debian releases. JUST_VERSION tracks mise.toml.
# Running each tool once at the end turns a bad URL or an unhandled architecture
# into a loud failure here rather than a confusing "not found" further down.
ARG JUST_VERSION=1.46.0
ARG YQ_VERSION=4.44.3
RUN set -eux; \
arch="$(dpkg --print-architecture)"; \
case "$arch" in \
amd64) just_target='x86_64-unknown-linux-musl' ;; \
arm64) just_target='aarch64-unknown-linux-musl' ;; \
*) echo "unsupported architecture: $arch" >&2; exit 1 ;; \
esac; \
wget -qO /tmp/just.tar.gz \
"https://github.com/casey/just/releases/download/${JUST_VERSION}/just-${JUST_VERSION}-${just_target}.tar.gz"; \
tar -xzf /tmp/just.tar.gz -C /usr/local/bin just; \
rm /tmp/just.tar.gz; \
wget -qO /usr/local/bin/yq \
"https://github.com/mikefarah/yq/releases/download/v${YQ_VERSION}/yq_linux_${arch}"; \
chmod +x /usr/local/bin/yq; \
just --version; \
yq --version
WORKDIR /app
# Cache go dependencies first
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
go mod download
# Copy source code
COPY . .
# op-node embeds op-core/superchain/superchain-configs.zip via //go:embed. The zip is
# gitignored, so build it from the superchain-registry data.
RUN bash op-core/superchain/sync-superchain.sh
# Build Go binaries using just (upstream migrated from Make to Just)
RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
JUST_UNSTABLE=1 just ./op-node/op-node \
&& JUST_UNSTABLE=1 just op-batcher op-proposer op-challenger op-dispute-mon cannon \
&& JUST_UNSTABLE=1 just ./op-conductor/op-conductor