Skip to content

Commit

Permalink
Fix docker cross-platform builds (#10827)
Browse files Browse the repository at this point in the history
* Disable CGO for op-node. Test cross-platform

* Install latest gcp cli version before publishing docker image

* Add oplabs-gcr context to docker-build job so it can publish

* Do not save op-node docker image tag for devnet

* Use TARGETARCH to conditionally set CC, CXX

* Remove BUILDPLATFORM

* Fix dangling && in dockerfile

* Use apk instead of apt-get

* Install correct apk cross build packages

* Remove non-existent cross-build apk package

* Use bullseye instead of alpine

* Remove hardcoded CGO_ENABLED=0

* Set CC and CXX in makefile

* Add echo to makefile

* Remove echo from makefile

* Remove check-cross-platform test

* Remove default values for CC and CXX from makefile

* Add TARGETOS and TARGETARCH to top of dockerfile

* Remove echo from dockerfile

* Use debian TARGET_BASE_IMAGE

* Add cross platform args to all relevant Makefiles

* Add temp circle ci job to publish and check-cross-platform

* Set CGO_ENABLED=0. Use alpine for TARGET_BASE_IMAGE

* Use CMD instead of ENTRYPOINT for op-supervisor-target image

* Add CC, CXX, CGO_ENABLED args to op-plasma

* Remove CC and CXX from Makefiles

* Use alpine image for builder

* scheduled-docker-publish trigger changed to hourly or manual

* Fix circle ci config

* Fix warnings in dockerfile

* Attempt cross compile without setting CGO_ENABLED=0

* Add CGO_ENABLED=0 back for make op-node
  • Loading branch information
bitwiseguy authored Jul 19, 2024
1 parent 5be9141 commit 26eac67
Show file tree
Hide file tree
Showing 13 changed files with 96 additions and 50 deletions.
58 changes: 56 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ parameters:
sdk_dispatch:
type: boolean
default: false
docker_publish_dispatch:
type: boolean
default: false

orbs:
go: circleci/go@1.8.0
Expand Down Expand Up @@ -316,7 +319,10 @@ jobs:
- run:
command: mkdir -p /tmp/docker_images
- when:
condition: "<<parameters.release>>"
condition:
or:
- "<<parameters.publish>>"
- "<<parameters.release>>"
steps:
- gcp-cli/install
- when:
Expand Down Expand Up @@ -2093,7 +2099,10 @@ workflows:

scheduled-docker-publish:
when:
equal: [ build_hourly, <<pipeline.schedule.name>> ]
or:
- equal: [ build_hourly, <<pipeline.schedule.name>> ]
# Trigger on manual triggers if explicitly requested
- equal: [ true, << pipeline.parameters.docker_publish_dispatch >> ]
jobs:
- docker-build:
name: op-node-docker-publish
Expand All @@ -2104,6 +2113,11 @@ workflows:
context:
- oplabs-gcr
- slack
- check-cross-platform:
name: op-node-cross-platform
op_component: op-node
requires:
- op-node-docker-publish
- docker-build:
name: op-batcher-docker-publish
docker_name: op-batcher
Expand All @@ -2113,6 +2127,11 @@ workflows:
context:
- oplabs-gcr
- slack
- check-cross-platform:
name: op-batcher-cross-platform
op_component: op-batcher
requires:
- op-batcher-docker-publish
- docker-build:
name: op-program-docker-publish
docker_name: op-program
Expand All @@ -2122,6 +2141,11 @@ workflows:
context:
- oplabs-gcr
- slack
- check-cross-platform:
name: op-program-cross-platform
op_component: op-program
requires:
- op-program-docker-publish
- docker-build:
name: op-proposer-docker-publish
docker_name: op-proposer
Expand All @@ -2131,6 +2155,11 @@ workflows:
context:
- oplabs-gcr
- slack
- check-cross-platform:
name: op-proposer-cross-platform
op_component: op-proposer
requires:
- op-proposer-docker-publish
- docker-build:
name: op-challenger-docker-publish
docker_name: op-challenger
Expand All @@ -2140,6 +2169,11 @@ workflows:
context:
- oplabs-gcr
- slack
- check-cross-platform:
name: op-challenger-cross-platform
op_component: op-challenger
requires:
- op-challenger-docker-publish
- docker-build:
name: op-dispute-mon-docker-publish
docker_name: op-dispute-mon
Expand All @@ -2149,6 +2183,11 @@ workflows:
context:
- oplabs-gcr
- slack
- check-cross-platform:
name: op-dispute-mon-cross-platform
op_component: op-dispute-mon
requires:
- op-dispute-mon-docker-publish
- docker-build:
name: op-conductor-docker-publish
docker_name: op-conductor
Expand All @@ -2158,6 +2197,11 @@ workflows:
context:
- oplabs-gcr
- slack
- check-cross-platform:
name: op-conductor-cross-platform
op_component: op-conductor
requires:
- op-conductor-docker-publish
- docker-build:
name: op-heartbeat-docker-publish
docker_name: op-heartbeat
Expand All @@ -2167,6 +2211,11 @@ workflows:
context:
- oplabs-gcr
- slack
- check-cross-platform:
name: op-heartbeat-cross-platform
op_component: op-heartbeat
requires:
- op-heartbeat-docker-publish
- docker-build:
name: op-supervisor-docker-publish
docker_name: op-supervisor
Expand All @@ -2176,6 +2225,11 @@ workflows:
context:
- oplabs-gcr
- slack
- check-cross-platform:
name: op-supervisor-cross-platform
op_component: op-supervisor
requires:
- op-supervisor-docker-publish
- docker-build:
name: chain-mon-docker-publish
docker_name: chain-mon
Expand Down
2 changes: 1 addition & 1 deletion docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ variable "IMAGE_TAGS" {

variable "PLATFORMS" {
// You can override this as "linux/amd64,linux/arm64".
// Only a specify a single platform when `--load` ing into docker.
// 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 = ""
Expand Down
2 changes: 1 addition & 1 deletion op-batcher/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ifeq ($(shell uname),Darwin)
endif

op-batcher:
env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) go build -v $(LDFLAGS) -o ./bin/op-batcher ./cmd
env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) CGO_ENABLED=0 go build -v $(LDFLAGS) -o ./bin/op-batcher ./cmd

clean:
rm bin/op-batcher
Expand Down
2 changes: 1 addition & 1 deletion op-challenger/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ifeq ($(shell uname),Darwin)
endif

op-challenger:
env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) go build -v $(LDFLAGS) -o ./bin/op-challenger ./cmd
env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) CGO_ENABLED=0 go build -v $(LDFLAGS) -o ./bin/op-challenger ./cmd

fuzz:
go test $(FUZZLDFLAGS) -run NOTAREALTEST -v -fuzztime 10s -fuzz FuzzKeccak ./game/keccak/matrix
Expand Down
2 changes: 1 addition & 1 deletion op-conductor/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ LDFLAGSSTRING +=-X main.Version=$(VERSION)
LDFLAGS := -ldflags "$(LDFLAGSSTRING)"

op-conductor:
env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) go build -v $(LDFLAGS) -o ./bin/op-conductor ./cmd
env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) CGO_ENABLED=0 go build -v $(LDFLAGS) -o ./bin/op-conductor ./cmd

clean:
rm bin/op-conductor
Expand Down
2 changes: 1 addition & 1 deletion op-dispute-mon/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LDFLAGSSTRING +=-X github.com/ethereum-optimism/optimism/op-dispute-mon/version.
LDFLAGS := -ldflags "$(LDFLAGSSTRING)"

op-dispute-mon:
env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) go build -v $(LDFLAGS) -o ./bin/op-dispute-mon ./cmd
env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) CGO_ENABLED=0 go build -v $(LDFLAGS) -o ./bin/op-dispute-mon ./cmd
.PHONY: op-dispute-mon

clean:
Expand Down
2 changes: 1 addition & 1 deletion op-heartbeat/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ LDFLAGSSTRING +=-X main.Version=$(VERSION)
LDFLAGS := -ldflags "$(LDFLAGSSTRING)"

op-heartbeat:
env GO111MODULE=on go build -v $(LDFLAGS) -o ./bin/op-heartbeat ./cmd
env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) CGO_ENABLED=0 go build -v $(LDFLAGS) -o ./bin/op-heartbeat ./cmd

clean:
rm bin/op-heartbeat
Expand Down
2 changes: 1 addition & 1 deletion op-node/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ifeq ($(shell uname),Darwin)
endif

op-node:
env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) go build -v $(LDFLAGS) -o ./bin/op-node ./cmd/main.go
env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) CGO_ENABLED=0 go build -v $(LDFLAGS) -o ./bin/op-node ./cmd/main.go

clean:
rm bin/op-node
Expand Down
2 changes: 1 addition & 1 deletion op-plasma/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ LDFLAGSSTRING +=-X main.Version=$(VERSION)
LDFLAGS := -ldflags "$(LDFLAGSSTRING)"

da-server:
env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) go build -v $(LDFLAGS) -o ./bin/da-server ./cmd/daserver
env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) CGO_ENABLED=0 go build -v $(LDFLAGS) -o ./bin/da-server ./cmd/daserver

clean:
rm bin/da-server
Expand Down
2 changes: 1 addition & 1 deletion op-program/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ op-program: \
op-program-client-mips

op-program-host:
env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) go build -v -ldflags "$(LDFLAGSSTRING)" -o ./bin/op-program ./host/cmd/main.go
env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) CGO_ENABLED=0 go build -v -ldflags "$(LDFLAGSSTRING)" -o ./bin/op-program ./host/cmd/main.go

op-program-client:
env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) go build -v -ldflags "$(PC_LDFLAGSSTRING)" -o ./bin/op-program-client ./client/cmd/main.go
Expand Down
2 changes: 1 addition & 1 deletion op-proposer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ LDFLAGSSTRING +=-X main.Version=$(VERSION)
LDFLAGS := -ldflags "$(LDFLAGSSTRING)"

op-proposer:
env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) go build -v $(LDFLAGS) -o ./bin/op-proposer ./cmd
env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) CGO_ENABLED=0 go build -v $(LDFLAGS) -o ./bin/op-proposer ./cmd

clean:
rm bin/op-proposer
Expand Down
3 changes: 1 addition & 2 deletions op-supervisor/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ LDFLAGSSTRING +=-X main.Version=$(VERSION)
LDFLAGSSTRING +=-X main.Meta=$(VERSION_META)
LDFLAGS := -ldflags "$(LDFLAGSSTRING)"


op-supervisor:
env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) go build -v $(LDFLAGS) -o ./bin/op-supervisor ./cmd
env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) CGO_ENABLED=0 go build -v $(LDFLAGS) -o ./bin/op-supervisor ./cmd

clean:
rm bin/op-supervisor
Expand Down
Loading

0 comments on commit 26eac67

Please sign in to comment.