mirror of
https://gitee.com/actions-mirror/docker-setup-buildx-action.git
synced 2024-11-27 15:20:43 +08:00
platforms input
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
2dfca373f3
commit
f6efb5fcbb
15
.github/workflows/ci.yml
vendored
15
.github/workflows/ci.yml
vendored
@ -449,3 +449,18 @@ jobs:
|
|||||||
-
|
-
|
||||||
name: List builder platforms
|
name: List builder platforms
|
||||||
run: echo ${{ steps.buildx.outputs.platforms }}
|
run: echo ${{ steps.buildx.outputs.platforms }}
|
||||||
|
|
||||||
|
platforms:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
-
|
||||||
|
name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v2
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
platforms: linux/amd64
|
||||||
|
43
README.md
43
README.md
@ -71,33 +71,36 @@ jobs:
|
|||||||
|
|
||||||
### inputs
|
### inputs
|
||||||
|
|
||||||
Following inputs can be used as `step.with` keys
|
Following inputs can be used as `step.with` keys:
|
||||||
|
|
||||||
| Name | Type | Description |
|
> `List` type is a newline-delimited string
|
||||||
|-------------------|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
||||||
| `version` | String | [Buildx](https://github.com/docker/buildx) version. (eg. `v0.3.0`, `latest`, `https://github.com/docker/buildx.git#master`) |
|
|
||||||
| `driver` | String | Sets the [builder driver](https://docs.docker.com/engine/reference/commandline/buildx_create/#driver) to be used (default `docker-container`) |
|
|
||||||
| `driver-opts` | CSV | List of additional [driver-specific options](https://docs.docker.com/engine/reference/commandline/buildx_create/#driver-opt) (eg. `image=moby/buildkit:master`) |
|
|
||||||
| `buildkitd-flags` | String | [Flags for buildkitd](https://docs.docker.com/engine/reference/commandline/buildx_create/#buildkitd-flags) daemon (since [buildx v0.3.0](https://github.com/docker/buildx/releases/tag/v0.3.0)) |
|
|
||||||
| `install` | Bool | Sets up `docker build` command as an alias to `docker buildx` (default `false`) |
|
|
||||||
| `use` | Bool | Switch to this builder instance (default `true`) |
|
|
||||||
| `endpoint` | String | [Optional address for docker socket](https://docs.docker.com/engine/reference/commandline/buildx_create/#description) or context from `docker context ls` |
|
|
||||||
| `config`¹ | String | [BuildKit config file](https://docs.docker.com/engine/reference/commandline/buildx_create/#config) |
|
|
||||||
| `config-inline`¹ | String | Same as `config` but inline |
|
|
||||||
| `append` | YAML | [Append additional nodes](docs/advanced/append-nodes.md) to the builder |
|
|
||||||
|
|
||||||
> * ¹ `config` and `config-inline` are mutually exclusive
|
|
||||||
|
|
||||||
> `CSV` type must be a newline-delimited string
|
|
||||||
> ```yaml
|
|
||||||
> driver-opts: image=moby/buildkit:master
|
|
||||||
> ```
|
|
||||||
> ```yaml
|
> ```yaml
|
||||||
> driver-opts: |
|
> driver-opts: |
|
||||||
> image=moby/buildkit:master
|
> image=moby/buildkit:master
|
||||||
> network=host
|
> network=host
|
||||||
> ```
|
> ```
|
||||||
|
|
||||||
|
> `CSV` type must be a newline-delimited string
|
||||||
|
> ```yaml
|
||||||
|
> platforms: linux/amd64,linux/arm64
|
||||||
|
> ```
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
|-------------------|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
|
| `version` | String | [Buildx](https://github.com/docker/buildx) version. (eg. `v0.3.0`, `latest`, `https://github.com/docker/buildx.git#master`) |
|
||||||
|
| `driver` | String | Sets the [builder driver](https://docs.docker.com/engine/reference/commandline/buildx_create/#driver) to be used (default `docker-container`) |
|
||||||
|
| `driver-opts` | List | List of additional [driver-specific options](https://docs.docker.com/engine/reference/commandline/buildx_create/#driver-opt) (eg. `image=moby/buildkit:master`) |
|
||||||
|
| `buildkitd-flags` | String | [Flags for buildkitd](https://docs.docker.com/engine/reference/commandline/buildx_create/#buildkitd-flags) daemon (since [buildx v0.3.0](https://github.com/docker/buildx/releases/tag/v0.3.0)) |
|
||||||
|
| `install` | Bool | Sets up `docker build` command as an alias to `docker buildx` (default `false`) |
|
||||||
|
| `use` | Bool | Switch to this builder instance (default `true`) |
|
||||||
|
| `endpoint` | String | [Optional address for docker socket](https://docs.docker.com/engine/reference/commandline/buildx_create/#description) or context from `docker context ls` |
|
||||||
|
| `platforms` | List/CSV | Fixed [platforms](https://docs.docker.com/engine/reference/commandline/buildx_create/#platform) for current node. If not empty, values take priority over the detected ones. |
|
||||||
|
| `config`¹ | String | [BuildKit config file](https://docs.docker.com/engine/reference/commandline/buildx_create/#config) |
|
||||||
|
| `config-inline`¹ | String | Same as `config` but inline |
|
||||||
|
| `append` | YAML | [Append additional nodes](docs/advanced/append-nodes.md) to the builder |
|
||||||
|
|
||||||
|
> * ¹ `config` and `config-inline` are mutually exclusive
|
||||||
|
|
||||||
### outputs
|
### outputs
|
||||||
|
|
||||||
Following outputs are available
|
Following outputs are available
|
||||||
|
@ -91,6 +91,24 @@ describe('getCreateArgs', () => {
|
|||||||
'tls://foo:1234'
|
'tls://foo:1234'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
4,
|
||||||
|
new Map<string, string>([
|
||||||
|
['driver', 'remote'],
|
||||||
|
['platforms', 'linux/arm64,linux/arm/v7'],
|
||||||
|
['endpoint', 'tls://foo:1234'],
|
||||||
|
['install', 'false'],
|
||||||
|
['use', 'true'],
|
||||||
|
]),
|
||||||
|
[
|
||||||
|
'create',
|
||||||
|
'--name', 'builder-9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d',
|
||||||
|
'--driver', 'remote',
|
||||||
|
'--platform', 'linux/arm64,linux/arm/v7',
|
||||||
|
'--use',
|
||||||
|
'tls://foo:1234'
|
||||||
|
]
|
||||||
|
],
|
||||||
])(
|
])(
|
||||||
'[%d] given %p as inputs, returns %p',
|
'[%d] given %p as inputs, returns %p',
|
||||||
async (num: number, inputs: Map<string, string>, expected: Array<string>) => {
|
async (num: number, inputs: Map<string, string>, expected: Array<string>) => {
|
||||||
|
@ -32,6 +32,9 @@ inputs:
|
|||||||
endpoint:
|
endpoint:
|
||||||
description: 'Optional address for docker socket or context from `docker context ls`'
|
description: 'Optional address for docker socket or context from `docker context ls`'
|
||||||
required: false
|
required: false
|
||||||
|
platforms:
|
||||||
|
description: 'Fixed platforms for current node. If not empty, values take priority over the detected ones'
|
||||||
|
required: false
|
||||||
config:
|
config:
|
||||||
description: 'BuildKit config file'
|
description: 'BuildKit config file'
|
||||||
required: false
|
required: false
|
||||||
|
@ -29,6 +29,7 @@ export interface Inputs {
|
|||||||
driver: string;
|
driver: string;
|
||||||
driverOpts: string[];
|
driverOpts: string[];
|
||||||
buildkitdFlags: string;
|
buildkitdFlags: string;
|
||||||
|
platforms: string[];
|
||||||
install: boolean;
|
install: boolean;
|
||||||
use: boolean;
|
use: boolean;
|
||||||
endpoint: string;
|
endpoint: string;
|
||||||
@ -44,6 +45,7 @@ export async function getInputs(): Promise<Inputs> {
|
|||||||
driver: core.getInput('driver') || 'docker-container',
|
driver: core.getInput('driver') || 'docker-container',
|
||||||
driverOpts: await getInputList('driver-opts', true),
|
driverOpts: await getInputList('driver-opts', true),
|
||||||
buildkitdFlags: core.getInput('buildkitd-flags') || '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host',
|
buildkitdFlags: core.getInput('buildkitd-flags') || '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host',
|
||||||
|
platforms: await getInputList('platforms'),
|
||||||
install: core.getBooleanInput('install'),
|
install: core.getBooleanInput('install'),
|
||||||
use: core.getBooleanInput('use'),
|
use: core.getBooleanInput('use'),
|
||||||
endpoint: core.getInput('endpoint'),
|
endpoint: core.getInput('endpoint'),
|
||||||
@ -67,6 +69,9 @@ export async function getCreateArgs(inputs: Inputs, buildxVersion: string): Prom
|
|||||||
args.push('--buildkitd-flags', inputs.buildkitdFlags);
|
args.push('--buildkitd-flags', inputs.buildkitdFlags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (inputs.platforms.length > 0) {
|
||||||
|
args.push('--platform', inputs.platforms.join(','));
|
||||||
|
}
|
||||||
if (inputs.use) {
|
if (inputs.use) {
|
||||||
args.push('--use');
|
args.push('--use');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user