From 393133c968b2264048efb35d3f367a22b4db9ec9 Mon Sep 17 00:00:00 2001 From: Gu Jiawei Date: Thu, 29 Jan 2026 23:24:59 +0800 Subject: [PATCH 1/3] 1. support multi arch docker image. --- .github/workflows/docker-publish.yml | 4 --- release/docker-build.sh | 54 +++++++++++++++++++++------- 2 files changed, 41 insertions(+), 17 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 22087b7d8..d7375ec59 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -45,7 +45,3 @@ jobs: set -euo pipefail chmod +x release/docker-build.sh release/docker-build.sh -t "${IMAGE_REPO}:${{ inputs.version }}" "/tmp/apache-bifromq-${{ inputs.version }}.tar.gz" - - name: "Push image" - run: | - set -euo pipefail - docker push "${IMAGE_REPO}:${{ inputs.version }}" \ No newline at end of file diff --git a/release/docker-build.sh b/release/docker-build.sh index e3918dd3c..14984ff88 100755 --- a/release/docker-build.sh +++ b/release/docker-build.sh @@ -21,17 +21,21 @@ set -euo pipefail usage() { - echo "Usage: $(basename "$0") [-t tag] " >&2 + echo "Usage: $(basename "$0") [-t tag] [-P platforms] [-p] [-o output] " >&2 exit 1 } tag_override="" -target_arch="${TARGETARCH:-}" +platforms="${PLATFORMS:-linux/amd64,linux/arm64}" +push_image="${PUSH_IMAGE:-}" +output_opt="${OUTPUT_OPT:-}" -while getopts ":t:a:h" opt; do +while getopts ":t:P:o:ph" opt; do case "$opt" in t) tag_override="$OPTARG" ;; - a) target_arch="$OPTARG" ;; + P) platforms="$OPTARG" ;; + o) output_opt="$OPTARG" ;; + p) push_image="true" ;; h) usage ;; *) usage ;; esac @@ -74,17 +78,41 @@ fi context_dir="$artifact_dir" tag="${tag_override:-apache-bifromq:${version}}" -if [[ -z "$target_arch" ]]; then - machine=$(uname -m) - case "$machine" in - x86_64|amd64) target_arch="amd64" ;; - aarch64|arm64|arm64e) target_arch="arm64" ;; - *) echo "Error: unsupported machine architecture: ${machine}. Set TARGETARCH explicitly." >&2; exit 1 ;; - esac +if [[ -z "$push_image" ]]; then + if [[ "${GITHUB_ACTIONS:-}" == "true" ]]; then + push_image="true" + else + push_image="false" + fi +fi + +if [[ -n "$output_opt" && "$push_image" == "true" ]]; then + echo "Error: use either --output (-o) or --push (-p), not both." >&2 + exit 1 +fi + +platform_count=1 +if [[ "$platforms" == *","* ]]; then + platform_count=2 +fi + +if [[ "$platform_count" -gt 1 && "$push_image" != "true" && -z "$output_opt" ]]; then + echo "Error: multi-arch build requires --push (-p) or --output (-o)." >&2 + exit 1 +fi + +buildx_output_args=() +if [[ -n "$output_opt" ]]; then + buildx_output_args+=(--output "$output_opt") +elif [[ "$push_image" == "true" ]]; then + buildx_output_args+=(--push) +else + buildx_output_args+=(--load) fi -docker build -f "$dockerfile" \ +docker buildx build -f "$dockerfile" \ + --platform "$platforms" \ --build-arg BIFROMQ_VERSION="$version" \ - --build-arg TARGETARCH="$target_arch" \ -t "$tag" \ + "${buildx_output_args[@]}" \ "$context_dir" From 0fd98a33a603fb1de280aad23fb29fdaa897ae33 Mon Sep 17 00:00:00 2001 From: Gu Jiawei Date: Sat, 31 Jan 2026 20:43:05 +0800 Subject: [PATCH 2/3] 1. change workflow to support muti-arch images. --- .github/workflows/docker-publish.yml | 18 +++++++-- release/docker-build.sh | 58 +++++++--------------------- 2 files changed, 30 insertions(+), 46 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index d7375ec59..93c9e11c7 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -40,8 +40,20 @@ jobs: curl -fSL "${ARTIFACT_URL}.sha512" -o /tmp/apache-bifromq-${{ inputs.version }}.tar.gz.sha512 cd /tmp sha512sum --check "apache-bifromq-${{ inputs.version }}.tar.gz.sha512" - - name: "Build image" + - name: "Build and push multi-arch image" run: | set -euo pipefail - chmod +x release/docker-build.sh - release/docker-build.sh -t "${IMAGE_REPO}:${{ inputs.version }}" "/tmp/apache-bifromq-${{ inputs.version }}.tar.gz" + ctx_dir="/tmp/bifromq-docker-build-context" + rm -rf "$ctx_dir" + mkdir -p "$ctx_dir" + + cp Dockerfile "$ctx_dir/Dockerfile" + cp "/tmp/apache-bifromq-${{ inputs.version }}.tar.gz" "$ctx_dir/" + cp "/tmp/apache-bifromq-${{ inputs.version }}.tar.gz.sha512" "$ctx_dir/" + + docker buildx build \ + --platform linux/amd64,linux/arm64 \ + --build-arg BIFROMQ_VERSION="${{ inputs.version }}" \ + -t "${IMAGE_REPO}:${{ inputs.version }}" \ + --push \ + "$ctx_dir" diff --git a/release/docker-build.sh b/release/docker-build.sh index 14984ff88..b3b52d386 100755 --- a/release/docker-build.sh +++ b/release/docker-build.sh @@ -7,9 +7,9 @@ # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -21,21 +21,17 @@ set -euo pipefail usage() { - echo "Usage: $(basename "$0") [-t tag] [-P platforms] [-p] [-o output] " >&2 + echo "Usage: $(basename "$0") [-t tag] " >&2 exit 1 } tag_override="" -platforms="${PLATFORMS:-linux/amd64,linux/arm64}" -push_image="${PUSH_IMAGE:-}" -output_opt="${OUTPUT_OPT:-}" +target_arch="${TARGETARCH:-}" -while getopts ":t:P:o:ph" opt; do +while getopts ":t:a:h" opt; do case "$opt" in t) tag_override="$OPTARG" ;; - P) platforms="$OPTARG" ;; - o) output_opt="$OPTARG" ;; - p) push_image="true" ;; + a) target_arch="$OPTARG" ;; h) usage ;; *) usage ;; esac @@ -78,41 +74,17 @@ fi context_dir="$artifact_dir" tag="${tag_override:-apache-bifromq:${version}}" -if [[ -z "$push_image" ]]; then - if [[ "${GITHUB_ACTIONS:-}" == "true" ]]; then - push_image="true" - else - push_image="false" - fi -fi - -if [[ -n "$output_opt" && "$push_image" == "true" ]]; then - echo "Error: use either --output (-o) or --push (-p), not both." >&2 - exit 1 -fi - -platform_count=1 -if [[ "$platforms" == *","* ]]; then - platform_count=2 -fi - -if [[ "$platform_count" -gt 1 && "$push_image" != "true" && -z "$output_opt" ]]; then - echo "Error: multi-arch build requires --push (-p) or --output (-o)." >&2 - exit 1 -fi - -buildx_output_args=() -if [[ -n "$output_opt" ]]; then - buildx_output_args+=(--output "$output_opt") -elif [[ "$push_image" == "true" ]]; then - buildx_output_args+=(--push) -else - buildx_output_args+=(--load) +if [[ -z "$target_arch" ]]; then + machine=$(uname -m) + case "$machine" in + x86_64|amd64) target_arch="amd64" ;; + aarch64|arm64|arm64e) target_arch="arm64" ;; + *) echo "Error: unsupported machine architecture: ${machine}. Set TARGETARCH explicitly." >&2; exit 1 ;; + esac fi -docker buildx build -f "$dockerfile" \ - --platform "$platforms" \ +docker build -f "$dockerfile" \ --build-arg BIFROMQ_VERSION="$version" \ + --build-arg TARGETARCH="$target_arch" \ -t "$tag" \ - "${buildx_output_args[@]}" \ "$context_dir" From cb51d0b8ab58a3e227f0ad9d779299ce80be1218 Mon Sep 17 00:00:00 2001 From: Gu Jiawei Date: Sat, 31 Jan 2026 20:56:23 +0800 Subject: [PATCH 3/3] 1. change step fonts. --- .github/workflows/docker-publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 93c9e11c7..8aa642584 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -29,7 +29,7 @@ jobs: with: username: ${{ secrets.DOCKERHUB_USER }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: "Download and verify artifact" + - name: "Download and Verify Artifact" run: | set -euo pipefail ARTIFACT_URL="${{ inputs.artifact_url }}" @@ -40,7 +40,7 @@ jobs: curl -fSL "${ARTIFACT_URL}.sha512" -o /tmp/apache-bifromq-${{ inputs.version }}.tar.gz.sha512 cd /tmp sha512sum --check "apache-bifromq-${{ inputs.version }}.tar.gz.sha512" - - name: "Build and push multi-arch image" + - name: "Build and Push Multi-Arch Image" run: | set -euo pipefail ctx_dir="/tmp/bifromq-docker-build-context"