mirror of
https://github.com/docker/build-push-action.git
synced 2024-11-23 19:39:03 +00:00
Merge pull request #555 from crazy-max/fix-add-host
Fix add-hosts context
This commit is contained in:
commit
7f9d37fa54
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@ -416,7 +416,7 @@ jobs:
|
|||||||
if: always()
|
if: always()
|
||||||
uses: crazy-max/ghaction-dump-context@v1
|
uses: crazy-max/ghaction-dump-context@v1
|
||||||
|
|
||||||
addhost:
|
add-hosts:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
@ -432,7 +432,7 @@ jobs:
|
|||||||
context: ./test
|
context: ./test
|
||||||
file: ./test/addhost.Dockerfile
|
file: ./test/addhost.Dockerfile
|
||||||
tags: name/app:latest
|
tags: name/app:latest
|
||||||
add-host: |
|
add-hosts: |
|
||||||
docker:10.180.0.1
|
docker:10.180.0.1
|
||||||
foo:10.0.0.1
|
foo:10.0.0.1
|
||||||
-
|
-
|
||||||
|
@ -199,7 +199,7 @@ Following inputs can be used as `step.with` keys
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
|---------------------|----------|------------------------------------|
|
|---------------------|----------|------------------------------------|
|
||||||
| `add-host` | List/CSV | Add a [custom 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`) |
|
| `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`) |
|
| `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) |
|
| `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 |
|
||||||
|
@ -446,6 +446,7 @@ ccc`],
|
|||||||
['context', '.'],
|
['context', '.'],
|
||||||
['tag', 'localhost:5000/name/app:latest'],
|
['tag', 'localhost:5000/name/app:latest'],
|
||||||
['file', './test/Dockerfile'],
|
['file', './test/Dockerfile'],
|
||||||
|
['add-hosts', 'docker:10.180.0.1,foo:10.0.0.1'],
|
||||||
['network', 'host'],
|
['network', 'host'],
|
||||||
['load', 'false'],
|
['load', 'false'],
|
||||||
['no-cache', 'false'],
|
['no-cache', 'false'],
|
||||||
@ -455,6 +456,8 @@ ccc`],
|
|||||||
[
|
[
|
||||||
'buildx',
|
'buildx',
|
||||||
'build',
|
'build',
|
||||||
|
'--add-host', 'docker:10.180.0.1',
|
||||||
|
'--add-host', 'foo:10.0.0.1',
|
||||||
'--file', './test/Dockerfile',
|
'--file', './test/Dockerfile',
|
||||||
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
||||||
'--metadata-file', '/tmp/.docker-build-push-jest/metadata-file',
|
'--metadata-file', '/tmp/.docker-build-push-jest/metadata-file',
|
||||||
@ -469,7 +472,7 @@ ccc`],
|
|||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['context', '.'],
|
['context', '.'],
|
||||||
['file', './test/Dockerfile'],
|
['file', './test/Dockerfile'],
|
||||||
['add-host', 'docker:10.180.0.1'],
|
['add-hosts', 'docker:10.180.0.1\nfoo:10.0.0.1'],
|
||||||
['cgroup-parent', 'foo'],
|
['cgroup-parent', 'foo'],
|
||||||
['shm-size', '2g'],
|
['shm-size', '2g'],
|
||||||
['ulimit', `nofile=1024:1024
|
['ulimit', `nofile=1024:1024
|
||||||
@ -483,6 +486,7 @@ nproc=3`],
|
|||||||
'buildx',
|
'buildx',
|
||||||
'build',
|
'build',
|
||||||
'--add-host', 'docker:10.180.0.1',
|
'--add-host', 'docker:10.180.0.1',
|
||||||
|
'--add-host', 'foo:10.0.0.1',
|
||||||
'--cgroup-parent', 'foo',
|
'--cgroup-parent', 'foo',
|
||||||
'--file', './test/Dockerfile',
|
'--file', './test/Dockerfile',
|
||||||
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
||||||
|
@ -7,8 +7,8 @@ branding:
|
|||||||
color: 'blue'
|
color: 'blue'
|
||||||
|
|
||||||
inputs:
|
inputs:
|
||||||
add-host:
|
add-hosts:
|
||||||
description: "Add a custom host-to-IP mapping (e.g., docker:10.180.0.1)"
|
description: "List of a customs host-to-IP mapping (e.g., docker:10.180.0.1)"
|
||||||
required: false
|
required: false
|
||||||
allow:
|
allow:
|
||||||
description: "List of extra privileged entitlement (e.g., network.host,security.insecure)"
|
description: "List of extra privileged entitlement (e.g., network.host,security.insecure)"
|
||||||
|
8
dist/index.js
generated
vendored
8
dist/index.js
generated
vendored
@ -270,7 +270,7 @@ exports.tmpNameSync = tmpNameSync;
|
|||||||
function getInputs(defaultContext) {
|
function getInputs(defaultContext) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
return {
|
return {
|
||||||
addHost: yield getInputList('add-host'),
|
addHosts: yield getInputList('add-hosts'),
|
||||||
allow: yield getInputList('allow'),
|
allow: yield getInputList('allow'),
|
||||||
buildArgs: yield getInputList('build-args', true),
|
buildArgs: yield getInputList('build-args', true),
|
||||||
builder: core.getInput('builder'),
|
builder: core.getInput('builder'),
|
||||||
@ -312,9 +312,9 @@ exports.getArgs = getArgs;
|
|||||||
function getBuildArgs(inputs, defaultContext, buildxVersion) {
|
function getBuildArgs(inputs, defaultContext, buildxVersion) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let args = ['build'];
|
let args = ['build'];
|
||||||
if (inputs.addHost.length > 0) {
|
yield exports.asyncForEach(inputs.addHosts, (addHost) => __awaiter(this, void 0, void 0, function* () {
|
||||||
args.push('--add-host', inputs.addHost.join(','));
|
args.push('--add-host', addHost);
|
||||||
}
|
}));
|
||||||
if (inputs.allow.length > 0) {
|
if (inputs.allow.length > 0) {
|
||||||
args.push('--allow', inputs.allow.join(','));
|
args.push('--allow', inputs.allow.join(','));
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ import * as handlebars from 'handlebars';
|
|||||||
let _defaultContext, _tmpDir: string;
|
let _defaultContext, _tmpDir: string;
|
||||||
|
|
||||||
export interface Inputs {
|
export interface Inputs {
|
||||||
addHost: string[];
|
addHosts: string[];
|
||||||
allow: string[];
|
allow: string[];
|
||||||
buildArgs: string[];
|
buildArgs: string[];
|
||||||
builder: string;
|
builder: string;
|
||||||
@ -68,7 +68,7 @@ export function tmpNameSync(options?: tmp.TmpNameOptions): string {
|
|||||||
|
|
||||||
export async function getInputs(defaultContext: string): Promise<Inputs> {
|
export async function getInputs(defaultContext: string): Promise<Inputs> {
|
||||||
return {
|
return {
|
||||||
addHost: await getInputList('add-host'),
|
addHosts: await getInputList('add-hosts'),
|
||||||
allow: await getInputList('allow'),
|
allow: await getInputList('allow'),
|
||||||
buildArgs: await getInputList('build-args', true),
|
buildArgs: await getInputList('build-args', true),
|
||||||
builder: core.getInput('builder'),
|
builder: core.getInput('builder'),
|
||||||
@ -106,9 +106,9 @@ export async function getArgs(inputs: Inputs, defaultContext: string, buildxVers
|
|||||||
|
|
||||||
async function getBuildArgs(inputs: Inputs, defaultContext: string, buildxVersion: string): Promise<Array<string>> {
|
async function getBuildArgs(inputs: Inputs, defaultContext: string, buildxVersion: string): Promise<Array<string>> {
|
||||||
let args: Array<string> = ['build'];
|
let args: Array<string> = ['build'];
|
||||||
if (inputs.addHost.length > 0) {
|
await asyncForEach(inputs.addHosts, async addHost => {
|
||||||
args.push('--add-host', inputs.addHost.join(','));
|
args.push('--add-host', addHost);
|
||||||
}
|
});
|
||||||
if (inputs.allow.length > 0) {
|
if (inputs.allow.length > 0) {
|
||||||
args.push('--allow', inputs.allow.join(','));
|
args.push('--allow', inputs.allow.join(','));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user