mirror of
https://github.com/docker/build-push-action.git
synced 2026-01-14 08:13:09 +08:00
Compare commits
2 Commits
2812df3236
...
62a971216d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
62a971216d | ||
|
|
1f530c4b33 |
13
.github/workflows/ci.yml
vendored
13
.github/workflows/ci.yml
vendored
@ -1544,21 +1544,10 @@ jobs:
|
||||
fi
|
||||
|
||||
distribute:
|
||||
uses: ./.github/workflows/reusable-distribute-mp.yml
|
||||
uses: ./.github/workflows/reusable-distribute.yml
|
||||
with:
|
||||
push: false
|
||||
meta-image: user/app
|
||||
build-context: "{{defaultContext}}:test"
|
||||
build-file: multi.Dockerfile
|
||||
build-platforms: linux/amd64,linux/arm64
|
||||
|
||||
distribute-cache:
|
||||
uses: ./.github/workflows/reusable-distribute-mp.yml
|
||||
with:
|
||||
push: false
|
||||
cache: true
|
||||
cache-scope: multi
|
||||
meta-image: user/app
|
||||
build-context: "{{defaultContext}}:test"
|
||||
build-file: multi.Dockerfile
|
||||
build-platforms: linux/amd64,linux/arm64
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# Reusable workflow to distribute multi-platform builds efficiently
|
||||
# https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners
|
||||
name: reusable-distribute-mp
|
||||
name: reusable-distribute
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
@ -16,20 +16,6 @@ on:
|
||||
description: "Push image to registry"
|
||||
required: false
|
||||
default: false
|
||||
cache:
|
||||
type: boolean
|
||||
description: "Enable cache to GitHub Actions cache backend"
|
||||
required: false
|
||||
default: false
|
||||
cache-scope:
|
||||
type: string
|
||||
description: "Which scope cache object belongs to if cache enabled (default is target name)"
|
||||
required: false
|
||||
cache-mode:
|
||||
type: string
|
||||
description: "Cache layers to export if cache enabled (min or max)"
|
||||
required: false
|
||||
default: 'min'
|
||||
set-meta-annotations:
|
||||
type: boolean
|
||||
description: "Set metadata-action annotations"
|
||||
@ -52,66 +38,40 @@ on:
|
||||
required: true
|
||||
meta-tags:
|
||||
type: string
|
||||
description: "List of tags as key-value pair attributes"
|
||||
description: 'List of tags as key-value pair attributes'
|
||||
required: false
|
||||
meta-flavor:
|
||||
type: string
|
||||
description: "Flavors to apply"
|
||||
description: 'Flavors to apply'
|
||||
required: false
|
||||
meta-labels:
|
||||
type: string
|
||||
description: "List of custom labels"
|
||||
description: 'List of custom labels'
|
||||
required: false
|
||||
meta-annotations:
|
||||
type: string
|
||||
description: "List of custom annotations"
|
||||
required: false
|
||||
# same as docker/setup-buildx-action inputs (minus driver, install, use, endpoint, append, cleanup)
|
||||
buildx-version:
|
||||
type: string
|
||||
description: "Buildx version. (eg. v0.3.0)"
|
||||
required: false
|
||||
buildx-cache-binary:
|
||||
type: boolean
|
||||
description: "Cache buildx binary to GitHub Actions cache backend"
|
||||
default: true
|
||||
required: false
|
||||
buildx-driver-opts:
|
||||
type: string
|
||||
description: "List of additional docker-container options. (eg. image=moby/buildkit:master)"
|
||||
required: false
|
||||
buildkitd-flags:
|
||||
type: string
|
||||
description: "BuildKit daemon flags"
|
||||
required: false
|
||||
buildkitd-config:
|
||||
type: string
|
||||
description: "BuildKit daemon config file"
|
||||
required: false
|
||||
buildkitd-config-inline:
|
||||
type: string
|
||||
description: "Inline BuildKit daemon config"
|
||||
description: 'List of custom annotations'
|
||||
required: false
|
||||
# same as docker/login-action inputs (minus logout)
|
||||
login-registry:
|
||||
type: string
|
||||
description: "Server address of Docker registry. If not set then will default to Docker Hub"
|
||||
description: 'Server address of Docker registry. If not set then will default to Docker Hub'
|
||||
required: false
|
||||
login-username:
|
||||
type: string
|
||||
description: "Username used to log against the Docker registry"
|
||||
description: 'Username used to log against the Docker registry'
|
||||
required: false
|
||||
login-ecr:
|
||||
type: string
|
||||
description: "Specifies whether the given registry is ECR (auto, true or false)"
|
||||
description: 'Specifies whether the given registry is ECR (auto, true or false)'
|
||||
default: 'auto'
|
||||
required: false
|
||||
# same as docker/setup-qemu-action inputs (minus platforms, cache-image)
|
||||
qemu-image:
|
||||
type: string
|
||||
description: "QEMU static binaries Docker image (e.g. tonistiigi/binfmt:latest)"
|
||||
description: 'QEMU static binaries Docker image (e.g. tonistiigi/binfmt:latest)'
|
||||
required: false
|
||||
# same as docker/build-push-action inputs (minus builder, cache-from, cache-to, call, load, no-cache, no-cache-filters, outputs, platforms, push, tags)
|
||||
# same as docker/build-push-action inputs (minus builder, call, load, outputs, platforms, push, tags)
|
||||
build-add-hosts:
|
||||
type: string
|
||||
description: "List of a customs host-to-IP mapping (e.g., docker:10.180.0.1)"
|
||||
@ -132,6 +92,14 @@ on:
|
||||
type: string
|
||||
description: "List of build-time variables"
|
||||
required: false
|
||||
build-cache-from:
|
||||
type: string
|
||||
description: "List of external cache sources for buildx (e.g., user/app:cache, type=local,src=path/to/dir)"
|
||||
required: false
|
||||
build-cache-to:
|
||||
type: string
|
||||
description: "List of cache export destinations for buildx (e.g., user/app:cache, type=local,dest=path/to/dir)"
|
||||
required: false
|
||||
build-cgroup-parent:
|
||||
type: string
|
||||
description: "Optional parent cgroup for the container used in the build"
|
||||
@ -156,6 +124,15 @@ on:
|
||||
type: string
|
||||
description: "Set the networking mode for the RUN instructions during build"
|
||||
required: false
|
||||
build-no-cache:
|
||||
type: boolean
|
||||
description: "Do not use cache when building the image"
|
||||
required: false
|
||||
default: false
|
||||
build-no-cache-filters:
|
||||
type: string
|
||||
description: "Do not cache specified stages"
|
||||
required: false
|
||||
build-platforms:
|
||||
type: string
|
||||
description: "List of target platforms for build"
|
||||
@ -213,7 +190,7 @@ on:
|
||||
required: false
|
||||
|
||||
env:
|
||||
ACTIONS_TOOLKIT_VERSION: "0.56.0"
|
||||
ACTIONS_TOOLKIT_VERSION: "0.54.0"
|
||||
|
||||
jobs:
|
||||
prepare:
|
||||
@ -271,57 +248,10 @@ jobs:
|
||||
core.setOutput('includes', JSON.stringify(includes));
|
||||
});
|
||||
|
||||
warmup:
|
||||
runs-on: ${{ inputs.runner == 'auto' && 'ubuntu-latest' || inputs.runner }}
|
||||
steps:
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
if: ${{ inputs.setup-qemu }}
|
||||
with:
|
||||
image: ${{ inputs.qemu-image }}
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
version: ${{ inputs.buildx-version }}
|
||||
driver-opts: ${{ inputs.buildx-driver-opts }}
|
||||
buildkitd-flags: ${{ inputs.buildkitd-flags }}
|
||||
buildkitd-config: ${{ inputs.buildkitd-config }}
|
||||
buildkitd-config-inline: ${{ inputs.buildkitd-config-inline }}
|
||||
cache-binary: ${{ inputs.buildx-cache-binary }}
|
||||
-
|
||||
name: Warm up cache
|
||||
uses: docker/build-push-action@v6
|
||||
if: ${{ inputs.cache }}
|
||||
with:
|
||||
add-hosts: ${{ inputs.build-add-hosts }}
|
||||
allow: ${{ inputs.build-allow }}
|
||||
build-args: ${{ inputs.build-build-args }}
|
||||
build-contexts: ${{ inputs.build-contexts }}
|
||||
cache-from: type=gha,scope=${{ inputs.cache-scope || inputs.target || 'buildkit' }}-warmup
|
||||
cache-to: type=gha,scope=${{ inputs.cache-scope || inputs.target || 'buildkit' }}-warmup,mode=${{ inputs.cache-mode }}
|
||||
cgroup-parent: ${{ inputs.build-cgroup-parent }}
|
||||
context: ${{ inputs.build-context }}
|
||||
file: ${{ inputs.build-file }}
|
||||
labels: ${{ steps.build-inputs.outputs.labels }}
|
||||
network: ${{ inputs.build-network }}
|
||||
outputs: type=cacheonly
|
||||
pull: ${{ inputs.build-pull }}
|
||||
secrets: ${{ inputs.build-secrets }}
|
||||
secret-envs: ${{ inputs.build-secret-envs }}
|
||||
secret-files: ${{ inputs.build-secret-files }}
|
||||
shm-size: ${{ inputs.build-shm-size }}
|
||||
ssh: ${{ inputs.build-ssh }}
|
||||
target: ${{ inputs.build-target }}
|
||||
ulimit: ${{ inputs.build-ulimit }}
|
||||
github-token: ${{ secrets.github-token || github.token }}
|
||||
|
||||
build:
|
||||
runs-on: ${{ matrix.runner }}
|
||||
needs:
|
||||
- prepare
|
||||
- warmup
|
||||
outputs:
|
||||
# needs predefined outputs as we can't use dynamic ones atm: https://github.com/actions/runner/pull/2477
|
||||
# 100 is the maximum number of platforms supported by the matrix strategy
|
||||
@ -457,50 +387,30 @@ jobs:
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
version: ${{ inputs.buildx-version }}
|
||||
driver-opts: ${{ inputs.buildx-driver-opts }}
|
||||
buildkitd-flags: ${{ inputs.buildkitd-flags }}
|
||||
buildkitd-config: ${{ inputs.buildkitd-config }}
|
||||
buildkitd-config-inline: ${{ inputs.buildkitd-config-inline }}
|
||||
cache-binary: ${{ inputs.buildx-cache-binary }}
|
||||
-
|
||||
name: Set build inputs
|
||||
id: build-inputs
|
||||
uses: actions/github-script@v7
|
||||
env:
|
||||
PLATFORM: ${{ matrix.platform }}
|
||||
INPUT_CACHE: ${{ inputs.cache }}
|
||||
INPUT_CACHE-SCOPE: ${{ inputs.cache-scope }}
|
||||
INPUT_CACHE-MODE: ${{ inputs.cache-mode }}
|
||||
INPUT_SET-META-ANNOTATIONS: ${{ inputs.set-meta-annotations }}
|
||||
INPUT_SET-META-LABELS: ${{ inputs.set-meta-labels }}
|
||||
INPUT_BUILD-ANNOTATIONS: ${{ inputs.build-annotations }}
|
||||
INPUT_BUILD-LABELS: ${{ inputs.build-labels }}
|
||||
INPUT_BUILD-TARGET: ${{ inputs.build-target }}
|
||||
with:
|
||||
script: |
|
||||
const platformPair = process.env.PLATFORM.replace(/\//g, '-');
|
||||
const inpCache = core.getBooleanInput('cache');
|
||||
const inpCacheScope = core.getInput('cache-scope');
|
||||
const inpCacheMode = core.getInput('cache-mode');
|
||||
const inpSetMetaAnnotations = core.getBooleanInput('set-meta-annotations');
|
||||
const inpSetMetaLabels = core.getBooleanInput('set-meta-labels');
|
||||
let inpBuildAnnotations = core.getInput('build-annotations');
|
||||
let inpBuildLabels = core.getInput('build-labels');
|
||||
const inpBuildTarget = core.getInput('build-target');
|
||||
|
||||
if (inpCache) {
|
||||
core.setOutput('cache-from', `type=gha,scope=${inpCacheScope || inpTarget || 'buildkit'}-warmup\ntype=gha,scope=${inpCacheScope || inpTarget}-${platformPair}`);
|
||||
core.setOutput('cache-to', `type=gha,scope=${inpCacheScope || inpTarget || 'buildkit'}-${platformPair},mode=${inpCacheMode}`);
|
||||
}
|
||||
let inpBuildAnnotations = core.getInput('build-annotations');
|
||||
if (inpSetMetaAnnotations) {
|
||||
inpBuildAnnotations += `\n${{ steps.meta.outputs.annotations }}`;
|
||||
}
|
||||
core.setOutput('annotations', inpBuildAnnotations);
|
||||
let inpBuildLabels = core.getInput('build-labels');
|
||||
if (inpSetMetaLabels) {
|
||||
inpBuildLabels += `\n${{ steps.meta.outputs.labels }}`;
|
||||
}
|
||||
|
||||
core.setOutput('annotations', inpBuildAnnotations);
|
||||
core.setOutput('labels', inpBuildLabels);
|
||||
-
|
||||
name: Build
|
||||
@ -513,13 +423,15 @@ jobs:
|
||||
attests: ${{ inputs.build-attests }}
|
||||
build-args: ${{ inputs.build-build-args }}
|
||||
build-contexts: ${{ inputs.build-contexts }}
|
||||
cache-from: ${{ steps.build-inputs.outputs.cache-from }}
|
||||
cache-to: ${{ steps.build-inputs.outputs.cache-to }}
|
||||
cache-from: ${{ inputs.build-cache-from }}
|
||||
cache-to: ${{ inputs.build-cache-to }}
|
||||
cgroup-parent: ${{ inputs.build-cgroup-parent }}
|
||||
context: ${{ inputs.build-context }}
|
||||
file: ${{ inputs.build-file }}
|
||||
labels: ${{ steps.build-inputs.outputs.labels }}
|
||||
network: ${{ inputs.build-network }}
|
||||
no-cache: ${{ inputs.build-no-cache }}
|
||||
no-cache-filters: ${{ inputs.build-no-cache-filters }}
|
||||
outputs: |
|
||||
type=image,"name=${{ inputs.meta-image }}",push-by-digest=true,name-canonical=true,push=${{ inputs.push }}
|
||||
platforms: ${{ matrix.platform }}
|
||||
@ -533,7 +445,6 @@ jobs:
|
||||
ssh: ${{ inputs.build-ssh }}
|
||||
target: ${{ inputs.build-target }}
|
||||
ulimit: ${{ inputs.build-ulimit }}
|
||||
github-token: ${{ secrets.github-token || github.token }}
|
||||
-
|
||||
name: Set digest output
|
||||
id: digest
|
||||
@ -570,13 +481,7 @@ jobs:
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
version: ${{ inputs.buildx-version }}
|
||||
driver-opts: ${{ inputs.buildx-driver-opts }}
|
||||
buildkitd-flags: ${{ inputs.buildkitd-flags }}
|
||||
buildkitd-config: ${{ inputs.buildkitd-config }}
|
||||
buildkitd-config-inline: ${{ inputs.buildkitd-config-inline }}
|
||||
cache-binary: ${{ inputs.buildx-cache-binary }}
|
||||
if: ${{ inputs.push }}
|
||||
-
|
||||
name: Create manifest list
|
||||
uses: actions/github-script@v7
|
||||
@ -156,7 +156,6 @@ jobs:
|
||||
## Examples
|
||||
|
||||
* [Multi-platform image](https://docs.docker.com/build/ci/github-actions/multi-platform/)
|
||||
* [Distribute multi-platform build across runners](https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-multi-platform-build-across-runners)
|
||||
* [Secrets](https://docs.docker.com/build/ci/github-actions/secrets/)
|
||||
* [Push to multi-registries](https://docs.docker.com/build/ci/github-actions/push-multi-registries/)
|
||||
* [Manage tags and labels](https://docs.docker.com/build/ci/github-actions/manage-tags-labels/)
|
||||
@ -171,7 +170,6 @@ jobs:
|
||||
* [SBOM and provenance attestations](https://docs.docker.com/build/ci/github-actions/attestations/)
|
||||
* [Annotations](https://docs.docker.com/build/ci/github-actions/annotations/)
|
||||
* [Reproducible builds](https://docs.docker.com/build/ci/github-actions/reproducible-builds/)
|
||||
* [Build checks](https://docs.docker.com/build/ci/github-actions/checks/#run-checks-with-dockerbuild-push-action)
|
||||
|
||||
## Summaries
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user