feat(ci): 支持 docker buildx 多架构构建 (linux/amd64,linux/arm64)
Build and Push Docker Image / build (push) Successful in 32m34s
Build and Push Docker Image / build (push) Successful in 32m34s
This commit is contained in:
1 parent
7f234aec2f
commit
f364821128
1 file changed
+17
-7
@@ -27,21 +27,31 @@ jobs:
|
|||||||
which docker || echo "docker CLI not found!"
|
which docker || echo "docker CLI not found!"
|
||||||
docker version || echo "docker daemon not accessible!"
|
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
|
- name: Log in to Gitea Container Registry
|
||||||
run: |
|
run: |
|
||||||
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login git.openlocalpdf.com -u "${{ gitea.actor }}" --password-stdin
|
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: |
|
run: |
|
||||||
IMAGE_NAME="git.openlocalpdf.com/${{ gitea.repository }}"
|
IMAGE_NAME="git.openlocalpdf.com/${{ gitea.repository }}"
|
||||||
echo "Building image: ${IMAGE_NAME}:latest"
|
TAGS="-t ${IMAGE_NAME}:latest"
|
||||||
docker build -t "${IMAGE_NAME}:latest" -f Dockerfile .
|
|
||||||
docker push "${IMAGE_NAME}:latest"
|
|
||||||
|
|
||||||
# 如果是 tag 触发,则同步打 tag 推送
|
# 如果是 tag 触发,则同时打上具体版本 tag
|
||||||
if [ "${{ github.ref_type }}" = "tag" ]; then
|
if [ "${{ github.ref_type }}" = "tag" ]; then
|
||||||
TAG_NAME="${{ github.ref_name }}"
|
TAG_NAME="${{ github.ref_name }}"
|
||||||
echo "Tag detected: ${TAG_NAME}"
|
echo "Tag detected: ${TAG_NAME}"
|
||||||
docker tag "${IMAGE_NAME}:latest" "${IMAGE_NAME}:${TAG_NAME}"
|
TAGS="${TAGS} -t ${IMAGE_NAME}:${TAG_NAME}"
|
||||||
docker push "${IMAGE_NAME}:${TAG_NAME}"
|
|
||||||
fi
|
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