Skip to content

Commit

Permalink
chore(taiko-client): try cross-compile taiko-client to speed up docke…
Browse files Browse the repository at this point in the history
…r building (#18171)

Co-authored-by: RogerLamTd <bob.rogerbob1@gmail.com>
  • Loading branch information
mask-pp and RogerLamTd authored Sep 25, 2024
1 parent 5023226 commit 9dbad24
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/taiko-client--docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v3

- name: Docker meta
id: meta
Expand All @@ -46,11 +46,11 @@ jobs:
type=sha
- name: Build and push
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
context: .
file: packages/taiko-client/Dockerfile
platforms: linux/amd64,linux/arm64
platforms: linux/arm64,linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
14 changes: 10 additions & 4 deletions packages/taiko-client/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
FROM golang:1.21-alpine as builder
FROM --platform=$BUILDPLATFORM golang:1.21 AS builder
ARG TARGETOS
ARG TARGETARCH

RUN apk update && apk add --no-cache --update gcc musl-dev linux-headers git make build-base
RUN apt-get update && apt-get install -y git make g++-x86-64-linux-gnu libc6-dev-amd64-cross

WORKDIR /build

Expand All @@ -9,8 +11,12 @@ COPY go.mod go.sum ./
COPY packages/taiko-client/ packages/taiko-client/

WORKDIR /build/packages/taiko-client

RUN make build
RUN echo "TARGETOS=${TARGETOS}, TARGETARCH=${TARGETARCH}" && \
if [ "$TARGETARCH" = "amd64" ]; then \
CGO_ENABLED=1 CC=x86_64-linux-gnu-gcc GOOS=${TARGETOS} GOARCH=${TARGETARCH} make build; \
else \
make build; \
fi

FROM alpine:latest

Expand Down

0 comments on commit 9dbad24

Please sign in to comment.