Add driver and driver-opt inputs for setup-buildx

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2020-08-12 14:07:04 +02:00
parent 4bde7b156d
commit 5cec6ce786
No known key found for this signature in database
GPG Key ID: 3248E46B6BB8C7F7
8 changed files with 80 additions and 19 deletions

@ -15,7 +15,7 @@ on:
- setup-buildx/** - setup-buildx/**
jobs: jobs:
build: main:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
fail-fast: false fail-fast: false
@ -62,6 +62,44 @@ jobs:
run: | run: |
docker build --help docker build --help
driver:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
driver:
- docker-container
- docker
steps:
-
name: Checkout
uses: actions/checkout@v2.3.1
-
name: Set up Docker Buildx
id: buildx
uses: ./setup-buildx/
with:
driver: ${{ matrix.driver }}
driver-opt:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
driver-opt:
- image=moby/buildkit:latest
- image=moby/buildkit:master
steps:
-
name: Checkout
uses: actions/checkout@v2.3.1
-
name: Set up Docker Buildx
id: buildx
uses: ./setup-buildx/
with:
driver-opt: ${{ matrix.driver-opt }}
with-qemu: with-qemu:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:

@ -15,7 +15,7 @@ on:
- setup-qemu/** - setup-qemu/**
jobs: jobs:
build: main:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
fail-fast: false fail-fast: false

@ -88,10 +88,12 @@ 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 |
|------------------|---------|-----------|------------------------------------| |------------------|---------|---------------------|------------------------------------|
| `buildx-version` | String | `latest` | [Buildx](https://github.com/docker/buildx) version. Example: `v0.3.0` | | `buildx-version` | String | `latest` | [Buildx](https://github.com/docker/buildx) version. e.g. `v0.3.0` |
| `install` | Bool | `false` | Sets up `docker build` command as an alias to `docker buildx` | | `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` |
### outputs ### outputs

@ -8,9 +8,16 @@ branding:
inputs: inputs:
buildx-version: buildx-version:
description: 'Buildx version. Example: v0.3.0' description: 'Buildx version. e.g. v0.3.0'
default: 'latest' default: 'latest'
required: false required: false
driver:
description: 'Sets the builder driver to be used'
default: 'docker-container'
required: false
driver-opt:
description: 'Passes additional driver-specific options. Eg. image=moby/buildkit:master'
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'

14
setup-buildx/dist/index.js generated vendored

@ -2492,21 +2492,27 @@ function run() {
return; return;
} }
const buildxVer = core.getInput('buildx-version') || 'latest'; const buildxVer = core.getInput('buildx-version') || 'latest';
const driver = core.getInput('driver') || 'docker-container';
const driverOpt = core.getInput('driver-opt');
const install = /true/i.test(core.getInput('install')); const install = /true/i.test(core.getInput('install'));
const dockerConfigHome = process.env.DOCKER_CONFIG || path.join(os.homedir(), '.docker'); const dockerConfigHome = process.env.DOCKER_CONFIG || path.join(os.homedir(), '.docker');
yield installer.buildx(buildxVer, dockerConfigHome); yield installer.buildx(buildxVer, dockerConfigHome);
core.info('📣 Buildx info'); core.info('📣 Buildx info');
yield exec.exec('docker', ['buildx', 'version']); yield exec.exec('docker', ['buildx', 'version']);
core.info('🔨 Creating a new builder instance...'); core.info('🔨 Creating a new builder instance...');
yield exec.exec('docker', [ let createArgs = [
'buildx', 'buildx',
'create', 'create',
'--use',
'--name', '--name',
`builder-${process.env.GITHUB_SHA}`, `builder-${process.env.GITHUB_SHA}`,
'--driver', '--driver',
'docker-container', driver
'--use' ];
]); if (driverOpt) {
createArgs.push('--driver-opt', driverOpt);
}
yield exec.exec('docker', createArgs);
core.info('🏃 Booting builder...'); core.info('🏃 Booting builder...');
yield exec.exec('docker', ['buildx', 'inspect', '--bootstrap']); yield exec.exec('docker', ['buildx', 'inspect', '--bootstrap']);
if (install) { if (install) {

@ -14,6 +14,8 @@ async function run(): Promise<void> {
} }
const buildxVer: string = core.getInput('buildx-version') || 'latest'; const buildxVer: string = core.getInput('buildx-version') || 'latest';
const driver: string = core.getInput('driver') || 'docker-container';
const driverOpt: string = core.getInput('driver-opt');
const install: boolean = /true/i.test(core.getInput('install')); const install: boolean = /true/i.test(core.getInput('install'));
const dockerConfigHome: string = process.env.DOCKER_CONFIG || path.join(os.homedir(), '.docker'); const dockerConfigHome: string = process.env.DOCKER_CONFIG || path.join(os.homedir(), '.docker');
await installer.buildx(buildxVer, dockerConfigHome); await installer.buildx(buildxVer, dockerConfigHome);
@ -22,15 +24,21 @@ async function run(): Promise<void> {
await exec.exec('docker', ['buildx', 'version']); await exec.exec('docker', ['buildx', 'version']);
core.info('🔨 Creating a new builder instance...'); core.info('🔨 Creating a new builder instance...');
await exec.exec('docker', [ let createArgs: Array<string> = [
'buildx', 'buildx',
'create', 'create',
'--use',
'--name', '--name',
`builder-${process.env.GITHUB_SHA}`, `builder-${process.env.GITHUB_SHA}`,
'--driver', '--driver',
'docker-container', driver
'--use' ];
]);
if (driverOpt) {
createArgs.push('--driver-opt', driverOpt);
}
await exec.exec('docker', createArgs);
core.info('🏃 Booting builder...'); core.info('🏃 Booting builder...');
await exec.exec('docker', ['buildx', 'inspect', '--bootstrap']); await exec.exec('docker', ['buildx', 'inspect', '--bootstrap']);

@ -48,8 +48,8 @@ Following inputs can be used as `step.with` keys
| Name | Type | Default | Description | | Name | Type | Default | Description |
|------------------|---------|-----------------------------|------------------------------------| |------------------|---------|-----------------------------|------------------------------------|
| `image` | String | `tonistiigi/binfmt:latest` | QEMU static binaries Docker image. Example: [`tonistiigi/binfmt:latest`](https://hub.docker.com/r/tonistiigi/binfmt/tags) | | `image` | String | `tonistiigi/binfmt:latest` | QEMU static binaries Docker image. e.g. [`tonistiigi/binfmt:latest`](https://hub.docker.com/r/tonistiigi/binfmt/tags) |
| `platforms` | String | `all` | Platforms to install. Example: `arm64,riscv64,arm` | | `platforms` | String | `all` | Platforms to install. e.g. `arm64,riscv64,arm` |
### outputs ### outputs

@ -8,11 +8,11 @@ branding:
inputs: inputs:
image: image:
description: 'QEMU static binaries Docker image. Example: tonistiigi/binfmt:latest' description: 'QEMU static binaries Docker image. e.g. tonistiigi/binfmt:latest'
default: 'tonistiigi/binfmt:latest' default: 'tonistiigi/binfmt:latest'
required: false required: false
platforms: platforms:
description: 'Platforms to install. Example: arm64,riscv64,arm' description: 'Platforms to install. e.g. arm64,riscv64,arm'
default: 'all' default: 'all'
required: false required: false