From 5210c7844e90e2c2d4da9412296b7c0b23db1a6b Mon Sep 17 00:00:00 2001 From: Paul Snively Date: Wed, 10 Apr 2024 14:21:32 -0400 Subject: [PATCH 1/8] Started migrating to for cross-compilation in the Docker build, for multi-arch images. --- Dockerfile | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7bb3d8efb..835e7c6f0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,17 @@ -FROM ghcr.io/goccy/go-zetasql:latest +FROM --platform=$BUILDPLATFORM tonistiigi/xx AS xx + +FROM --platform=$BUILDPLATFORM ghcr.io/goccy/go-zetasql:latest + +RUN apt-get update && apt-get upgrade -y + +COPY --from=xx / / + +ARG TARGETPLATFORM + +# There's a slightly weird combo of stuff that needs to be installed for the $BUILDPLATFORM +# and for the cross-toolchain, at least for this CGO-enabled target. +RUN apt-get install -y gcc-multilib g++-multilib +RUN xx-apt install -y musl-dev gcc libstdc++-12-dev ARG VERSION @@ -9,11 +22,15 @@ COPY . ./ RUN go mod edit -replace github.com/goccy/go-zetasql=../go-zetasql RUN go mod download -RUN make emulator/build +# Replace `RUN make emulator/build` with a bog-standard xx-go invocation, so it manages +# compiler, linker, options, everything. +ENV CGO_ENABLED=1 +RUN xx-go build -o bigquery-emulator \ + ./cmd/bigquery-emulator && xx-verify bigquery-emulator FROM debian:bullseye AS emulator -COPY --from=0 /work/bigquery-emulator /bin/bigquery-emulator +COPY --from=1 /work/bigquery-emulator /bin/bigquery-emulator WORKDIR /work From ff55d515e75801991fdcf4270e089b4cc69b37ee Mon Sep 17 00:00:00 2001 From: Paul Snively Date: Wed, 10 Apr 2024 14:51:01 -0400 Subject: [PATCH 2/8] First cut of multi-arch build. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 193cda505..dac3c0cea 100644 --- a/Makefile +++ b/Makefile @@ -11,4 +11,4 @@ emulator/build: ./cmd/bigquery-emulator docker/build: - docker build -t bigquery-emulator . --build-arg VERSION=${VERSION} + docker buildx build --push --platform linux/arm64/v8,linux/amd64 -t bigquery-emulator . --build-arg VERSION=${VERSION} From 27f6221c4bc9e4eb592d56111275e04e17e4ac1e Mon Sep 17 00:00:00 2001 From: Paul Snively Date: Wed, 10 Apr 2024 15:28:05 -0400 Subject: [PATCH 3/8] Don't try to --push the built image. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index dac3c0cea..e442a8955 100644 --- a/Makefile +++ b/Makefile @@ -11,4 +11,4 @@ emulator/build: ./cmd/bigquery-emulator docker/build: - docker buildx build --push --platform linux/arm64/v8,linux/amd64 -t bigquery-emulator . --build-arg VERSION=${VERSION} + docker buildx build --platform linux/arm64/v8,linux/amd64 -t bigquery-emulator . --build-arg VERSION=${VERSION} From 994696ccac17a2f75ea2b433ca5e622077904bbe Mon Sep 17 00:00:00 2001 From: Paul Snively Date: Mon, 22 Apr 2024 09:06:42 -0400 Subject: [PATCH 4/8] Change GitHub Registry to point to mine. --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index be4eb8a71..2a19e257a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,7 @@ jobs: - uses: docker/metadata-action@v3 id: meta with: - images: ${{ env.REGISTRY }}/goccy/bigquery-emulator + images: ${{ env.REGISTRY }}/paul-snively/bigquery-emulator tags: | type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} From b48944f74381e00e8e6fb7d3a9362756666d3102 Mon Sep 17 00:00:00 2001 From: Paul Snively Date: Mon, 22 Apr 2024 09:11:51 -0400 Subject: [PATCH 5/8] Allow manual workflow running. --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2a19e257a..98955fe15 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,6 +3,7 @@ on: push: tags: - v* + workflow_dispatch: env: REGISTRY: ghcr.io From ceec3da38be861162e957a42cb4f4dc1a59249e4 Mon Sep 17 00:00:00 2001 From: Paul Snively Date: Wed, 1 May 2024 09:33:15 -0400 Subject: [PATCH 6/8] Updating Action dependencies to Node 20 versions. --- .github/workflows/build.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 98955fe15..570c6fff5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,7 +15,7 @@ jobs: packages: write steps: - uses: actions/checkout@v4 - - uses: docker/metadata-action@v3 + - uses: docker/metadata-action@v5 id: meta with: images: ${{ env.REGISTRY }}/paul-snively/bigquery-emulator @@ -23,9 +23,9 @@ jobs: type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} - name: setup docker buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: cache for linux - uses: actions/cache@v3 + uses: actions/cache@v4 if: runner.os == 'Linux' with: path: | @@ -34,12 +34,12 @@ jobs: key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-go- - - uses: docker/login-action@v2 + - uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - uses: docker/build-push-action@v3 + - uses: docker/build-push-action@v5 with: context: . push: true From 0e4f455aa8eb4d409582730c925c91b09128144b Mon Sep 17 00:00:00 2001 From: Paul Snively Date: Wed, 1 May 2024 10:30:31 -0400 Subject: [PATCH 7/8] Added platforms entry to build-push-action. --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 570c6fff5..b8095e859 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,6 +42,7 @@ jobs: - uses: docker/build-push-action@v5 with: context: . + platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} From 325ca53d5740fa942d9416bcef181bd2fd9924b0 Mon Sep 17 00:00:00 2001 From: Paul Snively Date: Wed, 1 May 2024 12:18:15 -0400 Subject: [PATCH 8/8] Upgraded Debian distro to bookworm to match library versions with xx. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 835e7c6f0..f367aa4f9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,7 +28,7 @@ ENV CGO_ENABLED=1 RUN xx-go build -o bigquery-emulator \ ./cmd/bigquery-emulator && xx-verify bigquery-emulator -FROM debian:bullseye AS emulator +FROM debian:bookworm AS emulator COPY --from=1 /work/bigquery-emulator /bin/bigquery-emulator