LCOW: Ensure platform is populated on COPY/ADD#37563
Conversation
Signed-off-by: John Howard <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #37563 +/- ##
=========================================
Coverage ? 35.62%
=========================================
Files ? 610
Lines ? 44903
Branches ? 0
=========================================
Hits ? 15996
Misses ? 26705
Partials ? 2202 |
thaJeztah
left a comment
There was a problem hiding this comment.
Left a comment; I'm not super-familiar with this code, so my comment is just from digging a bit
| download: download, | ||
| imageSource: imageSource, | ||
| platform: req.builder.platform, | ||
| platform: platform, |
There was a problem hiding this comment.
I notice that after the copier is created, builder.performCopy() is called;
moby/builder/dockerfile/dispatchers.go
Lines 123 to 131 in 492545e
Looking at that function, that seems to use req.builder.platform, not the value set on the copier.
moby/builder/dockerfile/internals.go
Line 172 in f0585d0
The value is actually used, but only for path separators, and not persisted in the copy instruction itself;
moby/builder/dockerfile/copy.go
Lines 98 to 106 in b711437
Should a property beaded to copyInstruction, and set to this value?
There was a problem hiding this comment.
@thaJeztah I'll defer to @tonistiigi here. I don't think it matters, but I don't own the builder code. Just fixing a bug...
There was a problem hiding this comment.
The platform in
moby/builder/dockerfile/internals.go
Line 172 in f0585d0
--from not for the current instruction so may be different.
|
ping @simonferquel PTAL as well |
Signed-off-by: John Howard [email protected]
Fixes #37561, and internal VSO bug 17531561.
The copier object constructor is only using the API/dockerfile requested platform (OS) and ignoring the implicit operating system in the builder state. Hence, on LCOW (see linked issue this fixes) where no platform is passed in the API, a docker build goes down the route of assuming it's Windows paths.
@tonistiigi, @johnstep PTAL. @jterry75 FYI
Note there is an alternate fix I came up with initially. Both fixes work, but I think this is cleaner having the correct OS set at the start of the COPY command as it comes in from the dispatcher. Alternate can be found at 3bf17fc.
Using the same dockerfile from the linked issue, results with this fix (it succeeds and /foo/bar/dockerfile is shown in step 4).