forked from cerc-io/stack-orchestrator
Work around docker uid/gid insanity
This commit is contained in:
@@ -39,6 +39,7 @@ RUN mkdir /scripts
|
||||
COPY build-npm-package.sh /scripts
|
||||
COPY yarn-local-registry-fixup.sh /scripts
|
||||
COPY build-npm-package-local-dependencies.sh /scripts
|
||||
COPY fixup-for-uid.sh /scripts
|
||||
ENV PATH="${PATH}:/scripts"
|
||||
|
||||
COPY entrypoint.sh .
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
#!/bin/sh
|
||||
/scripts/fixup-for-uid.sh
|
||||
exec "$@"
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
# Make the container usable for uid/gid != 1000
|
||||
if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then
|
||||
set -x
|
||||
fi
|
||||
current_uid=$(id -u)
|
||||
current_gid=$(id -g)
|
||||
user_name="hostuser"
|
||||
# First check the current uid. If == 1000 then exit, nothing needed because that uid already exists
|
||||
if [[ ${current_uid} == 1000 ]]; then
|
||||
exit 0
|
||||
fi
|
||||
# Also exit for root
|
||||
if [[ ${current_uid} == 0 ]]; then
|
||||
exit 0
|
||||
fi
|
||||
# Create the user with home dir
|
||||
useradd -m -d /home/${user_name} -s /bin/bash -g ${current_gid} -u ${current_uid} ${user_name}
|
||||
Reference in New Issue
Block a user