Skip to content

[Feat]: Dockerfile entrypoint.d #5177

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

Closed
djarbz opened this issue May 7, 2022 · 4 comments · Fixed by #5194
Closed

[Feat]: Dockerfile entrypoint.d #5177

djarbz opened this issue May 7, 2022 · 4 comments · Fixed by #5194
Labels
enhancement Some improvement that isn't a feature
Milestone

Comments

@djarbz
Copy link
Contributor

djarbz commented May 7, 2022

What is your suggestion?

Add logic to the entrypoint to load user provided entrypoint scripts.

Why do you want this feature?

This would allow for us to setup the workspace beyond the base image without maintaining individual images per purpose.
For example, we could call to install a language or runtime dependency, or even install code-server plugins.

Are there any workarounds to get this functionality today?

Manually run the scripts via the code-server terminal.

Are you interested in submitting a PR for this?

Possibly.

@djarbz djarbz added the enhancement Some improvement that isn't a feature label May 7, 2022
@jsjoeio
Copy link
Contributor

jsjoeio commented May 9, 2022

What are your thoughts on this @code-asher ?

@jsjoeio jsjoeio added this to the Backlog Candidates milestone May 9, 2022
@code-asher
Copy link
Member

code-asher commented May 10, 2022 via email

@djarbz
Copy link
Contributor Author

djarbz commented May 10, 2022

That is one way to do it, I'm slightly concerned about the following bit of code.
I'm not 100% sure on the ramifications of it and if it would need to be ran prior to my scripts or if running it afterwards is ok?

# We do this first to ensure sudo works below when renaming the user.
# Otherwise the current container UID may not exist in the passwd database.
eval "$(fixuid -q)"

if [ "${DOCKER_USER-}" ]; then
  USER="$DOCKER_USER"
  if [ "$DOCKER_USER" != "$(whoami)" ]; then
    echo "$DOCKER_USER ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers.d/nopasswd > /dev/null
    # Unfortunately we cannot change $HOME as we cannot move any bind mounts
    # nor can we bind mount $HOME into a new home as that requires a privileged container.
    sudo usermod --login "$DOCKER_USER" coder
    sudo groupmod -n "$DOCKER_USER" coder

    sudo sed -i "/coder/d" /etc/sudoers.d/nopasswd
  fi
fi

Currently I build a custom image that inserts the following code after this section.

# Allow users to have scripts run on container startup to prepare workspace.
chmod u+x $HOME/entrypoint.d/*.sh
for f in $HOME/entrypoint.d/*.sh; do
  echo "Running Entrypoint: ${f}"
  bash "${f}"
done

@code-asher
Copy link
Member

code-asher commented May 11, 2022 via email

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 a pull request may close this issue.

3 participants