From f1fd9a274b6f6ab5071bef392f26885b582c4834 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Fri, 24 May 2019 15:23:16 -0700 Subject: [PATCH] bake: make dockerfile relative to context Signed-off-by: Tonis Tiigi --- bake/bake.go | 10 ++++++++++ vendor/modules.txt | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/bake/bake.go b/bake/bake.go index fd936593..4cebeab2 100644 --- a/bake/bake.go +++ b/bake/bake.go @@ -4,10 +4,12 @@ import ( "context" "io/ioutil" "os" + "path" "strings" "github.com/docker/buildx/build" "github.com/docker/buildx/util/platformutil" + "github.com/docker/docker/pkg/urlutil" "github.com/moby/buildkit/session/auth/authprovider" "github.com/pkg/errors" ) @@ -275,6 +277,10 @@ func toBuildOpt(t Target) (*build.Options, error) { dockerfilePath = *t.Dockerfile } + if !isRemoteResource(contextPath) && !path.IsAbs(dockerfilePath) { + dockerfilePath = path.Join(contextPath, dockerfilePath) + } + bo := &build.Options{ Inputs: build.Inputs{ ContextPath: contextPath, @@ -394,3 +400,7 @@ func removeDupes(s []string) []string { } return s[:i] } + +func isRemoteResource(str string) bool { + return urlutil.IsGitURL(str) || urlutil.IsURL(str) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index dcc135e5..113a2a96 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -151,8 +151,8 @@ github.com/docker/distribution/registry/storage/cache/memory github.com/docker/distribution/uuid github.com/docker/distribution/metrics # github.com/docker/docker v1.14.0-0.20190410063227-3998dffb806f3887f804b813069f59bc14a7f3c1 -github.com/docker/docker/client github.com/docker/docker/pkg/urlutil +github.com/docker/docker/client github.com/docker/docker/api/types github.com/docker/docker/api/types/container github.com/docker/docker/api/types/network