argo-cd/test/container/uid_entrypoint.sh
William Tam 9aae99cf7f
fix: Only processes need root uid will run as root inside test container (#4210)
* Add  "chown" to gpg/keys  in "start-local" target that so that repo-server can access gpg keys.

* * Set -u uid:gid in the docker run commands  so that test images are run under the current user.
* test Procfile processes will not need to perform "su"  to  default user (which has the current user's uid/gid)

* Remove chown in start-e2e-local

* clean up, remove  "bash -c"

* Test containers are run as uid 0 which allows uid_entrypoint.sh  to perform some user setup.  uid_entrypoint.sh creates a non-root user (default) and enables passwordless sudo for that user.    The container entry point command is run as the non-root user.   "goreman start"  does "sudo" to to the processes that need root permission including sshd, fcgiwrap, and nginix.   The other processes are running as the non-root user.

* use /bin/bash

* change back to sh

* Docker image to create  unpriveleged testuser and enable passwordless sudo for that user
2020-09-15 11:32:16 +02:00

12 lines
No EOL
279 B
Bash
Executable file

#!/bin/bash
set -e
if test "$(id -u)" == "0" -a "${USER_ID}" != ""; then
useradd -u ${USER_ID} -d /home/user -s /bin/bash ${USER_NAME:-default}
chown -R "${USER_NAME:-default}" ${GOCACHE}
fi
export PATH=$PATH:/usr/local/go/bin:/go/bin
export GOROOT=/usr/local/go
exec "$@"