Browse Source

resolve symlinks while making dockerfile path absolute

Signed-off-by: Nicolas De Loof <[email protected]>
Nicolas De Loof 6 months ago
parent
commit
45bd60c33a
1 changed files with 9 additions and 2 deletions
  1. 9 2
      pkg/compose/build_bake.go

+ 9 - 2
pkg/compose/build_bake.go

@@ -420,8 +420,15 @@ func dockerFilePath(ctxName string, dockerfile string) string {
 	if dockerfile == "" {
 		return ""
 	}
-	if urlutil.IsGitURL(ctxName) || filepath.IsAbs(dockerfile) {
+	if urlutil.IsGitURL(ctxName) {
 		return dockerfile
 	}
-	return filepath.Join(ctxName, dockerfile)
+	if !filepath.IsAbs(dockerfile) {
+		dockerfile = filepath.Join(ctxName, dockerfile)
+	}
+	symlinks, err := filepath.EvalSymlinks(dockerfile)
+	if err == nil {
+		return symlinks
+	}
+	return dockerfile
 }