-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathdocker-php-entrypoint
More file actions
35 lines (27 loc) · 905 Bytes
/
docker-php-entrypoint
File metadata and controls
35 lines (27 loc) · 905 Bytes
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
#!/bin/sh
set -ev
# Prepare source folders
rm -rf /var/www/html
ln -s /app/$DOCUMENT_ROOT /var/www/html
# Create app user
addgroup --gid $HOST_GID terra
echo $HOST_UID
echo $HOST_GID
adduser --uid $HOST_UID --gid $HOST_GID --system --no-create-home --home /var/www/html terra
adduser terra www-data
# Returns true once mysql can connect.
# Thanks to http://askubuntu.com/questions/697798/shell-script-how-to-run-script-after-mysql-is-ready
mysql_ready() {
echo "Trying to connect to $DATABASE_ENV_MYSQL_USER:$DATABASE_ENV_MYSQL_PASSWORD@database ..."
mysqladmin ping --host=database --user=$DATABASE_ENV_MYSQL_USER --password=$DATABASE_ENV_MYSQL_PASSWORD # > /dev/null 2>&1
}
while !(mysql_ready)
do
sleep 3
echo "Waiting for database host to be ready..."
done
# first arg is `-f` or `--some-option`
if [ "${1#-}" != "$1" ]; then
set -- apache2-foreground "$@"
fi
/usr/sbin/sshd -D