Skip to content

Commit

Permalink
Pin qemu image to fix github actions build-image builds (#2839)
Browse files Browse the repository at this point in the history
* Add multi image to check-linux-build-image action

* trigger action on change of action

* run each go install separately to debug

* Set max parallelism for buildx

* pin version of binfmt:qemu

* Clean up and update create_build_image

* Test action on arm image

* Revert from arm builder, pin to qemu action 3.4.0

* set env for check build image action

* Revert ineffective changes

* revert change to sigs.k8s.io/controller-tools

* Run each go install separately for debugging purposes

* try using older ubuntu runner

* Try ubuntu 22.04 without qemu7

* Try a different qemu build

* update golang image and qemu back to v7

* try without the boringcrypto build

* Try using alpine golang image

* Add boringcrypto build back in

* Standardize between check and create build image actions

* parallelize linux build image checks
  • Loading branch information
dehaansa authored Feb 28, 2025
1 parent cacba8a commit f7fd863
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 15 deletions.
35 changes: 31 additions & 4 deletions .github/workflows/check-linux-build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ on:
pull_request:
paths:
- 'tools/build-image/*'
- '.github/workflows/check-linux-build-image.yml'

jobs:
check-linux-build-image:
runs-on: github-hosted-ubuntu-x64-large
runs-on: ubuntu-22.04 # related to https://github.com/docker/setup-qemu-action/issues/198
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -21,25 +22,51 @@ jobs:
rm -rf /opt/hostedtoolcache
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
uses: docker/[email protected]
with:
image: tonistiigi/binfmt:qemu-v7.0.0-28 # https://github.com/docker/setup-qemu-action/issues/198

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

- name: Create test Linux build image
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
context: ./tools/build-image
push: false
tags: grafana/alloy-build-image:latest
build-args: |
GO_RUNTIME=golang:1.24.0-bullseye
GO_RUNTIME=golang:1.24.0-alpine3.21
check-linux-boringcrypto-build-image:
runs-on: ubuntu-22.04 # related to https://github.com/docker/setup-qemu-action/issues/198
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Remove unnecessary files
run: |
rm -rf /usr/share/dotnet
rm -rf "$AGENT_TOOLSDIRECTORY"
rm -rf /opt/ghc
rm -rf "/usr/local/share/boost"
rm -rf /opt/hostedtoolcache
- name: Setup QEMU
uses: docker/[email protected]
with:
image: tonistiigi/binfmt:qemu-v7.0.0-28 # https://github.com/docker/setup-qemu-action/issues/198

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

- name: Create test Linux build image for boring crypto
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
context: ./tools/build-image
push: false
tags: grafana/alloy-build-image:latest
build-args: |
GO_RUNTIME=mcr.microsoft.com/oss/go/microsoft/golang:1.24.0-bullseye
GO_RUNTIME=mcr.microsoft.com/oss/go/microsoft/golang:1.24.0-bookworm
44 changes: 34 additions & 10 deletions .github/workflows/create_build_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
linux_build_image:
name: Create a Linux build image
runs-on:
labels: github-hosted-ubuntu-x64-large
labels: ubuntu-22.04 # related to https://github.com/docker/setup-qemu-action/issues/198
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -32,15 +32,27 @@ jobs:
- name: Login to DockerHub (from vault)
uses: grafana/shared-workflows/actions/[email protected]

- run: |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker buildx create --name multiarch --driver docker-container --use
docker buildx build --build-arg="GO_RUNTIME=golang:1.24.0-bullseye" --push --platform linux/amd64,linux/arm64 -t grafana/alloy-build-image:${{ steps.get_image_version.outputs.image_tag }} ./tools/build-image
- name: Setup QEMU
uses: docker/[email protected]
with:
image: tonistiigi/binfmt:qemu-v7.0.0-28 # https://github.com/docker/setup-qemu-action/issues/198

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

- name: Create Linux build image
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
context: ./tools/build-image
tags: grafana/alloy-build-image:${{ steps.get_image_version.outputs.image_tag }}
build-args: |
GO_RUNTIME=golang:1.24.0-alpine3.21
linux_build_image_boringcrypto:
name: Create a Linux build image for boringcrypto
runs-on:
labels: github-hosted-ubuntu-x64-large
labels: ubuntu-22.04 # related to https://github.com/docker/setup-qemu-action/issues/198
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -60,7 +72,19 @@ jobs:
- name: Login to DockerHub (from vault)
uses: grafana/shared-workflows/actions/[email protected]

- run: |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker buildx create --name multiarch --driver docker-container --use
docker buildx build --build-arg="GO_RUNTIME=mcr.microsoft.com/oss/go/microsoft/golang:1.24.0-bullseye" --push --platform linux/amd64,linux/arm64 -t grafana/alloy-build-image:${{ steps.get_image_version.outputs.image_tag }} ./tools/build-image
- name: Setup QEMU
uses: docker/[email protected]
with:
image: tonistiigi/binfmt:qemu-v7.0.0-28 # https://github.com/docker/setup-qemu-action/issues/198

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

- name: Create Linux build image
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
context: ./tools/build-image
tags: grafana/alloy-build-image:${{ steps.get_image_version.outputs.image_tag }}
build-args: |
GO_RUNTIME=mcr.microsoft.com/oss/go/microsoft/golang:1.24.0-bullseye
2 changes: 1 addition & 1 deletion tools/build-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ RUN wget -nv https://nsis.sourceforge.io/mediawiki/images/4/4a/AccessControl.zip
# Dependency: Go and Go dependencies
FROM ${GO_RUNTIME} as golang

ENV CONTROLLER_GEN_VERSION v0.17.2
ENV CONTROLLER_GEN_VERSION v0.9.2

RUN go install sigs.k8s.io/controller-tools/cmd/controller-gen@$CONTROLLER_GEN_VERSION \
&& go install github.com/mitchellh/[email protected] \
Expand Down

0 comments on commit f7fd863

Please sign in to comment.