Thanks to visit codestin.com
Credit goes to github.com

Skip to content

FIX: Ensure USER has permissions for chmod in Dockerfile #26

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

Merged
merged 2 commits into from
Jul 19, 2023

Conversation

matthewfeickert
Copy link
Member

Resolves #25

@matthewfeickert matthewfeickert requested a review from Carreau July 19, 2023 06:32
@matthewfeickert matthewfeickert self-assigned this Jul 19, 2023
@matthewfeickert
Copy link
Member Author

Tests are needed in general (c.f. Issue #15), but if people would like this in sooner to fix things then a simple local test is

$ docker build -f Dockerfile -t scientific-python/upload-nightly-action:debug .
$ docker run --rm -ti --env INPUT_ANACONDA_NIGHTLY_UPLOAD_TOKEN="fail" --env INPUT_ARTIFACTS_PATH="." scientific-python/upload-nightly-action:debug

which will run all the way through until it correctly errors on

anaconda --token "${ANACONDA_TOKEN}" upload \
--force \
--user "${ANACONDA_ORG}" \
"${INPUT_ARTIFACTS_PATH}"/*.whl

for not being able to upload.

RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
ENTRYPOINT [ "/usr/local/bin/_entrypoint.sh" ]
Copy link
Member

Choose a reason for hiding this comment

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

I read your PR description, but am still fuzzy on what is happening in these two lines. Maybe a comment would help?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure! I'll do that this evening when I get time.

Copy link
Member

Choose a reason for hiding this comment

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

I think the confusion is calling ours entrypoint as well; it really is the command we execute AFTER entrypoint, so we can just give it a logical name that describes what it does?

But, this is already way better, so we could merge this, perhaps with a note to explain the distinction between ENTRYPOINT and CMD.

I.e. we use entrypoint to set env variables, and the cmd does whatever action we wish to execute.

* For security reasons the default user in mambaorg/micromamba:1.4.9-bullseye-slim
  is non-root with uid 1000 (mambauser) but this requires the user
  permissions to be escalated to one with chmod powers. The simplest way
  to do this is to chown to mambauser on COPY.

* To ensure that the micromamba environment is setup correctly on entry
  fallback to the mambaorg/micromamba's base image ENTRYPOINT and set this
  action's /entrypoint.sh as CMD.
   - c.f. https://github.com/mamba-org/micromamba-docker/blob/604ebafb09543a3d852e437886f1c782f0367911/_entrypoint.sh
Dockerfile Outdated
Comment on lines 14 to 19
# The mambaorg/micromamba base image's entrypoint is
# /usr/local/bin/_entrypoint.sh which ensures the shell environment is
# correctly set for micromamba to be accessible by the given user.
# c.f. https://github.com/mamba-org/micromamba-docker/blob/604ebafb09543a3d852e437886f1c782f0367911/_entrypoint.sh
# Instead of replicating this, continue to use it as the ENTRYPOINT
# and then pass the action's entrypoint as CMD.
Copy link
Member Author

Choose a reason for hiding this comment

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

@stefanv Let me know if this is helpful or still opaque. I'm happy to revise this!

@matthewfeickert matthewfeickert requested a review from stefanv July 19, 2023 17:06
RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
ENTRYPOINT [ "/usr/local/bin/_entrypoint.sh" ]
Copy link
Member

Choose a reason for hiding this comment

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

I think the confusion is calling ours entrypoint as well; it really is the command we execute AFTER entrypoint, so we can just give it a logical name that describes what it does?

But, this is already way better, so we could merge this, perhaps with a note to explain the distinction between ENTRYPOINT and CMD.

I.e. we use entrypoint to set env variables, and the cmd does whatever action we wish to execute.

* As the action is relying on the mambaorg/micromamba container's
  entrypoint to setup the shell environment correctly let this be
  clearly the ENTRYPOINT and rename the action's entrypoint script to
  cmd.sh as it is being passed as CMD.
@matthewfeickert matthewfeickert requested a review from stefanv July 19, 2023 18:36
@stefanv stefanv merged commit 4792bc2 into scientific-python:main Jul 19, 2023
@stefanv
Copy link
Member

stefanv commented Jul 19, 2023

Thanks, @matthewfeickert!

@matthewfeickert matthewfeickert deleted the fix/fix-docker-build branch July 19, 2023 19:49
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.

Fix permissions given default user is non-root
3 participants