forked from freeCodeCamp/devdocs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·41 lines (33 loc) · 1.26 KB
/
entrypoint.sh
File metadata and controls
executable file
·41 lines (33 loc) · 1.26 KB
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
33
34
35
36
37
38
39
40
41
#!/bin/bash
set -e
# This script designed to be used a docker ENTRYPOINT "workaround" missing docker
# feature discussed in docker/docker#7198, allow to have executable in the docker
# container manipulating files in the shared volume owned by the USER_ID:GROUP_ID.
#
# It creates a user named `dkr` with selected USER_ID and GROUP_ID (or
# 1000 if not specified).
# Example:
#
# docker run -ti -e UID=$(id -u) -e GID=$(id -g) imagename bash
#
# Reasonable defaults if no USER_ID/GROUP_ID environment variables are set.
if [ -z ${USER_ID+x} ]; then USER_ID=1000; fi
if [ -z ${GROUP_ID+x} ]; then GROUP_ID=1000; fi
msg="docker_entrypoint: Creating user UID/GID [$USER_ID/$GROUP_ID]" && echo $msg
groupadd -g $GROUP_ID -r dkr && \
useradd -u $USER_ID --create-home -r -g dkr dkr
echo "$msg - done"
msg="docker_entrypoint: Copying .gitconfig and .ssh/config to new user home" && echo $msg
cp /scripts/gitconfig /home/dkr/.gitconfig && \
chown dkr:dkr /home/dkr/.gitconfig && \
mkdir -p /home/dkr/.ssh && \
cp /scripts/ssh_config /home/dkr/.ssh/config && \
chown dkr:dkr -R /home/dkr/.ssh &&
echo "$msg - done"
echo "dkr ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
# Default to 'bash' if no arguments are provided
args="$@"
if [ -z "$args" ]; then
args="/scripts/start.sh"
fi
exec $args