@@ -51,6 +51,7 @@ struct AWSLambdaPackager: CommandPlugin {
5151 toolsProvider: { name in try context. tool ( named: name) . path } ,
5252 outputDirectory: configuration. outputDirectory,
5353 baseImage: configuration. baseDockerImage,
54+ disableDockerImageUpdate: configuration. disableDockerImageUpdate,
5455 buildConfiguration: configuration. buildConfiguration,
5556 verboseLogging: configuration. verboseLogging
5657 )
@@ -77,6 +78,7 @@ struct AWSLambdaPackager: CommandPlugin {
7778 toolsProvider: ( String ) throws -> Path ,
7879 outputDirectory: Path ,
7980 baseImage: String ,
81+ disableDockerImageUpdate: Bool ,
8082 buildConfiguration: PackageManager . BuildConfiguration ,
8183 verboseLogging: Bool
8284 ) throws -> [ LambdaProduct : Path ] {
@@ -86,13 +88,15 @@ struct AWSLambdaPackager: CommandPlugin {
8688 print ( " building \" \( packageIdentity) \" in docker " )
8789 print ( " ------------------------------------------------------------------------- " )
8890
89- // update the underlying docker image, if necessary
90- print ( " updating \" \( baseImage) \" docker image " )
91- try self . execute (
92- executable: dockerToolPath,
93- arguments: [ " pull " , baseImage] ,
94- logLevel: . output
95- )
91+ if !disableDockerImageUpdate {
92+ // update the underlying docker image, if necessary
93+ print ( " updating \" \( baseImage) \" docker image " )
94+ try self . execute (
95+ executable: dockerToolPath,
96+ arguments: [ " pull " , baseImage] ,
97+ logLevel: . output
98+ )
99+ }
96100
97101 // get the build output path
98102 let buildOutputPathCommand = " swift build -c \( buildConfiguration. rawValue) --show-bin-path "
@@ -290,6 +294,7 @@ private struct Configuration: CustomStringConvertible {
290294 public let buildConfiguration : PackageManager . BuildConfiguration
291295 public let verboseLogging : Bool
292296 public let baseDockerImage : String
297+ public let disableDockerImageUpdate : Bool
293298
294299 public init (
295300 context: PluginContext ,
@@ -302,6 +307,7 @@ private struct Configuration: CustomStringConvertible {
302307 let configurationArgument = argumentExtractor. extractOption ( named: " configuration " )
303308 let swiftVersionArgument = argumentExtractor. extractOption ( named: " swift-version " )
304309 let baseDockerImageArgument = argumentExtractor. extractOption ( named: " base-docker-image " )
310+ let disableDockerImageUpdateArgument = argumentExtractor. extractFlag ( named: " disable-docker-image-update " ) > 0
305311
306312 self . verboseLogging = verboseArgument
307313
@@ -345,6 +351,8 @@ private struct Configuration: CustomStringConvertible {
345351 let swiftVersion = swiftVersionArgument. first ?? . none // undefined version will yield the latest docker image
346352 self . baseDockerImage = baseDockerImageArgument. first ?? " swift: \( swiftVersion. map { $0 + " - " } ?? " " ) amazonlinux2 "
347353
354+ self . disableDockerImageUpdate = disableDockerImageUpdateArgument
355+
348356 if self . verboseLogging {
349357 print ( " ------------------------------------------------------------------------- " )
350358 print ( " configuration " )
@@ -360,6 +368,7 @@ private struct Configuration: CustomStringConvertible {
360368 products: \( self . products. map ( \. name) )
361369 buildConfiguration: \( self . buildConfiguration)
362370 baseDockerImage: \( self . baseDockerImage)
371+ disableDockerImageUpdate: \( self . disableDockerImageUpdate)
363372 }
364373 """
365374 }
0 commit comments