From ae7b8735826361dd79edb69c3c4eb4c50ad5f68d Mon Sep 17 00:00:00 2001 From: Jonas Reetz Date: Thu, 1 Sep 2022 10:56:17 +0200 Subject: [PATCH] Pass path to docker build command - changing the working dir will get us in problems when containers are build parallel --- pkg/dockerimage/build.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pkg/dockerimage/build.go b/pkg/dockerimage/build.go index 35236e3..a0baf9b 100644 --- a/pkg/dockerimage/build.go +++ b/pkg/dockerimage/build.go @@ -1,17 +1,13 @@ package dockerimage -import "os" +import "path/filepath" // BuildFromContainerfile builds a Container image from a Containerfile. // Invokes docker via CLI since Docker's dependencies and API are beyond brittle. func BuildFromContainerfile(path string, tag string) error { - - dir, _ := os.Getwd() - os.Chdir(path) - defer os.Chdir(dir) // Normally you would want to use a Golang API here. // Since the Docker API is a very thin shim, badly documented // and talking to Dockerd or Buildkit has a lot of quirks // just call the binary here and be done with it. - return executeDockerCommand("build", "-f", "Containerfile", ".", "-t", tag) + return executeDockerCommand("build", "-f", filepath.Join(path, "Containerfile"), path, "-t", tag) }