본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

Docker GitHub Builder로 빌드하기

원문 보기 위키 갱신

Docker GitHub Builder로 빌드하기 (Build with Docker GitHub Builder)

Docker가 관리하는 build.yml 재사용 워크플로는 Dockerfile로부터 빌드하고, 많은 저장소가 손으로 연결하던 핵심 작업들을 패키징해요. 이 페이지에서는 워크플로 호출 방법, 멀티플랫폼 이미지 게시 방법, 로컬 빌드 산출물 내보내기 방법을 다뤄요.

출처: 문서

본문

이미지 빌드·push (Build and push an image)

다음 워크플로는 저장소 Dockerfile로부터 빌드하고, 브랜치·태그 이벤트에서 push하며, 메타데이터 입력으로 태그를 생성해요:

name: ci

on:
  push:
    branches:
      - "main"
    tags:
      - "v*"
  pull_request:

permissions:
  contents: read

jobs:
  build:
    uses: docker/github-builder/.github/workflows/build.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' }}
      platforms: linux/amd64,linux/arm64
      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 }}

platforms로 대상 플랫폼을 지정하면 멀티플랫폼 매니페스트가 조립돼요. push로 push 여부를 결정하고, PR 이벤트에서는 push하지 않도록 할 수 있어요.

로컬 산출물 내보내기 (Exporting local artifacts)

output을 로컬로 설정하면 저장소마다 job 구조를 다시 만들 필요 없이 빌드 산출물을 로컬 디렉터리로 내보낼 수 있어요.

더 알아보기 (Learn more)