Skip to content

Commit

Permalink
Respect Dockerfile ENV PATH modifications in docker/bash.sh lookups.
Browse files Browse the repository at this point in the history
  • Loading branch information
areusch committed Sep 1, 2022
1 parent aa31dfc commit 16bff01
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions docker/with_the_same_user
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@

set -e

COMMAND=("$@")
# NOTE: sudo uses the env_reset option to reset environment variables to a secure bare minimum.
# The --preserve-env option below passes those variables through to the invoked process; however,
# this appears not to affect the environment used with execve, so we resolve the binary to run
# in this file using the $PATH specified in the Dockerfile.
COMMAND=( "$(which "$1")" )
shift
COMMAND=( "${COMMAND[@]}" "$@" )

if ! touch /this_is_writable_file_system; then
echo "You can't write to your filesystem!"
Expand All @@ -50,14 +56,14 @@ getent passwd "${CI_BUILD_UID}" || adduser --force-badname --gid "${CI_BUILD_GID
usermod -a -G sudo -G tvm-venv "${CI_BUILD_USER}"

# Add user to video group for ROCm
if [[ ! -z $ROCM_ENABLED ]]; then
if [[ ! -z "${ROCM_ENABLED-}" ]]; then
usermod -a -G video "${CI_BUILD_USER}"
fi

# This is a grotesque hack to get PYTEST_ADD_OPTS available to all task scripts.
echo "${CI_BUILD_USER} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-nopasswd-sudo

if [[ ! -z $CUDA_VISIBLE_DEVICES ]]; then
if [[ ! -z "${CUDA_VISIBLE_DEVICES-}" ]]; then
CUDA_ENV="CUDA_VISIBLE_DEVICES=${CUDA_VISIBLE_DEVICES}"
else
CUDA_ENV=""
Expand All @@ -67,8 +73,8 @@ sudo -u "#${CI_BUILD_UID}" --preserve-env \
${CUDA_ENV} \
PATH=${PATH} \
JAVA_HOME=${JAVA_HOME} \
LD_LIBRARY_PATH=${LD_LIBRARY_PATH} \
PYTHONPATH=${PYTHONPATH} \
CI_IMAGE_NAME=${CI_IMAGE_NAME} \
HOME=${CI_BUILD_HOME} \
LD_LIBRARY_PATH="${LD_LIBRARY_PATH-}" \
PYTHONPATH="${PYTHONPATH-}" \
CI_IMAGE_NAME="${CI_IMAGE_NAME-}" \
HOME="${CI_BUILD_HOME-}" \
"${COMMAND[@]}"

0 comments on commit 16bff01

Please sign in to comment.