Skip to content

Commit

Permalink
Make build image actions matrix actions, and add filespace cleanup to…
Browse files Browse the repository at this point in the history
… create (#2871)
  • Loading branch information
dehaansa authored Feb 28, 2025
1 parent f7fd863 commit e034ebf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 82 deletions.
39 changes: 6 additions & 33 deletions .github/workflows/check-linux-build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ on:

jobs:
check-linux-build-image:
strategy:
matrix:
build:
- runtime: golang:1.24.0-alpine3.21
- runtime: mcr.microsoft.com/oss/go/microsoft/golang:1.24.0-bookworm
runs-on: ubuntu-22.04 # related to https://github.com/docker/setup-qemu-action/issues/198
steps:
- name: Checkout
Expand Down Expand Up @@ -37,36 +42,4 @@ jobs:
push: false
tags: grafana/alloy-build-image:latest
build-args: |
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-bookworm
GO_RUNTIME=${{ matrix.build.runtime }}
66 changes: 17 additions & 49 deletions .github/workflows/create_build_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,63 +11,30 @@ permissions:
jobs:
linux_build_image:
name: Create a Linux build image
runs-on:
labels: ubuntu-22.04 # related to https://github.com/docker/setup-qemu-action/issues/198
strategy:
matrix:
build:
- runtime: golang:1.24.0-alpine3.21
- runtime: mcr.microsoft.com/oss/go/microsoft/golang:1.24.0-bookworm
suffix: "-boringcrypto"
runs-on: ubuntu-22.04 # related to https://github.com/docker/setup-qemu-action/issues/198
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: false

- name: Get version from Git tag
env:
FULL_TAG: ${{ github.ref_name }}
id: get_image_version
run: echo "image_tag=${FULL_TAG##*/}" >> $GITHUB_OUTPUT

- name: Login to DockerHub (from vault)
uses: grafana/shared-workflows/actions/[email protected]

- 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: ubuntu-22.04 # related to https://github.com/docker/setup-qemu-action/issues/198
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: false
- 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: Get version from Git tag
env:
FULL_TAG: ${{ github.ref_name }}
id: get_image_version
run: echo "image_tag=${FULL_TAG##*/}-boringcrypto" >> $GITHUB_OUTPUT
run: echo "image_tag=${FULL_TAG##*/}${{ matrix.build.suffix }}" >> $GITHUB_OUTPUT

- name: Login to DockerHub (from vault)
uses: grafana/shared-workflows/actions/[email protected]
Expand All @@ -85,6 +52,7 @@ jobs:
with:
platforms: linux/amd64,linux/arm64
context: ./tools/build-image
push: true
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
GO_RUNTIME=${{ matrix.build.runtime }}

0 comments on commit e034ebf

Please sign in to comment.