Docker GitHub Builder로 Bake하기
Docker GitHub Builder로 Bake하기 (Bake with Docker GitHub Builder)
Docker가 관리하는 bake.yml 재사용 워크플로는 Dockerfile 입력 세트 대신 Bake 정의로부터 빌드해요. 이 페이지에서는 타깃에 대해 워크플로를 호출하는 방법, Bake 오버라이드와 변수를 넘기는 방법, 그리고 Bake 파일이 이미 빌드의 진실 공급원(source of truth)일 때 로컬 출력을 내보내는 방법을 다뤄요.
출처: 문서
본문
Bake 타깃 빌드·push (Build and push a Bake target)
다음 워크플로는 docker/github-builder/.github/workflows/bake.yml@v1을 호출하고, 메타데이터 입력에서 생성된 태그로 결과를 게시해요:
name: ci
on:
push:
branches:
- "main"
tags:
- "v*"
pull_request:
permissions:
contents: read
jobs:
bake:
uses: docker/github-builder/.github/workflows/bake.yml@v1
permissions:
contents: read # to fetch the repository content
id-token: write # for signing attestation(s) with GitHub OIDC Token
with:
output: image
push: ${{ github.event_name != 'pull_request' }}
target: image
meta-images: name/app
meta-tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
secrets:
registry-auths: |
- registry: docker.io
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
with의 target으로 빌드할 Bake 타깃을 지정하고, output: image로 이미지를 push하도록 하고, push로 push 여부(PR이면 false)를 결정해요. 레지스트리 인증은 secrets.registry-auths로 넘겨요.
Bake 오버라이드와 변수 전달하기 (Passing Bake overrides and variables)
워크플로 입력을 통해 Bake의 --set 오버라이드나 변수 값을 전달할 수 있어요. 자세한 입력값은 원본 문서를 참고해요.
로컬 출력 내보내기 (Exporting local output)
Bake 파일이 진실 공급원인 경우 output을 로컬 디렉터리로 설정해 빌드 산출물을 내보낼 수 있어요.