Skip to content

Commit

Permalink
Add runners for each platform and xx support.
Browse files Browse the repository at this point in the history
Note platform support currently broken (tags don't exist).

Signed-off-by: Adrian Mouat <adrian@chainguard.dev>
  • Loading branch information
amouat committed Oct 25, 2024
1 parent 0af3e93 commit 44c4a51
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 6 deletions.
46 changes: 40 additions & 6 deletions .github/workflows/build-and-push-runners.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@ on:
push:

jobs:
docker:
runs-on: [ubuntu-arm-16-cores]
armbuild:
runs-on: [arm64-builder]
steps:
-
name: Set up Docker
uses: crazy-max/ghaction-setup-docker@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -32,7 +29,44 @@ jobs:
with:
platforms: linux/arm64
push: true
tags: amouat/images-bite-back:arm-runner
tags: amouat/images-bite-back:arm-runner-${GITHUB_RUN_ID}

x86build:
runs-on: [x86-builder]
steps:
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v6
with:
platforms: linux/x86_64
push: true
tags: amouat/images-bite-back:x86-runner-${GITHUB_RUN_ID}

manifest:
needs: [x86build, armbuild]
runs-on: ubuntu-latest
steps:
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Create and Push Multi-Platform Manifest
run: |
docker manifest create amouat/images-bite-back:multiplatorm-${GITHUB_RUN_ID} \
amouat/images-bite-back:x86-runner-${GITHUB_RUN_ID} \
amouat/images-bite-back:arm-runner-${GITHUB_RUN_ID}
docker manifest push amouat/images-bite-back:multiplatorm-${GITHUB_RUN_ID}
#name: Publish Docker image
#
Expand Down
22 changes: 22 additions & 0 deletions Dockerfile-cross-xx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Load cross-platform helper functions
FROM --platform=$BUILDPLATFORM tonistiigi/xx AS xx

FROM --platform=$BUILDPLATFORM cgr.dev/chainguard/go:latest-dev AS builder
COPY --from=xx / /
RUN xx-apk add --no-cache zlib-dev
ARG TARGETOS
ARG TARGETARCH
WORKDIR /work

COPY go.mod /work/
COPY cmd /work/cmd
COPY internal /work/internal

# See https://mt165.co.uk/blog/static-link-go/ for creating static binaries
#RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 go build -o hello ./cmd/server
RUN CGO_ENABLED=0 xx-go build -o hello ./cmd/server

FROM cgr.dev/chainguard/static
COPY --from=builder /work/hello /hello

ENTRYPOINT ["/hello"]

0 comments on commit 44c4a51

Please sign in to comment.