-
-
Notifications
You must be signed in to change notification settings - Fork 170
/
Copy pathdocker-entrypoint
executable file
·61 lines (51 loc) · 2.26 KB
/
docker-entrypoint
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
#!/bin/sh
set -e
# configure php additions.ini
cat /etc/php.d/05-additions.ini.template \
| envsubst '${MAILHOG_HOST} ${MAILHOG_PORT}' \
| sudo tee /etc/php.d/05-additions.ini
# append warden issued root ca cert to ca-bundle trusted by curl/openssl
if [ -f /etc/ssl/warden-rootca-cert/ca.cert.pem ]; then
sudo cp /etc/ssl/warden-rootca-cert/ca.cert.pem /etc/pki/ca-trust/source/anchors/warden-rootca-cert.pem
fi
# update trust outside if condition above to allow mounting PEM files into /etc/pki/ca-trust/source/anchors
sudo update-ca-trust
# start socat process in background to connect sockets used for agent access within container environment
if [[ -S /run/host-services/ssh-auth.sock ]] \
&& [[ "${SSH_AUTH_SOCK}" != "/run/host-services/ssh-auth.sock" ]]
then
sudo bash -c "nohup socat UNIX-CLIENT:/run/host-services/ssh-auth.sock \
UNIX-LISTEN:${SSH_AUTH_SOCK},fork,user=www-data,group=www-data 1>/var/log/socat-ssh-auth.log 2>&1 &"
fi
# start crond as a background process
sudo crond
# install requested node version if not already installed
NODE_INSTALLED="$(node -v | perl -pe 's/^v([0-9]+)\..*$/$1/')";
if [ "${NODE_INSTALLED}" != "${NODE_VERSION}" ] \
|| [ "${NODE_VERSION}" = "latest" ] || [ "${NODE_VERSION}" = "lts" ]
then
sudo n "${NODE_VERSION}"
fi
# Resolve permission issues with directories auto-created by volume mounts; to use set CHOWN_DIR_LIST to
# a list of directories (relative to working directory) to chown, walking up the paths to also chown each
# specified parent directory. Example: "dir1/dir2 dir3" will chown dir1/dir2, then dir1 followed by dir3
for DIR in ${CHOWN_DIR_LIST:-}; do
if [[ -d "${DIR}" ]]; then
while :; do
sudo chown www-data:www-data "${DIR}"
DIR=$(dirname "${DIR}")
if [[ ${DIR} == "." ]] || [[ ${DIR} == "/" ]]; then
break;
fi
done
fi
done
# Resolve permission issue with /var/www/html being owned by root as a result of volume mounted on php-fpm
# and nginx combined with nginx running as a different uid/gid than php-fpm does. This condition, when it
# surfaces would cause mutagen sync failures (on initial startup) on macOS environments.
sudo chown www-data:www-data /var/www/html
# first arg is `-f` or `--some-option`
if [ "${1#-}" != "$1" ]; then
set -- php-fpm "$@"
fi
exec "$@"