-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-entrypoint-development.sh
68 lines (47 loc) · 1.74 KB
/
docker-entrypoint-development.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/sh
# set -x
echo "=========================================================================="
echo "Starting $0, $(date)"
echo "=========================================================================="
echo "Starting CouchDB, Redis & MailHog localy..."
couchdb &> /var/log/couchdb.log &
redis &> /var/log/redis.log &
MailHog &> /var/log/mailhog.log &
echo "Wait for CouchDB to be available..."
wait-for-it.sh -h localhost -p 5984 -t 60
echo "Init CouchDB databases, nothing will happen if they already exists..."
for db in _global_changes _metadata _replicator _users
do
curl -s -X PUT "http://localhost:5984/$db"
done
echo "Wait for Redis to be available..."
wait-for-it.sh -h localhost -p 6379 -t 60
echo "Wait for MailHog to be available..."
wait-for-it.sh -h localhost -p 8045 -t 60
# Generate passphrase if missing
if [ ! -f /var/lib/stack/stack-admin-passphrase ]
then
if [ -z "$STACK_ADMIN_PASSPHRASE" ]
then
echo "Using default admin passphrase !!!"
STACK_ADMIN_PASSPHRASE="stack"
fi
echo "Generating /var/lib/stack/stack-admin-passphrase..."
echo $STACK_ADMIN_PASSPHRASE | stack config passwd /var/lib/stack/stack-admin-passphrase
fi
# Prepare stepping down from root to applicative user with chosen UID/GID
USER_ID=${LOCAL_USER_ID:-36000}
GROUP_ID=${LOCAL_GROUP_ID:-36000}
groupadd -g $GROUP_ID -o stack
useradd --shell /bin/bash -u $USER_ID -g stack -o -c "Stack user" -d /var/lib/stack -m stack
chown -R stack: /var/lib/stack
# If running an applicative subcommand, running it as stack user
if echo "$@" | grep -q "stack "
then
# Then run the command itself as applicative user
echo "Now running CMD with UID $USER_ID and GID $GROUP_ID"
exec gosu stack "$@"
else
# Otherwise run the command as root
exec "$@"
fi