Преглед изворни кода

use Dockerfile directly when path is absolute otherwise join it with Context path

Signed-off-by: Guillaume Lours <[email protected]>
Guillaume Lours пре 4 година
родитељ
комит
413f46ade0
1 измењених фајлова са 9 додато и 1 уклоњено
  1. 9 1
      pkg/compose/build.go

+ 9 - 1
pkg/compose/build.go

@@ -20,6 +20,7 @@ import (
 	"context"
 	"fmt"
 	"os"
+	"path"
 	"path/filepath"
 
 	"github.com/compose-spec/compose-go/types"
@@ -246,7 +247,7 @@ func (s *composeService) toBuildOptions(project *types.Project, service types.Se
 	return build.Options{
 		Inputs: build.Inputs{
 			ContextPath:    service.Build.Context,
-			DockerfilePath: filepath.Join(service.Build.Context, service.Build.Dockerfile),
+			DockerfilePath: dockerFilePath(service.Build.Context, service.Build.Dockerfile),
 		},
 		BuildArgs:   buildArgs,
 		Tags:        tags,
@@ -285,3 +286,10 @@ func mergeArgs(m ...types.Mapping) types.Mapping {
 	}
 	return merged
 }
+
+func dockerFilePath(context string, dockerfile string) string {
+	if path.IsAbs(dockerfile) {
+		return dockerfile
+	}
+	return filepath.Join(context, dockerfile)
+}