Skip to content

Allow user Entrypoint scripts #5194

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 9 commits into from
May 11, 2022
Merged

Allow user Entrypoint scripts #5194

merged 9 commits into from
May 11, 2022

Conversation

djarbz
Copy link
Contributor

@djarbz djarbz commented May 11, 2022

Fixes #5177

I created an ENV for easy changing of the entrypoint.d location in case it is ever wanted/needed to move it out of the home directory. This also would allow for the end user to set an ENVIRONMENT variable to specify a custom mount path as the entrypoint code is dynamic.

@djarbz djarbz requested a review from a team May 11, 2022 17:01
Copy link
Member

@code-asher code-asher left a comment

Choose a reason for hiding this comment

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

Thank you!

@@ -42,6 +42,11 @@ RUN ARCH="$(dpkg --print-architecture)" && \
COPY ci/release-image/entrypoint.sh /usr/bin/entrypoint.sh
RUN --mount=from=packages,src=/tmp,dst=/tmp/packages dpkg -i /tmp/packages/code-server*$(dpkg --print-architecture).deb

# Allow users to have scripts run on container startup to prepare workspace.
# https://github.com/coder/code-server/issues/5177
ENV ENTRYPOINTD=${HOME}/entrypoint.d
Copy link
Member

Choose a reason for hiding this comment

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

Nice!

@jsjoeio
Copy link
Contributor

jsjoeio commented May 11, 2022

You'll want to run yarn fmt again to fix CI ICYDK.

@jsjoeio
Copy link
Contributor

jsjoeio commented May 11, 2022

Thank you for adding this! This is an awesome improvement! 🎉

@jsjoeio jsjoeio added the enhancement Some improvement that isn't a feature label May 11, 2022
bash "${f}"
done
if [ -d "${ENTRYPOINTD}" ]; then
for f in $(find "${ENTRYPOINTD}" -type f -executable); do
Copy link
Member

Choose a reason for hiding this comment

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

Ooo this is slick, I like it.

@djarbz
Copy link
Contributor Author

djarbz commented May 11, 2022

You'll want to run yarn fmt again to fix CI ICYDK.

So I did that, I think correctly, I don't have experience with npm and yarn.
Looks like it is still complaining about it?

Edit: scratch that, I committed the wrong stuff.

@code-asher
Copy link
Member

We should drop the commit that updates prettier and the lockfiles since those are unrelated changes and seem to be causing Trivy to freak out. 😆

@djarbz
Copy link
Contributor Author

djarbz commented May 11, 2022

We should drop the commit that updates prettier and the lockfiles since those are unrelated changes and seem to be causing Trivy to freak out. 😆

I'm with you on that, unfortunately I am anything but a git expert and I'm not quite sure what I need to do to drop that commit.

@code-asher
Copy link
Member

I think the easiest way is probably to do git revert 5ca347f36155ec731587c1ed8437bca332c76693 and then push the resulting commit.

Copy link
Member

@code-asher code-asher left a comment

Choose a reason for hiding this comment

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

🎉 🎉 🎉

Copy link
Contributor

@jsjoeio jsjoeio left a comment

Choose a reason for hiding this comment

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

@jsjoeio jsjoeio enabled auto-merge (squash) May 11, 2022 21:54
@codecov
Copy link

codecov bot commented May 11, 2022

Codecov Report

Merging #5194 (c724078) into main (dedd770) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #5194   +/-   ##
=======================================
  Coverage   71.73%   71.73%           
=======================================
  Files          30       30           
  Lines        1663     1663           
  Branches      367      367           
=======================================
  Hits         1193     1193           
  Misses        403      403           
  Partials       67       67           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dedd770...c724078. Read the comment docs.

@jsjoeio jsjoeio merged commit 5276e41 into coder:main May 11, 2022
@djarbz
Copy link
Contributor Author

djarbz commented May 11, 2022

Thanks for working with me on this one!

@jneuhauser
Copy link

I'm not sure if I'm using this enhancement correctly, but the following part in my Dockerfile created the entrypoint.d directory in / instead of /home/coder.

FROM codercom/code-server:latest
COPY entrypoint.d/* ${ENTRYPOINTD}/

For me there is not env HOME defined in the docker build process and therefore ENTRYPOINTD is always set to /entrypoint.d.

@djarbz
Copy link
Contributor Author

djarbz commented Oct 20, 2022

Interesting, I personally overwrite the directory to root anyways for my needs. I see that HOME is set inside the VSCode shell, but that may be an artifact from that particular shell.

As a fix, I might propose that we hard-code the path.
ENV ENTRYPOINTD=/home/coder/entrypoint.d

In your particular case, I would probably want it outside the home directory anyways in case an end user decides to bind mount the home dir.

@jneuhauser
Copy link

You are absolutely right that it would be better to hardcode it, but I would prefer /entrypoint.d so that mounting a volume/directory to /home/coder remains possible.

For me it was a bit confusing that it is defined like ENV ENTRYPOINTD=${HOME}/entrypoint.d.

So to not confuse users, I would suggest changing it to ENV ENTRYPOINTD=/entrypoint.d.

@code-asher
Copy link
Member

If you are in control of the Docker image could you just write your own RUN commands? My understanding was that entrypoint.d was specifically for end users who have no control over the image (thus you want it in a writable place that gets mounted). Quite possibly I am misunderstanding the use case though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Some improvement that isn't a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feat]: Dockerfile entrypoint.d
4 participants