From ae6b5828ce0cee380267fb9060695bc3ae40e25b Mon Sep 17 00:00:00 2001 From: John Howard Date: Mon, 30 Jul 2018 12:49:33 -0700 Subject: [PATCH] LCOW: Ensure platform is populated on COPY/ADD Signed-off-by: John Howard --- builder/dockerfile/copy.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/builder/dockerfile/copy.go b/builder/dockerfile/copy.go index 74e245bdc4..0e8071258f 100644 --- a/builder/dockerfile/copy.go +++ b/builder/dockerfile/copy.go @@ -82,13 +82,28 @@ type copier struct { } func copierFromDispatchRequest(req dispatchRequest, download sourceDownloader, imageSource *imageMount) copier { + platform := req.builder.platform + if platform == nil { + // May be nil if not explicitly set in API/dockerfile + platform = &specs.Platform{} + } + if platform.OS == "" { + // Default to the dispatch requests operating system if not explicit in API/dockerfile + platform.OS = req.state.operatingSystem + } + if platform.OS == "" { + // This is a failsafe just in case. Shouldn't be hit. + platform.OS = runtime.GOOS + } + return copier{ source: req.source, pathCache: req.builder.pathCache, download: download, imageSource: imageSource, - platform: req.builder.platform, + platform: platform, } + } func (o *copier) createCopyInstruction(args []string, cmdName string) (copyInstruction, error) {