Skip to content

Commit 55ac50f

Browse files
authored
feat: add GitHub Actions workflow for publishing Build Tools Docker image (#477)
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
1 parent 45475c9 commit 55ac50f

3 files changed

Lines changed: 149 additions & 19 deletions

File tree

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Publish Build Tools Docker Image
16+
17+
on:
18+
workflow_dispatch:
19+
inputs:
20+
ubuntu_version:
21+
description: 'Ubuntu version for base image'
22+
required: true
23+
bazel_version:
24+
description: 'Bazel version to build'
25+
required: true
26+
platforms:
27+
description: 'Target platforms (comma-separated)'
28+
required: false
29+
default: 'linux/s390x'
30+
draft:
31+
description: 'Draft mode (true: build only, false: build and push)'
32+
type: boolean
33+
required: false
34+
default: true
35+
36+
jobs:
37+
publish:
38+
runs-on: ubuntu-24.04-16core
39+
permissions:
40+
contents: read
41+
packages: write
42+
43+
steps:
44+
- uses: actions/checkout@v2
45+
46+
- name: Generate tag
47+
id: tag
48+
run: |
49+
TAG="ubuntu-${{ github.event.inputs.ubuntu_version }}-bazel-${{ github.event.inputs.bazel_version }}"
50+
echo "tag=$TAG" >> $GITHUB_OUTPUT
51+
52+
- name: Login to GitHub Container Registry
53+
if: ${{ !github.event.inputs.draft }}
54+
uses: docker/login-action@v3
55+
with:
56+
registry: ghcr.io
57+
username: ${{ github.actor }}
58+
password: ${{ secrets.GITHUB_TOKEN }}
59+
60+
- name: Set up QEMU
61+
uses: docker/setup-qemu-action@v3
62+
63+
- name: Set up Docker Buildx
64+
uses: docker/setup-buildx-action@v3
65+
66+
- name: Build and Push Docker Image
67+
uses: docker/build-push-action@v6
68+
with:
69+
context: .
70+
file: bazel/external/Dockerfile.bazel
71+
platforms: ${{ github.event.inputs.platforms }}
72+
tags: ghcr.io/proxy-wasm/build-tools:${{ steps.tag.outputs.tag }}
73+
build-args: |
74+
UBUNTU_VERSION=${{ github.event.inputs.ubuntu_version }}
75+
BAZEL_VERSION=${{ github.event.inputs.bazel_version }}
76+
push: ${{ !github.event.inputs.draft }}
77+
load: ${{ github.event.inputs.draft }}
78+
cache-from: type=gha,scope=build-tools-${{ steps.tag.outputs.tag }}
79+
cache-to: type=gha,mode=max,scope=build-tools-${{ steps.tag.outputs.tag }}

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ jobs:
277277

278278
- name: Activate Docker/QEMU
279279
if: startsWith(matrix.run_under, 'docker')
280-
run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
280+
uses: docker/setup-qemu-action@v3
281281

282282
- name: Set up Docker Buildx
283283
if: startsWith(matrix.run_under, 'docker')

bazel/external/Dockerfile.bazel

Lines changed: 69 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,75 @@
1414
# limitations under the License.
1515

1616

17-
# Prep:
18-
# docker run --rm --privileged tonistiigi/binfmt --install all
19-
# docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
20-
# Need to see "F" flag: cat /proc/sys/fs/binfmt_misc/qemu-*
21-
#
22-
# Build:
23-
# docker buildx build --platform linux/s390x -t $IMAGE -f Dockerfile.bazel
24-
#
25-
# Push:
26-
# docker image tag $IMAGE ghcr.io/proxy-wasm/$IMAGE
27-
# docker push ghcr.io/proxy-wasm/$IMAGE
28-
#
29-
# Test:
30-
# docker run --rm --volume $(pwd):/mnt --workdir /mnt \
31-
# --platform linux/s390x $IMAGE \
32-
# bazel test --verbose_failures --test_output=errors \
33-
# --define engine=null --config=clang --test_timeout=1800 \
34-
# -- //test/...
17+
# ============================================================================
18+
# BUILD TOOLS DOCKER IMAGE WORKFLOWS
19+
# ============================================================================
20+
#
21+
# This Dockerfile creates build tools images for cross-platform testing,
22+
# particularly for s390x architecture. Images are published to GitHub
23+
# Container Registry (ghcr.io/proxy-wasm/build-tools).
24+
#
25+
# ----------------------------------------------------------------------------
26+
# RECOMMENDED: Automated Workflow (via GitHub Actions)
27+
# ----------------------------------------------------------------------------
28+
#
29+
# The preferred method for publishing build tools images is through the
30+
# automated GitHub Actions workflow defined in:
31+
# .github/workflows/publish-build-tools.yml
32+
#
33+
# This workflow can be triggered manually via the GitHub UI:
34+
# 1. Go to Actions tab in the repository
35+
# 2. Select "Publish Build Tools Docker Image"
36+
# 3. Click "Run workflow"
37+
# 4. Provide the required inputs:
38+
# - ubuntu_version: Base Ubuntu version (e.g., 22.04, 24.04)
39+
# - bazel_version: Bazel version to build (e.g., 6.5.0, 7.0.0)
40+
# - platforms: Target platforms (default: linux/s390x)
41+
# - draft: Set to 'false' to build and push, 'true' for build-only testing
42+
#
43+
# The workflow handles QEMU setup, multi-platform builds, caching, and
44+
# authentication automatically. Images are tagged as:
45+
# ghcr.io/proxy-wasm/build-tools:ubuntu-{VERSION}-bazel-{VERSION}
46+
#
47+
# This automated approach is recommended because it:
48+
# - Ensures consistent build environments
49+
# - Handles authentication and permissions automatically
50+
# - Provides build caching for faster iterations
51+
# - Supports draft mode for testing before publishing
52+
#
53+
# ----------------------------------------------------------------------------
54+
# ALTERNATIVE: Manual Build and Push
55+
# ----------------------------------------------------------------------------
56+
#
57+
# For local development or when automated workflows are unavailable,
58+
# you can manually build and push images using the following steps:
59+
#
60+
# 1. Prep (enable cross-platform emulation):
61+
# docker run --rm --privileged tonistiigi/binfmt --install all
62+
# docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
63+
# # Verify "F" flag: cat /proc/sys/fs/binfmt_misc/qemu-*
64+
#
65+
# 2. Build:
66+
# docker buildx build --platform linux/s390x \
67+
# --build-arg UBUNTU_VERSION=22.04 \
68+
# --build-arg BAZEL_VERSION=6.5.0 \
69+
# -t build-tools:local \
70+
# -f bazel/external/Dockerfile.bazel .
71+
#
72+
# 3. Push (requires appropriate permissions):
73+
# docker image tag build-tools:local \
74+
# ghcr.io/proxy-wasm/build-tools:ubuntu-22.04-bazel-6.5.0
75+
# docker push ghcr.io/proxy-wasm/build-tools:ubuntu-22.04-bazel-6.5.0
76+
#
77+
# 4. Test:
78+
# docker run --rm --volume $(pwd):/mnt --workdir /mnt \
79+
# --platform linux/s390x \
80+
# ghcr.io/proxy-wasm/build-tools:ubuntu-22.04-bazel-6.5.0 \
81+
# bazel test --verbose_failures --test_output=errors \
82+
# --define engine=null --config=clang --test_timeout=1800 \
83+
# -- //test/...
84+
#
85+
# ============================================================================
3586

3687
ARG BAZEL_VERSION=7.7.1
3788
ARG UBUNTU_VERSION=24.04

0 commit comments

Comments
 (0)