From f73df6e1f0a27f9d570d0682269279fd68172014 Mon Sep 17 00:00:00 2001 From: Nicolas De Loof Date: Wed, 28 May 2025 11:43:25 +0200 Subject: [PATCH] resolve symlinks while making dockerfile path absolute Signed-off-by: Nicolas De Loof --- pkg/compose/build_bake.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/compose/build_bake.go b/pkg/compose/build_bake.go index 3591900e06c..ea63fe49200 100644 --- a/pkg/compose/build_bake.go +++ b/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 }