|
@@ -157,12 +157,14 @@ func runBuild(dockerCli *command.DockerCli, options buildOptions) error {
|
|
switch {
|
|
switch {
|
|
case specifiedContext == "-":
|
|
case specifiedContext == "-":
|
|
buildCtx, relDockerfile, err = build.GetContextFromReader(dockerCli.In(), options.dockerfileName)
|
|
buildCtx, relDockerfile, err = build.GetContextFromReader(dockerCli.In(), options.dockerfileName)
|
|
|
|
+ case isLocalDir(specifiedContext):
|
|
|
|
+ contextDir, relDockerfile, err = build.GetContextFromLocalDir(specifiedContext, options.dockerfileName)
|
|
case urlutil.IsGitURL(specifiedContext):
|
|
case urlutil.IsGitURL(specifiedContext):
|
|
tempDir, relDockerfile, err = build.GetContextFromGitURL(specifiedContext, options.dockerfileName)
|
|
tempDir, relDockerfile, err = build.GetContextFromGitURL(specifiedContext, options.dockerfileName)
|
|
case urlutil.IsURL(specifiedContext):
|
|
case urlutil.IsURL(specifiedContext):
|
|
buildCtx, relDockerfile, err = build.GetContextFromURL(progBuff, specifiedContext, options.dockerfileName)
|
|
buildCtx, relDockerfile, err = build.GetContextFromURL(progBuff, specifiedContext, options.dockerfileName)
|
|
default:
|
|
default:
|
|
- contextDir, relDockerfile, err = build.GetContextFromLocalDir(specifiedContext, options.dockerfileName)
|
|
|
|
|
|
+ return fmt.Errorf("unable to prepare context: path %q not found", specifiedContext)
|
|
}
|
|
}
|
|
|
|
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -357,6 +359,11 @@ func runBuild(dockerCli *command.DockerCli, options buildOptions) error {
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func isLocalDir(c string) bool {
|
|
|
|
+ _, err := os.Stat(c)
|
|
|
|
+ return err == nil
|
|
|
|
+}
|
|
|
|
+
|
|
type translatorFunc func(context.Context, reference.NamedTagged) (reference.Canonical, error)
|
|
type translatorFunc func(context.Context, reference.NamedTagged) (reference.Canonical, error)
|
|
|
|
|
|
// validateTag checks if the given image name can be resolved.
|
|
// validateTag checks if the given image name can be resolved.
|