From 4b1297ec71f397f77be2a983f074e001f246a433 Mon Sep 17 00:00:00 2001 From: Nicolas De Loof Date: Fri, 19 Mar 2021 10:10:35 +0100 Subject: [PATCH] Support build.context with git URLs Signed-off-by: Nicolas De Loof --- local/compose/build.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/local/compose/build.go b/local/compose/build.go index af19e0a44..56cafd701 100644 --- a/local/compose/build.go +++ b/local/compose/build.go @@ -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,