Support multi-platform Docker image build

Enable multi-platform (amd64/arm64) Docker image building using
docker buildx. This allows building and pushing images for both
x86_64 and ARM64 architectures simultaneously.

Changes:
- Update Makefile to use docker buildx for multi-platform builds
- Add PLATFORMS and PUSH variables to control build behavior
- Update build documentation in README files (en/zh/ko)
- Fix deprecated ENV format in Dockerfile

By default, PLATFORMS is set to "linux/amd64,linux/arm64" and
PUSH is false. When PUSH=true, the build command will push the
multi-arch manifest directly to the registry.

Change-Id: I51a256e7cf8c70f3ab42cf72b6f423989dd902da
Signed-off-by: Wu Wenxiang <wu.wenxiang@algoblu.com>
This commit is contained in:
Wu Wenxiang
2025-10-09 13:32:06 +08:00
parent dde20cbb20
commit 711902f3d3
5 changed files with 59 additions and 11 deletions

View File

@@ -29,7 +29,11 @@ help:
@echo "Target:"
@echo " git_config Initialize git configuration."
@echo " clean Clean up."
@echo " build Build docker image."
@echo " build Build docker image for multiple platforms (default: linux/amd64,linux/arm64)."
@echo " Options:"
@echo " PLATFORMS=linux/amd64,linux/arm64 - Set target platforms"
@echo " PUSH=true - Push multi-arch image to registry"
@echo " PUSH=false (default) - Load single-arch image to local docker"
@echo " db_revision Generate database alembic version revision with model."
@echo " db_sync Sync database from alembic version revision."
@echo " future_check Find python files without 'type annotations'.(Alpha)"
@@ -84,27 +88,47 @@ BUILD_CONTEXT ?= .
DOCKER_FILE ?= container/Dockerfile
IMAGE ?= skyline
IMAGE_TAG ?= latest
PLATFORMS ?= linux/amd64,linux/arm64
PUSH ?= false
ifeq ($(BUILD_ENGINE), docker)
build_cmd = docker build
build_cmd = docker buildx build
else ifeq ($(BUILD_ENGINE), buildah)
build_cmd = buildah bud
else
$(error Unsupported build engine $(BUILD_ENGINE))
endif
build: skyline_console/skyline_console.tar.gz skyline_console/commit_id
$(build_cmd) --no-cache --pull --force-rm \
ifeq ($(PUSH), true)
$(build_cmd) --no-cache --pull --platform $(PLATFORMS) \
--build-arg GIT_CONSOLE_COMMIT=$(shell cat skyline_console/commit_id) \
--build-arg GIT_BRANCH=$(GIT_BRANCH) \
--build-arg GIT_COMMIT=$(GIT_COMMIT) \
--build-arg RELEASE_VERSION=$(RELEASE_VERSION) \
$(BUILD_ARGS) -f $(DOCKER_FILE) -t $(IMAGE):$(IMAGE_TAG) $(BUILD_CONTEXT)
$(BUILD_ARGS) -f $(DOCKER_FILE) -t $(IMAGE):$(IMAGE_TAG) --push $(BUILD_CONTEXT)
else
$(build_cmd) --no-cache --pull --platform $(PLATFORMS) \
--build-arg GIT_CONSOLE_COMMIT=$(shell cat skyline_console/commit_id) \
--build-arg GIT_BRANCH=$(GIT_BRANCH) \
--build-arg GIT_COMMIT=$(GIT_COMMIT) \
--build-arg RELEASE_VERSION=$(RELEASE_VERSION) \
$(BUILD_ARGS) -f $(DOCKER_FILE) -t $(IMAGE):$(IMAGE_TAG) --load $(BUILD_CONTEXT)
endif
devbuild: skyline_console/skyline_console.tar.gz skyline_console/commit_id
$(build_cmd) \
ifeq ($(PUSH), true)
$(build_cmd) --platform $(PLATFORMS) \
--build-arg GIT_CONSOLE_COMMIT=$(shell cat skyline_console/commit_id) \
--build-arg GIT_BRANCH=devbuild \
--build-arg GIT_COMMIT=devbuild \
--build-arg RELEASE_VERSION=devbuild \
$(BUILD_ARGS) -f $(DOCKER_FILE) -t $(IMAGE):$(IMAGE_TAG) $(BUILD_CONTEXT)
$(BUILD_ARGS) -f $(DOCKER_FILE) -t $(IMAGE):$(IMAGE_TAG) --push $(BUILD_CONTEXT)
else
$(build_cmd) --platform $(PLATFORMS) \
--build-arg GIT_CONSOLE_COMMIT=$(shell cat skyline_console/commit_id) \
--build-arg GIT_BRANCH=devbuild \
--build-arg GIT_COMMIT=devbuild \
--build-arg RELEASE_VERSION=devbuild \
$(BUILD_ARGS) -f $(DOCKER_FILE) -t $(IMAGE):$(IMAGE_TAG) --load $(BUILD_CONTEXT)
endif
.PHONY: db_revision

View File

@@ -221,7 +221,15 @@ Install & Run
.. code:: bash
make build
# Ubuntu 22.04 / 24.04 install docker-buildx
# apt install docker-buildx
# docker buildx create --name mybuilder --driver docker-container --use --bootstrap
# Local build (current platform only)
make build PLATFORMS=linux/amd64
# Multi-platform build and push
make build PLATFORMS=linux/amd64,linux/arm64 IMAGE=yourrepo/skyline IMAGE_TAG=latest PUSH=true
DevStack Integration
--------------------

View File

@@ -212,7 +212,15 @@ Skyline-apiserver 개발
.. code:: bash
make build
# Ubuntu 22.04 / 24.04 install docker-buildx
# apt install docker-buildx
# docker buildx create --name mybuilder --driver docker-container --use --bootstrap
# 로컬 빌드 (현재 플랫폼)
make build PLATFORMS=linux/amd64
# 멀티 플랫폼 빌드 및 푸시
make build PLATFORMS=linux/amd64,linux/arm64 IMAGE=yourrepo/skyline IMAGE_TAG=latest PUSH=true
Devstack 통합
--------------------

View File

@@ -287,7 +287,15 @@ python 3.8 及以上版本
.. code:: bash
make build
# Ubuntu 22.04 / 24.04 install docker-buildx
# apt install docker-buildx
# docker buildx create --name mybuilder --driver docker-container --use --bootstrap
# 本地构建(仅当前平台)
make build PLATFORMS=linux/amd64
# 多平台构建并推送
make build PLATFORMS=linux/amd64,linux/arm64 IMAGE=yourrepo/skyline IMAGE_TAG=latest PUSH=true
Devstack 集成
-------------

View File

@@ -11,8 +11,8 @@ LABEL skyline.build_branch=${GIT_BRANCH}
LABEL skyline.build_commit=${GIT_COMMIT}
LABEL skyline.release_version=${RELEASE_VERSION}
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
ENV LANG=C.UTF-8
ENV LC_ALL=C.UTF-8
RUN apt update -y && apt install -y --no-install-recommends apt-utils \
&& DEBIAN_FRONTEND=noninteractive apt install -y \