Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build a multi-arch Docker image. Intended to close #215 #298

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
tags:
- v*
workflow_dispatch:
env:
REGISTRY: ghcr.io

Expand All @@ -14,17 +15,17 @@ jobs:
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/metadata-action@v3
- uses: docker/metadata-action@v5
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}}
- 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: |
Expand All @@ -33,14 +34,15 @@ 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: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand Down
25 changes: 21 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
FROM debian:bookworm AS emulator

COPY --from=0 /work/bigquery-emulator /bin/bigquery-emulator
COPY --from=1 /work/bigquery-emulator /bin/bigquery-emulator

WORKDIR /work

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ emulator/build:
./cmd/bigquery-emulator

docker/build:
docker build -t bigquery-emulator . --build-arg VERSION=${VERSION}
docker buildx build --platform linux/arm64/v8,linux/amd64 -t bigquery-emulator . --build-arg VERSION=${VERSION}