-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a3e9d9a
commit ee43085
Showing
6 changed files
with
57 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
FROM debian:stable-slim | ||
|
||
RUN apt-get update && \ | ||
apt install jq curl gosu -y | ||
|
||
RUN curl -fLo /usr/bin/yq https://github.com/mikefarah/yq/releases/download/3.4.0/yq_linux_amd64 && chmod +x /usr/bin/yq | ||
ADD ./ga /usr/bin/ga | ||
RUN chmod +x /usr/bin/ga | ||
|
||
|
||
ENV USER=wesley USER_ID=1000 USER_GID=1000 | ||
|
||
# now creating user | ||
RUN groupadd --gid "${USER_GID}" "${USER}" && \ | ||
useradd \ | ||
--uid ${USER_ID} \ | ||
--gid ${USER_GID} \ | ||
--shell /bin/bash \ | ||
--create-home \ | ||
${USER} | ||
|
||
COPY ./dockerfile/entrypoint.sh / | ||
RUN chmod u+x /entrypoint.sh | ||
|
||
WORKDIR /workdir/ | ||
ENTRYPOINT ["/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
|
||
if [ -z "${USER}" ]; then | ||
echo "We need USER to be set!"; exit 100 | ||
fi | ||
|
||
# if both not set we do not need to do anything | ||
if [ -z "${HOST_USER_ID}" -a -z "${HOST_USER_GID}" ]; then | ||
echo "this image suppose to run with UID/GID mapped" ; exit 0 | ||
fi | ||
|
||
# reset user_?id to either new id or if empty old (still one of above | ||
# might not be set) | ||
USER_ID=${HOST_USER_ID:=$USER_ID} | ||
USER_GID=${HOST_USER_GID:=$USER_GID} | ||
|
||
LINE=$(grep -F "${USER}" /etc/passwd) | ||
# replace all ':' with a space and create array | ||
array=( ${LINE//:/ } ) | ||
|
||
# home is 5th element | ||
USER_HOME=${array[4]} | ||
|
||
sed -i -e "s/^${USER}:\([^:]*\):[0-9]*:[0-9]*/${USER}:\1:${USER_ID}:${USER_GID}/" /etc/passwd | ||
sed -i -e "s/^${USER}:\([^:]*\):[0-9]*/${USER}:\1:${USER_GID}/" /etc/group | ||
|
||
chown -R ${USER_ID}:${USER_GID} ${USER_HOME} | ||
chown -R ${USER_ID}:${USER_GID} /workdir | ||
|
||
exec gosu ${USER_ID}:${USER_GID} "$@" |