mirror of
https://github.com/docker/build-push-action.git
synced 2024-11-22 16:33:10 +08:00
Merge pull request #563 from crazy-max/new-inputs
`build-contexts` input
This commit is contained in:
commit
ac9327eae2
21
.github/workflows/ci.yml
vendored
21
.github/workflows/ci.yml
vendored
@ -388,6 +388,27 @@ jobs:
|
||||
docker:10.180.0.1
|
||||
foo:10.0.0.1
|
||||
|
||||
build-contexts:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
with:
|
||||
version: v0.8.0
|
||||
-
|
||||
name: Build
|
||||
uses: ./
|
||||
with:
|
||||
context: ./test
|
||||
file: ./test/buildcontext.Dockerfile
|
||||
build-contexts: |
|
||||
alpine=docker-image://debian:stable-slim
|
||||
tags: name/app:latest
|
||||
|
||||
multi:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
|
27
README.md
27
README.md
@ -202,10 +202,11 @@ Following inputs can be used as `step.with` keys
|
||||
| `add-hosts` | List/CSV | List of [customs host-to-IP mapping](https://docs.docker.com/engine/reference/commandline/build/#add-entries-to-container-hosts-file---add-host) (e.g., `docker:10.180.0.1`) |
|
||||
| `allow` | List/CSV | List of [extra privileged entitlement](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#allow) (e.g., `network.host,security.insecure`) |
|
||||
| `builder` | String | Builder instance (see [setup-buildx](https://github.com/docker/setup-buildx-action) action) |
|
||||
| `build-args` | List | List of build-time variables |
|
||||
| `build-args` | List | List of [build-time variables](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#build-arg) |
|
||||
| `build-contexts` | List | List of additional [build contexts](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#build-context) (e.g., `name=path`) |
|
||||
| `cache-from` | List | List of [external cache sources](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#cache-from) (e.g., `type=local,src=path/to/dir`) |
|
||||
| `cache-to` | List | List of [cache export destinations](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#cache-to) (e.g., `type=local,dest=path/to/dir`) |
|
||||
| `cgroup-parent`¹ | String | Optional [parent cgroup](https://docs.docker.com/engine/reference/commandline/build/#use-a-custom-parent-cgroup---cgroup-parent) for the container used in the build |
|
||||
| `cgroup-parent` | String | Optional [parent cgroup](https://docs.docker.com/engine/reference/commandline/build/#use-a-custom-parent-cgroup---cgroup-parent) for the container used in the build |
|
||||
| `context` | String | Build's context is the set of files located in the specified [`PATH` or `URL`](https://docs.docker.com/engine/reference/commandline/build/) (default [Git context](#git-context)) |
|
||||
| `file` | String | Path to the Dockerfile. (default `{context}/Dockerfile`) |
|
||||
| `labels` | List | List of metadata for an image |
|
||||
@ -214,27 +215,17 @@ Following inputs can be used as `step.with` keys
|
||||
| `no-cache` | Bool | Do not use cache when building the image (default `false`) |
|
||||
| `outputs` | List | List of [output destinations](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#output) (format: `type=local,dest=path`) |
|
||||
| `platforms` | List/CSV | List of [target platforms](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#platform) for build |
|
||||
| `pull` | Bool | Always attempt to pull a newer version of the image (default `false`) |
|
||||
| `pull` | Bool | Always attempt to pull all referenced images (default `false`) |
|
||||
| `push` | Bool | [Push](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#push) is a shorthand for `--output=type=registry` (default `false`) |
|
||||
| `secrets` | List | List of secrets to expose to the build (e.g., `key=string`, `GIT_AUTH_TOKEN=mytoken`) |
|
||||
| `secret-files` | List | List of secret files to expose to the build (e.g., `key=filename`, `MY_SECRET=./secret.txt`) |
|
||||
| `shm-size`¹ | String | Size of [`/dev/shm`](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#-size-of-devshm---shm-size) (e.g., `2g`) |
|
||||
| `ssh` | List | List of SSH agent socket or keys to expose to the build |
|
||||
| `secrets` | List | List of [secrets](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#secret) to expose to the build (e.g., `key=string`, `GIT_AUTH_TOKEN=mytoken`) |
|
||||
| `secret-files` | List | List of [secret files](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#secret) to expose to the build (e.g., `key=filename`, `MY_SECRET=./secret.txt`) |
|
||||
| `shm-size` | String | Size of [`/dev/shm`](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#-size-of-devshm---shm-size) (e.g., `2g`) |
|
||||
| `ssh` | List | List of [SSH agent socket or keys](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#ssh) to expose to the build |
|
||||
| `tags` | List/CSV | List of tags |
|
||||
| `target` | String | Sets the target stage to build |
|
||||
| `ulimit`¹ | List | [Ulimit](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#-set-ulimits---ulimit) options (e.g., `nofile=1024:1024`) |
|
||||
| `ulimit` | List | [Ulimit](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#-set-ulimits---ulimit) options (e.g., `nofile=1024:1024`) |
|
||||
| `github-token` | String | GitHub Token used to authenticate against a repository for [Git context](#git-context) (default `${{ github.token }}`) |
|
||||
|
||||
> ¹ `cgroup-parent`, `shm-size` and `ulimit` are only available using `moby/buildkit:master`
|
||||
> as builder image atm:
|
||||
> ```yaml
|
||||
> - name: Set up Docker Buildx
|
||||
> uses: docker/setup-buildx-action@v1
|
||||
> with:
|
||||
> driver-opts: |
|
||||
> image=moby/buildkit:master
|
||||
> ```
|
||||
|
||||
### outputs
|
||||
|
||||
Following outputs are available
|
||||
|
@ -16,6 +16,9 @@ inputs:
|
||||
build-args:
|
||||
description: "List of build-time variables"
|
||||
required: false
|
||||
build-contexts:
|
||||
description: "List of additional build contexts (e.g., name=path)"
|
||||
required: false
|
||||
builder:
|
||||
description: "Builder instance"
|
||||
required: false
|
||||
@ -55,7 +58,7 @@ inputs:
|
||||
description: "List of target platforms for build"
|
||||
required: false
|
||||
pull:
|
||||
description: "Always attempt to pull a newer version of the image"
|
||||
description: "Always attempt to pull all referenced images"
|
||||
required: false
|
||||
default: 'false'
|
||||
push:
|
||||
|
6
dist/index.js
generated
vendored
6
dist/index.js
generated
vendored
@ -286,6 +286,7 @@ function getInputs(defaultContext) {
|
||||
addHosts: yield getInputList('add-hosts'),
|
||||
allow: yield getInputList('allow'),
|
||||
buildArgs: yield getInputList('build-args', true),
|
||||
buildContexts: yield getInputList('build-contexts', true),
|
||||
builder: core.getInput('builder'),
|
||||
cacheFrom: yield getInputList('cache-from', true),
|
||||
cacheTo: yield getInputList('cache-to', true),
|
||||
@ -334,6 +335,11 @@ function getBuildArgs(inputs, defaultContext, buildxVersion) {
|
||||
yield exports.asyncForEach(inputs.buildArgs, (buildArg) => __awaiter(this, void 0, void 0, function* () {
|
||||
args.push('--build-arg', buildArg);
|
||||
}));
|
||||
if (buildx.satisfies(buildxVersion, '>=0.8.0')) {
|
||||
yield exports.asyncForEach(inputs.buildContexts, (buildContext) => __awaiter(this, void 0, void 0, function* () {
|
||||
args.push('--build-context', buildContext);
|
||||
}));
|
||||
}
|
||||
yield exports.asyncForEach(inputs.cacheFrom, (cacheFrom) => __awaiter(this, void 0, void 0, function* () {
|
||||
args.push('--cache-from', cacheFrom);
|
||||
}));
|
||||
|
@ -17,6 +17,7 @@ export interface Inputs {
|
||||
addHosts: string[];
|
||||
allow: string[];
|
||||
buildArgs: string[];
|
||||
buildContexts: string[];
|
||||
builder: string;
|
||||
cacheFrom: string[];
|
||||
cacheTo: string[];
|
||||
@ -71,6 +72,7 @@ export async function getInputs(defaultContext: string): Promise<Inputs> {
|
||||
addHosts: await getInputList('add-hosts'),
|
||||
allow: await getInputList('allow'),
|
||||
buildArgs: await getInputList('build-args', true),
|
||||
buildContexts: await getInputList('build-contexts', true),
|
||||
builder: core.getInput('builder'),
|
||||
cacheFrom: await getInputList('cache-from', true),
|
||||
cacheTo: await getInputList('cache-to', true),
|
||||
@ -115,6 +117,11 @@ async function getBuildArgs(inputs: Inputs, defaultContext: string, buildxVersio
|
||||
await asyncForEach(inputs.buildArgs, async buildArg => {
|
||||
args.push('--build-arg', buildArg);
|
||||
});
|
||||
if (buildx.satisfies(buildxVersion, '>=0.8.0')) {
|
||||
await asyncForEach(inputs.buildContexts, async buildContext => {
|
||||
args.push('--build-context', buildContext);
|
||||
});
|
||||
}
|
||||
await asyncForEach(inputs.cacheFrom, async cacheFrom => {
|
||||
args.push('--cache-from', cacheFrom);
|
||||
});
|
||||
|
3
test/buildcontext.Dockerfile
Normal file
3
test/buildcontext.Dockerfile
Normal file
@ -0,0 +1,3 @@
|
||||
# syntax=docker/dockerfile-upstream:master
|
||||
FROM alpine
|
||||
RUN cat /etc/*release
|
Loading…
Reference in New Issue
Block a user