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
Allow REPO_DIR to be a non-existing folder by creating it and providing the user with permissions #976
Allow REPO_DIR to be a non-existing folder by creating it and providing the user with permissions #976
Conversation
repo2docker/buildpacks/base.py
Outdated
RUN if [ ! -d "${REPO_DIR}" ] \ | ||
; then \ | ||
mkdir -p "${REPO_DIR}" \ | ||
&& chown -R ${NB_USER}:${NB_USER} "${REPO_DIR}" \ |
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.
Perhaps we can remove -R
as it's an empty directory just created.
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, it probably doesn't magically do umask
or anything (though maybe we should think about that)...
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.
will wait to get any other feedback, it's a lot of coal to burn!
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.
FYI you can use something like /usr/bin/install -d <directory> -m <mode> -o <owner> -g <group>
to do everything in one go if you want, doesn't really matter though.
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, can we use this instead? if
in bash always makes me feel like I'm too dumb to make it work
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.
This PR as a whole LGTM, but let's adjust to this review comment and resolve the merge conflicts and we are good to go.
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.
Resolved it by applying my own suggestion, based on /usr/bin/install -d <directory> -m <mode> -o <owner> -g <group>
aef9939
to
59bea68
Compare
I applied a suggestion and rebased this PR on the main branch to get the test suite to run. I took a backup of the state before rebase in my fork's branch. |
59bea68
to
3f17058
Compare
3f17058
to
2f13af8
Compare
PR summary by Erik 2022-10-31
If users provide a REPO_DIR as a build arg to a folder that doesn't exist, the root user will create it but leave the non-root user without permissions to access it. This PR resolves that and adds a test to verify it by adding some
mkdir
andchown
statements.It includes basic refactoring of the Dockerfile to reduce the layers by coalescing ENV statements and making use of the recommended syntax with explicit
=
in ENV statements.It updates a comment to clarify how the test suite works.
Updated
This PR (originally attempted to try out some alternatives to #974 and (#975) now:
conftest.py
for providing extra arguments viaextra-args.yml
ENV
to the recommended=
syntax, replacing use of the "alternative" (space-based) syntax:ENV
calls to a single, multi-line directive