Merge pull request #1439 from docker/build_url

Support build.context with git URLs
This commit is contained in:
Guillaume Tardif 2021-03-19 15:12:08 +01:00 committed by GitHub
commit 9ace15c9e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 3 deletions

View File

@ -19,6 +19,7 @@ package compose
import ( import (
"context" "context"
"fmt" "fmt"
"net/url"
"os" "os"
"path" "path"
"strings" "strings"
@ -190,11 +191,22 @@ func (s *composeService) toBuildOptions(service types.ServiceConfig, contextPath
plats = append(plats, p) plats = append(plats, p)
} }
return build.Options{ var input build.Inputs
Inputs: build.Inputs{ _, err := url.ParseRequestURI(service.Build.Context)
if err == nil {
input = build.Inputs{
ContextPath: service.Build.Context,
DockerfilePath: service.Build.Dockerfile,
}
} else {
input = build.Inputs{
ContextPath: path.Join(contextPath, service.Build.Context), ContextPath: path.Join(contextPath, service.Build.Context),
DockerfilePath: path.Join(contextPath, service.Build.Context, service.Build.Dockerfile), DockerfilePath: path.Join(contextPath, service.Build.Context, service.Build.Dockerfile),
}, }
}
return build.Options{
Inputs: input,
BuildArgs: flatten(mergeArgs(service.Build.Args, buildArgs)), BuildArgs: flatten(mergeArgs(service.Build.Args, buildArgs)),
Tags: tags, Tags: tags,
Target: service.Build.Target, Target: service.Build.Target,