Skip to content
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

Merged
merged 1 commit into from
Dec 20, 2019

Conversation

rohanKanojia
Copy link
Member

Fix #544

Copy link
Collaborator

@rhuss rhuss left a 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 ?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really > 2 ? Not > 1 ?

Copy link
Collaborator

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.

Copy link
Collaborator

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)

Copy link
Member Author

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

if (userParts.length > 2) {
DockerFileKeyword.USER.addTo(b, "root");
}
DockerFileKeyword.ADD.addTo(b, " --chown="
Copy link
Collaborator

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.

Copy link
Collaborator

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) ?

Copy link
Member Author

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

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks !

Copy link
Collaborator

@rhuss rhuss left a 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.

@rhuss rhuss merged commit 96683f4 into fabric8io:master Dec 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Avoiding chown to reduce the image size
2 participants