-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Create intermediate directories in COPY with correct uid and gid #2795
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
integration/dockerfiles/Dockerfile_test_add_chown_intermediate_dirs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM alpine@sha256:5ce5f501c457015c4b91f91a15ac69157d9b06f1a75cf9107bf2b62e0843983a | ||
# Create dev user and group, with id 1001 | ||
RUN yes | adduser -u 1001 dev | ||
|
||
ADD --chown=dev:dev context/foo /path/to/foo | ||
ADD --chown=dev:dev context/qux /path/to/qux | ||
ADD --chown=1001:1001 context/foo /path2/to/foo | ||
ADD --chown=1001:1001 context/qux /path2/to/qux | ||
|
||
USER dev | ||
|
||
# `mkdir` fails when `dev` does not own all of `/path{,2}/to{,/qux}` | ||
RUN mkdir /path/to/new_dir | ||
RUN mkdir /path/to/qux/new_dir | ||
RUN mkdir /path2/to/new_dir | ||
RUN mkdir /path2/to/qux/new_dir |
16 changes: 16 additions & 0 deletions
16
integration/dockerfiles/Dockerfile_test_copy_chown_intermediate_dirs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM alpine@sha256:5ce5f501c457015c4b91f91a15ac69157d9b06f1a75cf9107bf2b62e0843983a | ||
# Create dev user and group, with id 1001 | ||
RUN yes | adduser -u 1001 dev | ||
|
||
COPY --chown=dev:dev context/foo /path/to/foo | ||
COPY --chown=dev:dev context/qux /path/to/qux | ||
COPY --chown=1001:1001 context/foo /path2/to/foo | ||
COPY --chown=1001:1001 context/qux /path2/to/qux | ||
|
||
USER dev | ||
|
||
# `mkdir` fails when `dev` does not own all of `/path{,2}/to{,/qux}` | ||
RUN mkdir /path/to/new_dir | ||
RUN mkdir /path/to/qux/new_dir | ||
RUN mkdir /path2/to/new_dir | ||
RUN mkdir /path2/to/qux/new_dir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 understand that you included in the PR message about adding the test but it looks like this is not adding coverage for the
CreateFile
case with UID/GID :/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.
What might be valuable here is to add an integration test at https://github.com/GoogleContainerTools/kaniko/tree/main/integration/dockerfiles, with
COPY --chown= ...
and it would be very helpful so that we could verify the fix when comparing in the future release.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.
Yeah, you're right, it doesn't set UID/GID. I didn't know how to add that test :( I think I added this one to quickly be able to figure out how to create intermediate directories in the first place.
I'll add an integration test.