mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-08-01 08:08:05 +08:00
bake: copy remote context contents to root
When resolving remote contexts locally in bake, then we need to ensure that we properly unpack the contents of that context to the root directory, instead of leaving it in the subdirectory. Otherwise, any files will be found in the wrong location. Along with this change, we also need a change to the dockerfile location lookup to ensure that it is found at the root instead of in the subdirectory. Signed-off-by: Justin Chadwell <me@jedevc.com>
This commit is contained in:
13
bake/bake.go
13
bake/bake.go
@@ -951,7 +951,12 @@ func updateContext(t *build.Inputs, inp *Input) {
|
||||
if build.IsRemoteURL(t.ContextPath) {
|
||||
return
|
||||
}
|
||||
st := llb.Scratch().File(llb.Copy(*inp.State, t.ContextPath, "/"), llb.WithCustomNamef("set context to %s", t.ContextPath))
|
||||
st := llb.Scratch().File(
|
||||
llb.Copy(*inp.State, t.ContextPath, "/", &llb.CopyInfo{
|
||||
CopyDirContentsOnly: true,
|
||||
}),
|
||||
llb.WithCustomNamef("set context to %s", t.ContextPath),
|
||||
)
|
||||
t.ContextState = &st
|
||||
}
|
||||
|
||||
@@ -1027,9 +1032,6 @@ func toBuildOpt(t *Target, inp *Input) (*build.Options, error) {
|
||||
if t.Dockerfile != nil {
|
||||
dockerfilePath = *t.Dockerfile
|
||||
}
|
||||
if !build.IsRemoteURL(contextPath) && !path.IsAbs(dockerfilePath) {
|
||||
dockerfilePath = path.Join(contextPath, dockerfilePath)
|
||||
}
|
||||
|
||||
bi := build.Inputs{
|
||||
ContextPath: contextPath,
|
||||
@@ -1040,6 +1042,9 @@ func toBuildOpt(t *Target, inp *Input) (*build.Options, error) {
|
||||
bi.DockerfileInline = *t.DockerfileInline
|
||||
}
|
||||
updateContext(&bi, inp)
|
||||
if !build.IsRemoteURL(bi.ContextPath) && bi.ContextState == nil && !path.IsAbs(bi.DockerfilePath) {
|
||||
bi.DockerfilePath = path.Join(bi.ContextPath, bi.DockerfilePath)
|
||||
}
|
||||
if strings.HasPrefix(bi.ContextPath, "cwd://") {
|
||||
bi.ContextPath = path.Clean(strings.TrimPrefix(bi.ContextPath, "cwd://"))
|
||||
}
|
||||
|
Reference in New Issue
Block a user