Merge pull request #3675 from tonistiigi/policy-filename-fix

build: normalize policy env filename default
This commit is contained in:
CrazyMax
2026-02-27 15:33:02 +01:00
committed by GitHub
+9 -2
View File
@@ -7,7 +7,6 @@ import (
"io"
"maps"
"os"
"path"
"path/filepath"
"slices"
"strconv"
@@ -603,7 +602,7 @@ func configureSourcePolicy(ctx context.Context, np *noderesolver.ResolvedNode, o
}
env.Args[k] = &v
}
env.Filename = path.Base(opt.Inputs.DockerfilePath)
env.Filename = policyEnvFilename(opt.Inputs)
env.Target = opt.Target
env.Labels = opt.Labels
@@ -695,6 +694,14 @@ func configureSourcePolicy(ctx context.Context, np *noderesolver.ResolvedNode, o
return defers, nil
}
func policyEnvFilename(inp Inputs) string {
base := filepath.Base(filepath.Clean(inp.DockerfilePath))
if base != "." && base != string(filepath.Separator) {
return base
}
return "Dockerfile"
}
func loadInputs(ctx context.Context, d *driver.DriverHandle, inp *Inputs, pw progress.Writer, target *client.SolveOpt) (func(), error) {
if inp.ContextPath == "" {
return nil, errors.New("please specify build context (e.g. \".\" for the current directory)")