forked from aligent/serverless-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
31 lines (21 loc) · 790 Bytes
/
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
#!/bin/bash
#set -x
APP_ROOT="/app"
DOCKER_UID=`stat -c "%u" $APP_ROOT`
DOCKER_GID=`stat -c "%g" $APP_ROOT`
INCUMBENT_USER=`getent passwd $DOCKER_UID | cut -d: -f1`
INCUMBENT_GROUP=`getent group $DOCKER_GID | cut -d: -f1`
#echo "Docker: uid = $DOCKER_UID, gid = $DOCKER_GID"
#echo "Incumbent: user = $INCUMBENT_USER, group = $INCUMBENT_GROUP"
userdel node
groupadd -g ${DOCKER_GID} node
useradd -g ${DOCKER_GID} --home-dir /home/node -s /bin/bash -u ${DOCKER_UID} node
chown -R node:node /home/node/.config
chown -R node:node /home/node/.serverless
chown -R node:node /home/node/.serverlessrc
cd $APP_ROOT
if [ "${1:-}" = "sls" ] || [ "${1:-}" = "serverless" ]; then
shift
exec sudo -u node /serverless/node_modules/serverless/bin/serverless.js "$@"
fi
exec sudo -u node "$@"