Skip to content

Commit

Permalink
Merge pull request #4 from apppackio/transparent-build-args
Browse files Browse the repository at this point in the history
Pass all config vars as build args to Docker
  • Loading branch information
ipmb authored Jul 10, 2023
2 parents 4e9bc5b + 39fcdd7 commit f96edcb
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions builder/containers/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,21 @@ func (c *Containers) DeleteContainer(containerID string) error {

func (c *Containers) BuildImage(dockerfile string, config *BuildConfig) error {
c.Log().Debug().Str("image", config.Image).Msg("building Docker image")
cmd := exec.Command(
"docker", "buildx", "build",
dockerArgs := []string{
"buildx",
"build",
"--tag", config.Image,
"--progress", "plain",
"--cache-to", fmt.Sprintf("type=local,dest=%s", config.CacheDir),
"--cache-from", fmt.Sprintf("type=local,src=%s", config.CacheDir),
"--file", dockerfile,
"--load",
".",
)
}
for k, v := range config.Env {
dockerArgs = append(dockerArgs, "--build-arg", fmt.Sprintf("%s=%s", k, v))
}
dockerArgs = append(dockerArgs, ".")
cmd := exec.Command("docker", dockerArgs...)
out := io.MultiWriter(os.Stdout, config.LogFile)
cmd.Stdout = out
cmd.Stderr = out
Expand Down

0 comments on commit f96edcb

Please sign in to comment.