Skip to content

Commit

Permalink
ci-base-image: entrypoint hackery to make sure PATH gets set
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Jun 27, 2024
1 parent 1ff15b5 commit 2031626
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
8 changes: 7 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ RUN apt-get clean

RUN echo "runner ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/allow-runner-sudo
RUN echo 'APT::Get::Assume-Yes "1";' > /etc/apt/apt.conf.d/75assume-yes
RUN echo 'export PATH="$PATH:$HOME/.local/bin"' >> /home/runner/.bashrc

# We get run with bash --login. That reads .bash_profile, but not .bashrc.
RUN echo 'export PATH="$PATH:$HOME/.local/bin"' >> /home/runner/.bash_profile

USER runner

ADD entrypoint.sh /

ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]
15 changes: 15 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# According to
# https://docs.gitlab.com/runner/shells/#shell-profile-loading
# Gitlab runner's docker executor does not load shell startup files,
# because that's a great idea.
cmd=()
for i in "$@"; do
cmd+=("$(echo "$i"| sed "/exec/s/bash/bash --login/g")")
done
echo "Using rewritten shell invocation received from executor."
echo "${cmd[@]}"
"${cmd[@]}"
retcode="$?"
echo "return code from command: $retcode"
exit "$retcode"

0 comments on commit 2031626

Please sign in to comment.