Define a build context for backends

This commit is contained in:
Ettore Di Giacinto
2021-01-18 11:05:46 +01:00
parent 429e9757db
commit 43b0b11028
3 changed files with 12 additions and 2 deletions

View File

@@ -46,8 +46,12 @@ func (*SimpleDocker) BuildImage(opts compiler.CompilerBackendOptions) error {
name := opts.ImageName
path := opts.SourcePath
dockerfileName := opts.DockerFileName
context := opts.Context
buildarg := []string{"build", "-f", dockerfileName, "-t", name, "."}
if context == "" {
context = "."
}
buildarg := []string{"build", "-f", dockerfileName, "-t", name, context}
Debug(":whale2: Building image " + name)
cmd := exec.Command("docker", buildarg...)

View File

@@ -35,9 +35,14 @@ func NewSimpleImgBackend() compiler.CompilerBackend {
func (*SimpleImg) BuildImage(opts compiler.CompilerBackendOptions) error {
name := opts.ImageName
path := opts.SourcePath
context := opts.Context
if context == "" {
context = "."
}
dockerfileName := opts.DockerFileName
buildarg := []string{"build", "-f", dockerfileName, "-t", name, "."}
buildarg := []string{"build", "-f", dockerfileName, "-t", name, context}
Spinner(22)
defer SpinnerStop()
Debug(":tea: Building image " + name)

View File

@@ -42,6 +42,7 @@ type CompilerBackendOptions struct {
SourcePath string
DockerFileName string
Destination string
Context string
}
type CompilerOptions struct {