Support build.context with git URLs

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2021-03-19 10:10:35 +01:00
parent 3366131096
commit 4b1297ec71
No known key found for this signature in database
GPG Key ID: 9858809D6F8F6E7E
1 changed files with 15 additions and 3 deletions

View File

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