Add build add-host

This commit is contained in:
recamshak 2019-12-11 09:33:26 +09:00
parent 4c09b80365
commit 17639d6cbf
2 changed files with 10 additions and 0 deletions

View File

@ -223,6 +223,11 @@ func main() {
Usage: "do not use cached intermediate containers",
EnvVar: "PLUGIN_NO_CACHE",
},
cli.StringSliceFlag{
Name: "add-host",
Usage: "additional host:IP mapping",
EnvVar: "PLUGIN_ADD_HOST",
},
}
if err := app.Run(os.Args); err != nil {
@ -257,6 +262,7 @@ func run(c *cli.Context) error {
Labels: c.StringSlice("custom-labels"),
LabelSchema: c.StringSlice("label-schema"),
NoCache: c.Bool("no-cache"),
AddHost: c.StringSlice("add-host"),
},
Daemon: docker.Daemon{
Registry: c.String("docker.registry"),

View File

@ -52,6 +52,7 @@ type (
LabelSchema []string // label-schema Label map
Labels []string // Label map
NoCache bool // Docker build no-cache
AddHost []string // Docker build add-host
}
// Plugin defines the Docker plugin parameters.
@ -215,6 +216,9 @@ func commandBuild(build Build) *exec.Cmd {
for _, arg := range build.Args {
args = append(args, "--build-arg", arg)
}
for _, host := range build.AddHost {
args = append(args, "--add-host", host)
}
if build.Target != "" {
args = append(args, "--target", build.Target)
}