-
Notifications
You must be signed in to change notification settings - Fork 642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #544: Avoiding chown to reduce the image size #1301
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me (except with some minor change request), but I wonder whether we should do an API detection like elsewhere, because --chown
might not be available for every API version.
However, if --chown
has been added since a long time (>1-2 years), then I think we could just do it unconditionally. But then we should mark this clearly in the changelog.
for (CopyEntry entry : copyEntries) { | ||
String dest = (basedir.equals("/") ? "" : basedir) + "/" + entry.destination; | ||
DockerFileKeyword.ADD.addTo(b, " --chown=" | ||
+ (userParts.length > 2 ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really > 2 ? Not > 1 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm asking because I don't see userPart[2]
used anywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, for backwards compatibility we shoudl use userParts[2]
to switch to that user after the ADD
, like in the original code. (but we can mark that as deprecated, as its not really useful anymore IMO)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I might have missed this. Let me remove this and add a deprecation note to doc on next update
88174d8
to
2b65823
Compare
if (userParts.length > 2) { | ||
DockerFileKeyword.USER.addTo(b, "root"); | ||
} | ||
DockerFileKeyword.ADD.addTo(b, " --chown=" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we just keep the COPY
semnatics (instead of using ADD
which works slightly different). I.e. I would add the extra command for chown to addCopyEntries
and add an extra argument String ownerAndGroup
to addCopyEntries()
which can be either null
or "user:group"
. That way we can preserve the COPY
semantics.
i.e. use COPY --chown
instead of ADD --chown
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rohanKanojia I'd like to add this to the release. Do you think there is a chance to get this in for the next release (i.e. change from ADD
to COPY
) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, sorry. I was busy in last few weeks. Let me update this today
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks !
7363ce0
to
8a929e5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot. Looks good to me.
Fix #544