GitHub Actions로 멀티플랫폼 이미지 빌드하기
GitHub Actions로 멀티플랫폼 이미지 빌드하기 (Multi-platform image with GitHub Actions)
build-push-action의 platforms 옵션으로 단일 빌드에서 여러 플랫폼용 이미지를 만들 수 있어요.
출처: 문서
본문
- 사용 가능한 플랫폼 목록은 Docker Setup Buildx 액션을 참고해요.
- 더 많은 플랫폼을 지원하려면 Docker Setup QEMU 액션으로 QEMU를 사용할 수 있어요.
name: ci
on:
push:
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Login to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Build and push
uses: docker/build-push-action@v7
with:
platforms: linux/amd64,linux/arm64
push: true
tags: user/app:latest
멀티플랫폼 이미지 빌드·로드하기 (Build and load multi-platform images)
GitHub Actions 러너의 기본 Docker 설정은 멀티플랫폼 이미지를 레지스트리로 빌드·push하는 것은 지원하지만, 멀티플랫폼 이미지를 로컬 이미지 저장소로 로드하는 것(즉 --load로 여러 플랫폼을 한 번에 로드하는 것)은 지원하지 않아요. 멀티플랫폼 이미지는 레지스트리로 push하거나, 단일 플랫폼으로 로드하는 방식으로 사용해요.