From 82c243c14d5d159d9ce0fe857baef351225a5413 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sun, 16 Aug 2020 06:48:01 +0200 Subject: [PATCH] Add buildkitd-flags for setup-buildx Signed-off-by: CrazyMax --- setup-buildx/README.md | 15 ++++++++------- setup-buildx/action.yml | 3 +++ setup-buildx/dist/index.js | 6 +++++- setup-buildx/src/main.ts | 6 +++++- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/setup-buildx/README.md b/setup-buildx/README.md index 86e039e..792ca71 100644 --- a/setup-buildx/README.md +++ b/setup-buildx/README.md @@ -91,13 +91,14 @@ jobs: Following inputs can be used as `step.with` keys -| 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` | -| `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` | -| `install` | Bool | `false` | Sets up `docker build` command as an alias to `docker buildx` | -| `use` | Bool | `true` | Switch to this builder instance | +| 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` | +| `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` | +| `buildkitd-flags` | String | | [Flags for buildkitd](https://github.com/moby/buildkit/blob/master/docs/buildkitd.toml.md) daemon. | +| `install` | Bool | `false` | Sets up `docker build` command as an alias to `docker buildx` | +| `use` | Bool | `true` | Switch to this builder instance | ### outputs diff --git a/setup-buildx/action.yml b/setup-buildx/action.yml index bf38bc7..8ed2b25 100644 --- a/setup-buildx/action.yml +++ b/setup-buildx/action.yml @@ -17,6 +17,9 @@ inputs: driver-opt: description: 'Passes additional driver-specific options. Eg. image=moby/buildkit:master' required: false + buildkitd-flags: + description: 'Flags for buildkitd daemon' + required: false install: description: 'Sets up docker build command as an alias to docker buildx' default: 'false' diff --git a/setup-buildx/dist/index.js b/setup-buildx/dist/index.js index 10ed3e0..0cda3d4 100644 --- a/setup-buildx/dist/index.js +++ b/setup-buildx/dist/index.js @@ -2493,6 +2493,7 @@ function run() { const bxVersion = core.getInput('version'); const bxDriver = core.getInput('driver') || 'docker-container'; const bxDriverOpt = core.getInput('driver-opt'); + const bxBuildkitdFlags = core.getInput('buildkitd-flags'); const bxInstall = /true/i.test(core.getInput('install')); const bxUse = /true/i.test(core.getInput('use')); const dockerConfigHome = process.env.DOCKER_CONFIG || path.join(os.homedir(), '.docker'); @@ -2501,7 +2502,7 @@ function run() { } core.info('📣 Buildx info'); 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); stateHelper.setBuilderName(builderName); core.info('🔨 Creating a new builder instance...'); @@ -2509,6 +2510,9 @@ function run() { if (bxDriverOpt) { createArgs.push('--driver-opt', bxDriverOpt); } + if (bxBuildkitdFlags) { + createArgs.push('--buildkitd-flags', bxBuildkitdFlags); + } if (bxUse) { createArgs.push('--use'); } diff --git a/setup-buildx/src/main.ts b/setup-buildx/src/main.ts index efc7503..3744b95 100644 --- a/setup-buildx/src/main.ts +++ b/setup-buildx/src/main.ts @@ -16,6 +16,7 @@ async function run(): Promise { const bxVersion: string = core.getInput('version'); const bxDriver: string = core.getInput('driver') || 'docker-container'; const bxDriverOpt: string = core.getInput('driver-opt'); + const bxBuildkitdFlags: string = core.getInput('buildkitd-flags'); const bxInstall: boolean = /true/i.test(core.getInput('install')); const bxUse: boolean = /true/i.test(core.getInput('use')); @@ -28,7 +29,7 @@ async function run(): Promise { core.info('📣 Buildx info'); 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); stateHelper.setBuilderName(builderName); @@ -37,6 +38,9 @@ async function run(): Promise { if (bxDriverOpt) { createArgs.push('--driver-opt', bxDriverOpt); } + if (bxBuildkitdFlags) { + createArgs.push('--buildkitd-flags', bxBuildkitdFlags); + } if (bxUse) { createArgs.push('--use'); }