Add buildkitd-flags for setup-buildx

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2020-08-16 06:48:01 +02:00
parent 807389ab0d
commit 82c243c14d
No known key found for this signature in database
GPG key ID: 3248E46B6BB8C7F7
4 changed files with 21 additions and 9 deletions

View file

@ -91,13 +91,14 @@ jobs:
Following inputs can be used as `step.with` keys Following inputs can be used as `step.with` keys
| Name | Type | Default | Description | | Name | Type | Default | Description |
|------------------|---------|-----------------------------------|------------------------------------| |--------------------|---------|-----------------------------------|------------------------------------|
| `version` | String | _the one installed on the runner_ | [Buildx](https://github.com/docker/buildx) version. e.g. `v0.3.0`, `latest` | | `version` | String | _the one installed on the runner_ | [Buildx](https://github.com/docker/buildx) version. e.g. `v0.3.0`, `latest` |
| `driver` | String | `docker-container` | Sets the [builder driver](https://github.com/docker/buildx#--driver-driver) to be used. | | `driver` | String | `docker-container` | Sets the [builder driver](https://github.com/docker/buildx#--driver-driver) to be used. |
| `driver-opt` | String | | Passes additional [driver-specific options](https://github.com/docker/buildx#--driver-opt-options). e.g. `image=moby/buildkit:master` | | `driver-opt` | String | | Passes additional [driver-specific options](https://github.com/docker/buildx#--driver-opt-options). e.g. `image=moby/buildkit:master` |
| `install` | Bool | `false` | Sets up `docker build` command as an alias to `docker buildx` | | `buildkitd-flags` | String | | [Flags for buildkitd](https://github.com/moby/buildkit/blob/master/docs/buildkitd.toml.md) daemon. |
| `use` | Bool | `true` | Switch to this builder instance | | `install` | Bool | `false` | Sets up `docker build` command as an alias to `docker buildx` |
| `use` | Bool | `true` | Switch to this builder instance |
### outputs ### outputs

View file

@ -17,6 +17,9 @@ inputs:
driver-opt: driver-opt:
description: 'Passes additional driver-specific options. Eg. image=moby/buildkit:master' description: 'Passes additional driver-specific options. Eg. image=moby/buildkit:master'
required: false required: false
buildkitd-flags:
description: 'Flags for buildkitd daemon'
required: false
install: install:
description: 'Sets up docker build command as an alias to docker buildx' description: 'Sets up docker build command as an alias to docker buildx'
default: 'false' default: 'false'

6
setup-buildx/dist/index.js generated vendored
View file

@ -2493,6 +2493,7 @@ function run() {
const bxVersion = core.getInput('version'); const bxVersion = core.getInput('version');
const bxDriver = core.getInput('driver') || 'docker-container'; const bxDriver = core.getInput('driver') || 'docker-container';
const bxDriverOpt = core.getInput('driver-opt'); const bxDriverOpt = core.getInput('driver-opt');
const bxBuildkitdFlags = core.getInput('buildkitd-flags');
const bxInstall = /true/i.test(core.getInput('install')); const bxInstall = /true/i.test(core.getInput('install'));
const bxUse = /true/i.test(core.getInput('use')); const bxUse = /true/i.test(core.getInput('use'));
const dockerConfigHome = process.env.DOCKER_CONFIG || path.join(os.homedir(), '.docker'); const dockerConfigHome = process.env.DOCKER_CONFIG || path.join(os.homedir(), '.docker');
@ -2501,7 +2502,7 @@ function run() {
} }
core.info('📣 Buildx info'); core.info('📣 Buildx info');
yield exec.exec('docker', ['buildx', 'version']); yield exec.exec('docker', ['buildx', 'version']);
const builderName = `builder-${(yield buildx.countBuilders()) + 1}-${process.env.GITHUB_JOB}`; const builderName = `builder-${process.env.GITHUB_JOB}-${(yield buildx.countBuilders()) + 1}`;
core.setOutput('name', builderName); core.setOutput('name', builderName);
stateHelper.setBuilderName(builderName); stateHelper.setBuilderName(builderName);
core.info('🔨 Creating a new builder instance...'); core.info('🔨 Creating a new builder instance...');
@ -2509,6 +2510,9 @@ function run() {
if (bxDriverOpt) { if (bxDriverOpt) {
createArgs.push('--driver-opt', bxDriverOpt); createArgs.push('--driver-opt', bxDriverOpt);
} }
if (bxBuildkitdFlags) {
createArgs.push('--buildkitd-flags', bxBuildkitdFlags);
}
if (bxUse) { if (bxUse) {
createArgs.push('--use'); createArgs.push('--use');
} }

View file

@ -16,6 +16,7 @@ async function run(): Promise<void> {
const bxVersion: string = core.getInput('version'); const bxVersion: string = core.getInput('version');
const bxDriver: string = core.getInput('driver') || 'docker-container'; const bxDriver: string = core.getInput('driver') || 'docker-container';
const bxDriverOpt: string = core.getInput('driver-opt'); const bxDriverOpt: string = core.getInput('driver-opt');
const bxBuildkitdFlags: string = core.getInput('buildkitd-flags');
const bxInstall: boolean = /true/i.test(core.getInput('install')); const bxInstall: boolean = /true/i.test(core.getInput('install'));
const bxUse: boolean = /true/i.test(core.getInput('use')); const bxUse: boolean = /true/i.test(core.getInput('use'));
@ -28,7 +29,7 @@ async function run(): Promise<void> {
core.info('📣 Buildx info'); core.info('📣 Buildx info');
await exec.exec('docker', ['buildx', 'version']); await exec.exec('docker', ['buildx', 'version']);
const builderName: string = `builder-${(await buildx.countBuilders()) + 1}-${process.env.GITHUB_JOB}`; const builderName: string = `builder-${process.env.GITHUB_JOB}-${(await buildx.countBuilders()) + 1}`;
core.setOutput('name', builderName); core.setOutput('name', builderName);
stateHelper.setBuilderName(builderName); stateHelper.setBuilderName(builderName);
@ -37,6 +38,9 @@ async function run(): Promise<void> {
if (bxDriverOpt) { if (bxDriverOpt) {
createArgs.push('--driver-opt', bxDriverOpt); createArgs.push('--driver-opt', bxDriverOpt);
} }
if (bxBuildkitdFlags) {
createArgs.push('--buildkitd-flags', bxBuildkitdFlags);
}
if (bxUse) { if (bxUse) {
createArgs.push('--use'); createArgs.push('--use');
} }