feat(ci): 支持 docker buildx 多架构构建 (linux/amd64,linux/arm64)
This commit is contained in:
1 parent
7f234aec2f
commit
fa1c9dc796
1 file changed
+17
-7
@@ -27,21 +27,31 @@ jobs:
|
||||
which docker || echo "docker CLI not found!"
|
||||
docker version || echo "docker daemon not accessible!"
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to Gitea Container Registry
|
||||
run: |
|
||||
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login git.openlocalpdf.com -u "${{ gitea.actor }}" --password-stdin
|
||||
|
||||
- name: Build and Push Docker image
|
||||
- name: Build and Push Docker image (Multi-Arch)
|
||||
run: |
|
||||
IMAGE_NAME="git.openlocalpdf.com/${{ gitea.repository }}"
|
||||
echo "Building image: ${IMAGE_NAME}:latest"
|
||||
docker build -t "${IMAGE_NAME}:latest" -f Dockerfile .
|
||||
docker push "${IMAGE_NAME}:latest"
|
||||
TAGS="-t ${IMAGE_NAME}:latest"
|
||||
|
||||
# 如果是 tag 触发,则同步打 tag 推送
|
||||
# 如果是 tag 触发,则同时打上具体版本 tag
|
||||
if [ "${{ github.ref_type }}" = "tag" ]; then
|
||||
TAG_NAME="${{ github.ref_name }}"
|
||||
echo "Tag detected: ${TAG_NAME}"
|
||||
docker tag "${IMAGE_NAME}:latest" "${IMAGE_NAME}:${TAG_NAME}"
|
||||
docker push "${IMAGE_NAME}:${TAG_NAME}"
|
||||
TAGS="${TAGS} -t ${IMAGE_NAME}:${TAG_NAME}"
|
||||
fi
|
||||
|
||||
echo "Building and pushing multi-arch image: ${TAGS}"
|
||||
docker buildx build \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
${TAGS} \
|
||||
--push \
|
||||
-f Dockerfile .
|
||||
Reference in new issue
Block a user