瀏覽代碼

resolve symlinks while making dockerfile path absolute

Signed-off-by: Nicolas De Loof <[email protected]>
Nicolas De Loof 9 月之前
父節點
當前提交
45bd60c33a
共有 1 個文件被更改,包括 9 次插入2 次删除
  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
 }