Skip to content

Commit

Permalink
Fix user permissions and add support for Docker buildkit and credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
khizunov committed Jan 30, 2024
1 parent 8fa3634 commit 9c40cf2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 7 additions & 3 deletions skipper/data/skipper-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
if ! [ -z "${SKIPPER_DOCKER_GID}" ];then

HOME_DIR=${HOME}

SKIP_HOME_DIR_PARAM=""

# if home directory already exists, useradd should not try to create it
Expand All @@ -29,8 +28,13 @@ if ! [ -z "${SKIPPER_DOCKER_GID}" ];then
usermod -G root ${SKIPPER_USERNAME}
fi


su -m ${SKIPPER_USERNAME} -c "$@"
if ! which sudo > /dev/null; then
su -m ${SKIPPER_USERNAME} -c "$@"
else
# for debian dsitros (maybe for others too) -m flag resets the PATH variable
# so we need to use sudo -E to preserve the PATH
sudo -sE -u ${SKIPPER_USERNAME} "$@"
fi
else
bash -c "$@"
fi
7 changes: 5 additions & 2 deletions skipper/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,11 @@ def handle_networking(cmd, publish, net):
def handle_volumes_bind_mount(docker_cmd, homedir, volumes, workspace):
volumes = volumes or []
volumes.extend([f'{homedir}/.netrc:{homedir}/.netrc:ro',
f'{homedir}/.gitconfig:{homedir}/.gitconfig:ro',
f'{homedir}/.docker/config.json:{homedir}/.docker/config.json:ro'])
f'{homedir}/.gitconfig:{homedir}/.gitconfig:ro'])

# required for docker buildkit and credentials
if os.path.exists(f'{homedir}/.docker'):
volumes.append(f'{homedir}/.docker:{homedir}/.docker:rw')

# required for docker login (certificates)
if os.path.exists('/etc/docker'):
Expand Down

0 comments on commit 9c40cf2

Please sign in to comment.