Skip to content

Commit c67c67a

Browse files
Docker-targets v2 (ethereum-optimism#10346)
* Revert "Revert "Merge pull request ethereum-optimism#8242 from ethereum-optimism/go-docker-targets"" This reverts commit d972c46. It also fixes up some conflicts / inconsistencies, since op-conductor was added after the original revert. * ops: experimental cross-build fixes * Retrieve git tag in Circle CI and use to set op version within docker image * Update dispute-mon and da-server to use new docker build flow * Fix GIT_VERSION script in Circle CI config.yml * Update ops-bedrock docker-compose to use new docker build flow * Load pre-built op-challenger image in devnet tests * Save op-challenger.tar to avoid docker rebuild in devnet tests * Add Circle CI job for check-cross-platform * Allow env var to override VERSION in Makefiles * Pass version to op-program components except op-program-client * Wrap all docker-bake variable names in quotes --------- Co-authored-by: protolambda <[email protected]>
1 parent 29c7b44 commit c67c67a

File tree

29 files changed

+395
-295
lines changed

29 files changed

+395
-295
lines changed

.circleci/config.yml

Lines changed: 121 additions & 57 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,42 @@ golang-docker:
4141
op-node op-batcher op-proposer op-challenger op-dispute-mon
4242
.PHONY: golang-docker
4343

44+
docker-builder-clean:
45+
docker buildx rm buildx-build
46+
.PHONY: docker-builder-clean
47+
48+
docker-builder:
49+
docker buildx create \
50+
--driver=docker-container --name=buildx-build --bootstrap --use
51+
.PHONY: docker-builder
52+
53+
# add --print to dry-run
54+
cross-op-node:
55+
# We don't use a buildx builder here, and just load directly into regular docker, for convenience.
56+
GIT_COMMIT=$$(git rev-parse HEAD) \
57+
GIT_DATE=$$(git show -s --format='%ct') \
58+
IMAGE_TAGS=$$(git rev-parse HEAD),latest \
59+
PLATFORMS="linux/arm64" \
60+
GIT_VERSION=$(shell tags=$$(git tag --points-at $(GITCOMMIT) | grep '^op-node/' | sed 's/op-node\///' | sort -V); \
61+
preferred_tag=$$(echo "$$tags" | grep -v -- '-rc' | tail -n 1); \
62+
if [ -z "$$preferred_tag" ]; then \
63+
if [ -z "$$tags" ]; then \
64+
echo "untagged"; \
65+
else \
66+
echo "$$tags" | tail -n 1; \
67+
fi \
68+
else \
69+
echo $$preferred_tag; \
70+
fi) \
71+
docker buildx bake \
72+
--progress plain \
73+
--builder=buildx-build \
74+
--load \
75+
--no-cache \
76+
-f docker-bake.hcl \
77+
op-node
78+
.PHONY: golang-docker
79+
4480
chain-mon-docker:
4581
# We don't use a buildx builder here, and just load directly into regular docker, for convenience.
4682
GIT_COMMIT=$$(git rev-parse HEAD) \

cannon/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
GITCOMMIT ?= $(shell git rev-parse HEAD)
22
GITDATE ?= $(shell git show -s --format='%ct')
3-
VERSION := v0.0.0
3+
VERSION ?= v0.0.0
44

55
LDFLAGSSTRING +=-X main.GitCommit=$(GITCOMMIT)
66
LDFLAGSSTRING +=-X main.GitDate=$(GITDATE)

docker-bake.hcl

Lines changed: 110 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ variable "GIT_DATE" {
1414
default = "0"
1515
}
1616

17+
// The default version to embed in the built images.
18+
// During CI release builds this is set to <<pipeline.git.tag>>
1719
variable "GIT_VERSION" {
18-
default = "docker" // original default as set in proxyd file, not used by full go stack, yet
20+
default = "v0.0.0"
1921
}
2022

2123
variable "IMAGE_TAGS" {
@@ -27,148 +29,187 @@ variable "PLATFORMS" {
2729
// Only a specify a single platform when `--load` ing into docker.
2830
// Multi-platform is supported when outputting to disk or pushing to a registry.
2931
// Multi-platform builds can be tested locally with: --set="*.output=type=image,push=false"
30-
default = "linux/amd64"
32+
default = ""
3133
}
3234

33-
target "op-stack-go" {
35+
// Each of the services can have a customized version, but defaults to the global specified version.
36+
variable "OP_NODE_VERSION" {
37+
default = "${GIT_VERSION}"
38+
}
39+
40+
variable "OP_BATCHER_VERSION" {
41+
default = "${GIT_VERSION}"
42+
}
43+
44+
variable "OP_PROPOSER_VERSION" {
45+
default = "${GIT_VERSION}"
46+
}
47+
48+
variable "OP_CHALLENGER_VERSION" {
49+
default = "${GIT_VERSION}"
50+
}
51+
52+
variable "OP_DISPUTE_MON_VERSION" {
53+
default = "${GIT_VERSION}"
54+
}
55+
56+
variable "OP_HEARTBEAT_VERSION" {
57+
default = "${GIT_VERSION}"
58+
}
59+
60+
variable "OP_PROGRAM_VERSION" {
61+
default = "${GIT_VERSION}"
62+
}
63+
64+
variable "CANNON_VERSION" {
65+
default = "${GIT_VERSION}"
66+
}
67+
68+
variable "OP_CONDUCTOR_VERSION" {
69+
default = "${GIT_VERSION}"
70+
}
71+
72+
73+
target "op-node" {
3474
dockerfile = "ops/docker/op-stack-go/Dockerfile"
3575
context = "."
3676
args = {
3777
GIT_COMMIT = "${GIT_COMMIT}"
3878
GIT_DATE = "${GIT_DATE}"
79+
OP_NODE_VERSION = "${OP_NODE_VERSION}"
3980
}
40-
platforms = split(",", PLATFORMS)
41-
tags = [for tag in split(",", IMAGE_TAGS) : "${REGISTRY}/${REPOSITORY}/op-stack-go:${tag}"]
42-
}
43-
44-
target "op-node" {
45-
dockerfile = "Dockerfile"
46-
context = "./op-node"
47-
args = {
48-
OP_STACK_GO_BUILDER = "op-stack-go"
49-
}
50-
contexts = {
51-
op-stack-go: "target:op-stack-go"
52-
}
81+
target = "op-node-target"
5382
platforms = split(",", PLATFORMS)
5483
tags = [for tag in split(",", IMAGE_TAGS) : "${REGISTRY}/${REPOSITORY}/op-node:${tag}"]
5584
}
5685

5786
target "op-batcher" {
58-
dockerfile = "Dockerfile"
59-
context = "./op-batcher"
87+
dockerfile = "ops/docker/op-stack-go/Dockerfile"
88+
context = "."
6089
args = {
61-
OP_STACK_GO_BUILDER = "op-stack-go"
62-
}
63-
contexts = {
64-
op-stack-go: "target:op-stack-go"
90+
GIT_COMMIT = "${GIT_COMMIT}"
91+
GIT_DATE = "${GIT_DATE}"
92+
OP_BATCHER_VERSION = "${OP_BATCHER_VERSION}"
6593
}
94+
target = "op-batcher-target"
6695
platforms = split(",", PLATFORMS)
6796
tags = [for tag in split(",", IMAGE_TAGS) : "${REGISTRY}/${REPOSITORY}/op-batcher:${tag}"]
6897
}
6998

7099
target "op-proposer" {
71-
dockerfile = "Dockerfile"
72-
context = "./op-proposer"
100+
dockerfile = "ops/docker/op-stack-go/Dockerfile"
101+
context = "."
73102
args = {
74-
OP_STACK_GO_BUILDER = "op-stack-go"
75-
}
76-
contexts = {
77-
op-stack-go: "target:op-stack-go"
103+
GIT_COMMIT = "${GIT_COMMIT}"
104+
GIT_DATE = "${GIT_DATE}"
105+
OP_PROPOSER_VERSION = "${OP_PROPOSER_VERSION}"
78106
}
107+
target = "op-proposer-target"
79108
platforms = split(",", PLATFORMS)
80109
tags = [for tag in split(",", IMAGE_TAGS) : "${REGISTRY}/${REPOSITORY}/op-proposer:${tag}"]
81110
}
82111

83112
target "op-challenger" {
84-
dockerfile = "Dockerfile"
85-
context = "./op-challenger"
113+
dockerfile = "ops/docker/op-stack-go/Dockerfile"
114+
context = "."
86115
args = {
87-
OP_STACK_GO_BUILDER = "op-stack-go"
88-
}
89-
contexts = {
90-
op-stack-go: "target:op-stack-go"
116+
GIT_COMMIT = "${GIT_COMMIT}"
117+
GIT_DATE = "${GIT_DATE}"
118+
OP_CHALLENGER_VERSION = "${OP_CHALLENGER_VERSION}"
91119
}
120+
target = "op-challenger-target"
92121
platforms = split(",", PLATFORMS)
93122
tags = [for tag in split(",", IMAGE_TAGS) : "${REGISTRY}/${REPOSITORY}/op-challenger:${tag}"]
94123
}
95124

96125
target "op-dispute-mon" {
97-
dockerfile = "Dockerfile"
98-
context = "./op-dispute-mon"
126+
dockerfile = "ops/docker/op-stack-go/Dockerfile"
127+
context = "."
99128
args = {
100-
OP_STACK_GO_BUILDER = "op-stack-go"
101-
}
102-
contexts = {
103-
op-stack-go: "target:op-stack-go"
129+
GIT_COMMIT = "${GIT_COMMIT}"
130+
GIT_DATE = "${GIT_DATE}"
131+
OP_DISPUTE_MON_VERSION = "${OP_DISPUTE_MON_VERSION}"
104132
}
133+
target = "op-dispute-mon-target"
105134
platforms = split(",", PLATFORMS)
106135
tags = [for tag in split(",", IMAGE_TAGS) : "${REGISTRY}/${REPOSITORY}/op-dispute-mon:${tag}"]
107136
}
108137

109138
target "op-conductor" {
110-
dockerfile = "Dockerfile"
111-
context = "./op-conductor"
139+
dockerfile = "ops/docker/op-stack-go/Dockerfile"
140+
context = "."
112141
args = {
113-
OP_STACK_GO_BUILDER = "op-stack-go"
114-
}
115-
contexts = {
116-
op-stack-go: "target:op-stack-go"
142+
GIT_COMMIT = "${GIT_COMMIT}"
143+
GIT_DATE = "${GIT_DATE}"
144+
OP_CONDUCTOR_VERSION = "${OP_CONDUCTOR_VERSION}"
117145
}
146+
target = "op-conductor-target"
118147
platforms = split(",", PLATFORMS)
119148
tags = [for tag in split(",", IMAGE_TAGS) : "${REGISTRY}/${REPOSITORY}/op-conductor:${tag}"]
120149
}
121150

122151
target "op-heartbeat" {
123-
dockerfile = "Dockerfile"
124-
context = "./op-heartbeat"
152+
dockerfile = "ops/docker/op-stack-go/Dockerfile"
153+
context = "."
125154
args = {
126-
OP_STACK_GO_BUILDER = "op-stack-go"
127-
}
128-
contexts = {
129-
op-stack-go: "target:op-stack-go"
155+
GIT_COMMIT = "${GIT_COMMIT}"
156+
GIT_DATE = "${GIT_DATE}"
157+
OP_HEARTBEAT_VERSION = "${OP_HEARTBEAT_VERSION}"
130158
}
159+
target = "op-heartbeat-target"
131160
platforms = split(",", PLATFORMS)
132161
tags = [for tag in split(",", IMAGE_TAGS) : "${REGISTRY}/${REPOSITORY}/op-heartbeat:${tag}"]
133162
}
134163

135164
target "da-server" {
136-
dockerfile = "Dockerfile"
137-
context = "./op-plasma"
165+
dockerfile = "ops/docker/op-stack-go/Dockerfile"
166+
context = "."
138167
args = {
139-
OP_STACK_GO_BUILDER = "op-stack-go"
140-
}
141-
contexts = {
142-
op-stack-go: "target:op-stack-go"
168+
GIT_COMMIT = "${GIT_COMMIT}"
169+
GIT_DATE = "${GIT_DATE}"
143170
}
171+
target = "da-server-target"
144172
platforms = split(",", PLATFORMS)
145173
tags = [for tag in split(",", IMAGE_TAGS) : "${REGISTRY}/${REPOSITORY}/da-server:${tag}"]
146174
}
147175

148176
target "op-program" {
149-
dockerfile = "Dockerfile"
150-
context = "./op-program"
177+
dockerfile = "ops/docker/op-stack-go/Dockerfile"
178+
context = "."
151179
args = {
152-
OP_STACK_GO_BUILDER = "op-stack-go"
153-
}
154-
contexts = {
155-
op-stack-go: "target:op-stack-go"
180+
GIT_COMMIT = "${GIT_COMMIT}"
181+
GIT_DATE = "${GIT_DATE}"
182+
OP_PROGRAM_VERSION = "${OP_PROGRAM_VERSION}"
156183
}
184+
target = "op-program-target"
157185
platforms = split(",", PLATFORMS)
158186
tags = [for tag in split(",", IMAGE_TAGS) : "${REGISTRY}/${REPOSITORY}/op-program:${tag}"]
159187
}
160188

161189
target "op-ufm" {
162190
dockerfile = "./op-ufm/Dockerfile"
163-
context = "./"
164-
args = {
191+
context = "./"
192+
args = {
165193
// op-ufm dockerfile has no _ in the args
166-
GITCOMMIT = "${GIT_COMMIT}"
167-
GITDATE = "${GIT_DATE}"
194+
GITCOMMIT = "${GIT_COMMIT}"
195+
GITDATE = "${GIT_DATE}"
168196
GITVERSION = "${GIT_VERSION}"
169197
}
170198
platforms = split(",", PLATFORMS)
171-
tags = [for tag in split(",", IMAGE_TAGS) : "${REGISTRY}/${REPOSITORY}/op-ufm:${tag}"]
199+
tags = [for tag in split(",", IMAGE_TAGS) : "${REGISTRY}/${REPOSITORY}/op-ufm:${tag}"]
200+
}
201+
202+
target "cannon" {
203+
dockerfile = "ops/docker/op-stack-go/Dockerfile"
204+
context = "."
205+
args = {
206+
GIT_COMMIT = "${GIT_COMMIT}"
207+
GIT_DATE = "${GIT_DATE}"
208+
CANNON_VERSION = "${CANNON_VERSION}"
209+
}
210+
target = "cannon-target"
211+
platforms = split(",", PLATFORMS)
212+
tags = [for tag in split(",", IMAGE_TAGS) : "${REGISTRY}/${REPOSITORY}/cannon:${tag}"]
172213
}
173214

174215
target "proxyd" {

op-batcher/Dockerfile

Lines changed: 0 additions & 9 deletions
This file was deleted.

op-batcher/Dockerfile.dockerignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

op-bootnode/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
GITCOMMIT ?= $(shell git rev-parse HEAD)
22
GITDATE ?= $(shell git show -s --format='%ct')
3-
VERSION := v0.0.0
3+
VERSION ?= v0.0.0
44

55
LDFLAGSSTRING +=-X main.GitCommit=$(GITCOMMIT)
66
LDFLAGSSTRING +=-X main.GitDate=$(GITDATE)

op-challenger/Dockerfile

Lines changed: 0 additions & 17 deletions
This file was deleted.

op-challenger/Dockerfile.dockerignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

op-challenger/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
GITCOMMIT ?= $(shell git rev-parse HEAD)
22
GITDATE ?= $(shell git show -s --format='%ct')
3-
VERSION := v0.0.0
3+
VERSION ?= v0.0.0
44

55
LDFLAGSSTRING +=-X main.GitCommit=$(GITCOMMIT)
66
LDFLAGSSTRING +=-X main.GitDate=$(GITDATE)

0 commit comments

Comments
 (0)