From 8862dd5189484f768e7d713b0a30486ad8bd676e Mon Sep 17 00:00:00 2001 From: Patrick Seidensal Date: Tue, 4 Jul 2023 08:52:20 +0200 Subject: [PATCH] Add support for network --- file/file.go | 5 +++++ main.go | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/file/file.go b/file/file.go index 9f9cdc9..ba58ef4 100644 --- a/file/file.go +++ b/file/file.go @@ -40,6 +40,7 @@ type Dapperfile struct { NoContext bool MountSuffix string Target string + Network string } func Lookup(file string) (*Dapperfile, error) { @@ -253,6 +254,10 @@ func (d *Dapperfile) build(args []string, copy bool) (string, error) { buildArgs = append(buildArgs, "--build-arg", v) } + if d.Network != "" { + buildArgs = append(buildArgs, "--network", d.Network) + } + if d.NoContext { buildArgs = append(buildArgs, "-") buildArgs = append(buildArgs, args...) diff --git a/main.go b/main.go index fcc619b..0359087 100644 --- a/main.go +++ b/main.go @@ -97,6 +97,10 @@ func main() { Name: "target", Usage: "The multistage build target to use", }, + cli.StringFlag{ + Name: "network", + Usage: "The network to use for the build container", + }, } app.Action = func(c *cli.Context) { exit(run(c)) @@ -131,6 +135,7 @@ func run(c *cli.Context) error { dapperFile.NoContext = c.Bool("no-context") dapperFile.MountSuffix = c.String("mount-suffix") dapperFile.Target = c.String("target") + dapperFile.Network = c.String("network") if shell { return dapperFile.Shell(c.Args())