Skip to content

Commit

Permalink
fix(ci): support building arm64 architecture (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
welkin22 authored Sep 10, 2024
1 parent 1a3fb74 commit b924d7b
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
provenance: false

push-op-batcher:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -75,6 +77,8 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
provenance: false

push-op-proposer:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -108,6 +112,8 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
provenance: false

push-op-bootnode:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -141,3 +147,5 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
provenance: false
6 changes: 6 additions & 0 deletions op-batcher/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ ifeq ($(shell uname),Darwin)
endif

op-batcher:
ifeq ($(TARGETARCH),arm64)
wget https://musl.cc/aarch64-linux-musl-cross.tgz
tar zxf aarch64-linux-musl-cross.tgz
export PATH=$$PATH:/app/op-batcher/aarch64-linux-musl-cross/bin/ && env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) CC=aarch64-linux-musl-gcc CGO_ENABLED=1 go build -v $(LDFLAGS) -o ./bin/op-batcher ./cmd
else
env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) go build -v $(LDFLAGS) -o ./bin/op-batcher ./cmd
endif

clean:
rm bin/op-batcher
Expand Down
6 changes: 6 additions & 0 deletions op-bootnode/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ LDFLAGSSTRING +=-X main.Version=$(VERSION)
LDFLAGS := -ldflags "$(LDFLAGSSTRING)"

op-bootnode:
ifeq ($(TARGETARCH),arm64)
wget https://musl.cc/aarch64-linux-musl-cross.tgz
tar zxf aarch64-linux-musl-cross.tgz
export PATH=$$PATH:/app/op-bootnode/aarch64-linux-musl-cross/bin/ && env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) CC=aarch64-linux-musl-gcc CGO_ENABLED=1 go build -v $(LDFLAGS) -o ./bin/op-bootnode ./cmd
else
env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) go build -v $(LDFLAGS) -o ./bin/op-bootnode ./cmd
endif

clean:
rm -f bin/op-bootnode
Expand Down
6 changes: 3 additions & 3 deletions op-node/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM --platform=$BUILDPLATFORM golang:1.21.5-alpine3.18 as builder

ARG VERSION=v0.0.0

RUN apk add --no-cache build-base libc-dev
RUN apk add --no-cache build-base libc-dev wget
RUN apk add --no-cache make gcc musl-dev linux-headers git jq bash

# build op-node with the shared go.mod & go.sum files
Expand All @@ -17,10 +17,10 @@ COPY ./go.sum /app/go.sum
COPY ./.git /app/.git

WORKDIR /app/op-node

RUN go mod download

ARG TARGETOS TARGETARCH
ARG TARGETOS
ARG TARGETARCH

ENV CGO_CFLAGS="-O -D__BLST_PORTABLE__"
ENV CGO_CFLAGS_ALLOW="-O -D__BLST_PORTABLE__"
Expand Down
6 changes: 6 additions & 0 deletions op-node/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ ifeq ($(shell uname),Darwin)
endif

op-node:
ifeq ($(TARGETARCH),arm64)
wget https://musl.cc/aarch64-linux-musl-cross.tgz
tar zxf aarch64-linux-musl-cross.tgz
export PATH=$$PATH:/app/op-node/aarch64-linux-musl-cross/bin/ && env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) CC=aarch64-linux-musl-gcc CGO_ENABLED=1 go build -v $(LDFLAGS) -o ./bin/op-node ./cmd/main.go
else
env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) go build -v $(LDFLAGS) -o ./bin/op-node ./cmd/main.go
endif

clean:
rm bin/op-node
Expand Down
6 changes: 6 additions & 0 deletions op-proposer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ LDFLAGSSTRING +=-X main.Version=$(VERSION)
LDFLAGS := -ldflags "$(LDFLAGSSTRING)"

op-proposer:
ifeq ($(TARGETARCH),arm64)
wget https://musl.cc/aarch64-linux-musl-cross.tgz
tar zxf aarch64-linux-musl-cross.tgz
export PATH=$$PATH:/app/op-proposer/aarch64-linux-musl-cross/bin/ && env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) CC=aarch64-linux-musl-gcc CGO_ENABLED=1 go build -v $(LDFLAGS) -o ./bin/op-proposer ./cmd
else
env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) go build -v $(LDFLAGS) -o ./bin/op-proposer ./cmd
endif

clean:
rm bin/op-proposer
Expand Down

0 comments on commit b924d7b

Please sign in to comment.