-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·32 lines (25 loc) · 1.02 KB
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/sh
# Git config
if [ ! -z "$GIT_USER_NAME" ] && [ ! -z "$GIT_USER_EMAIL" ]; then
git config --global user.name "$GIT_USER_NAME"
git config --global user.email "$GIT_USER_EMAIL"
fi
# Create a user and group that matches the host, either using ID's provided or
# collected from the '/workspace' directory
export HOST_USER_ID=${HOST_USER_ID:-`stat -c %u ~/Workspace`}
export HOST_GROUP_ID=${HOST_GROUP_ID:-`stat -c %g ~/Workspace`}
groupadd -g $HOST_GROUP_ID group
useradd -u $HOST_USER_ID -g group me
# This is to ensure all the files that we copy into the container are owned
# with the right permissions
chown -R me: /home/me
# Give user `me` permission to use docker!
if [ -S "/var/run/docker.sock" ]; then
# Find the hosts group ID for the docker socket
HOST_DOCKER_SOCKET_GROUP_ID=`stat -c %g /var/run/docker.sock`
# create the group `docker`
groupadd --non-unique -g "$HOST_DOCKER_SOCKET_GROUP_ID" docker
# add `me` to the `docker` group
adduser me docker
fi
exec /sbin/su-exec me /bin/bash