Skip to content

Commit

Permalink
Merge pull request docker#83 from tonistiigi/relative-dockerfile-path
Browse files Browse the repository at this point in the history
bake: make dockerfile relative to context
  • Loading branch information
tiborvass authored May 24, 2019
2 parents 4e61674 + f1fd9a2 commit 0eb2df5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions bake/bake.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -394,3 +400,7 @@ func removeDupes(s []string) []string {
}
return s[:i]
}

func isRemoteResource(str string) bool {
return urlutil.IsGitURL(str) || urlutil.IsURL(str)
}
2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0eb2df5

Please sign in to comment.