@@ -30,7 +30,7 @@ const AdditionalPackageBuildArg = "ADDITIONAL_PACKAGE"
30
30
31
31
// BuildImage construct Docker image from function parameters
32
32
// TODO: refactor signature to a struct to simplify the length of the method header
33
- func BuildImage (image string , handler string , functionName string , language string , nocache bool , squash bool , shrinkwrap bool , buildArgMap map [string ]string , buildOptions []string , tagFormat schema.BuildFormat , buildLabelMap map [string ]string , quietBuild bool , copyExtraPaths []string , remoteBuilder , payloadSecretPath string ) error {
33
+ func BuildImage (image string , handler string , functionName string , language string , nocache bool , squash bool , shrinkwrap bool , buildArgMap map [string ]string , buildOptions []string , tagFormat schema.BuildFormat , buildLabelMap map [string ]string , quietBuild bool , copyExtraPaths []string , remoteBuilder , payloadSecretPath string , forcePull bool ) error {
34
34
35
35
if stack .IsValidTemplate (language ) {
36
36
pathToTemplateYAML := fmt .Sprintf ("./template/%s/template.yml" , language )
@@ -127,6 +127,7 @@ func BuildImage(image string, handler string, functionName string, language stri
127
127
BuildArgMap : buildArgMap ,
128
128
BuildOptPackages : buildOptPackages ,
129
129
BuildLabelMap : buildLabelMap ,
130
+ ForcePull : forcePull ,
130
131
}
131
132
132
133
command , args := getDockerBuildCommand (dockerBuildVal )
@@ -135,6 +136,7 @@ func BuildImage(image string, handler string, functionName string, language stri
135
136
if mountSSH {
136
137
envs = append (envs , "DOCKER_BUILDKIT=1" )
137
138
}
139
+ log .Printf ("Build flags: %+v\n " , args )
138
140
139
141
task := v2execute.ExecTask {
140
142
Cwd : tempPath ,
@@ -260,7 +262,7 @@ func hashFolder(contextPath string) (string, error) {
260
262
}
261
263
262
264
func getDockerBuildCommand (build dockerBuild ) (string , []string ) {
263
- flagSlice := buildFlagSlice (build .NoCache , build .Squash , build .HTTPProxy , build .HTTPSProxy , build .BuildArgMap , build .BuildOptPackages , build .BuildLabelMap )
265
+ flagSlice := buildFlagSlice (build .NoCache , build .Squash , build .HTTPProxy , build .HTTPSProxy , build .BuildArgMap , build .BuildOptPackages , build .BuildLabelMap , build . ForcePull )
264
266
args := []string {"build" }
265
267
args = append (args , flagSlice ... )
266
268
@@ -287,6 +289,8 @@ type dockerBuild struct {
287
289
288
290
// ExtraTags for published images like :latest
289
291
ExtraTags []string
292
+
293
+ ForcePull bool
290
294
}
291
295
292
296
var defaultDirPermissions os.FileMode = 0700
@@ -409,7 +413,7 @@ func pathInScope(path string, scope string) (string, error) {
409
413
return "" , fmt .Errorf ("forbidden path appears to be outside of the build context: %s (%s)" , path , abs )
410
414
}
411
415
412
- func buildFlagSlice (nocache bool , squash bool , httpProxy string , httpsProxy string , buildArgMap map [string ]string , buildOptionPackages []string , buildLabelMap map [string ]string ) []string {
416
+ func buildFlagSlice (nocache bool , squash bool , httpProxy string , httpsProxy string , buildArgMap map [string ]string , buildOptionPackages []string , buildLabelMap map [string ]string , forcePull bool ) []string {
413
417
414
418
var spaceSafeBuildFlags []string
415
419
@@ -445,6 +449,10 @@ func buildFlagSlice(nocache bool, squash bool, httpProxy string, httpsProxy stri
445
449
spaceSafeBuildFlags = append (spaceSafeBuildFlags , "--label" , fmt .Sprintf ("%s=%s" , k , v ))
446
450
}
447
451
452
+ if forcePull {
453
+ spaceSafeBuildFlags = append (spaceSafeBuildFlags , "--pull" )
454
+ }
455
+
448
456
return spaceSafeBuildFlags
449
457
}
450
458
0 commit comments