Skip to content

Commit

Permalink
Pass path to docker build command
Browse files Browse the repository at this point in the history
 - changing the working dir will get us in problems when containers are build parallel
  • Loading branch information
joreetz-otto authored and AndreasBergmeier6176 committed Sep 1, 2022
1 parent 07d138e commit ae7b873
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions pkg/dockerimage/build.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit ae7b873

Please sign in to comment.