-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-entrypoint.sh
35 lines (29 loc) · 962 Bytes
/
docker-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
31
32
33
34
35
#!/bin/sh
APP_PATH="/app"
BACKEND_PATH="$APP_PATH/backend"
${DJANGO_CONTAINER:=true} # If not defined in environment variable set as true. If true Django commands will run.
##########################
# Postgres check
##########################
echo "Waiting for PostgreSQL on ${DATABASE_HOST:=postgres}:${DATABASE_PORT:=5432}..."
while ! nc -z $DATABASE_HOST $DATABASE_PORT; do
sleep 0.1
done
echo "PostgreSQL started."
##########################
# Redis check
##########################
REDIS_HOST=$(echo ${CELERY_BROKER:=redis://redis:6379} | awk -F[/:] '{print $4}')
REDIS_PORT=$(echo ${CELERY_BROKER:=redis://redis:6379} | awk -F[/:] '{print $5}')
echo "Waiting for Redis on $REDIS_HOST:$REDIS_PORT..."
while ! nc -z $REDIS_HOST $REDIS_PORT; do
sleep 0.1
done
echo "Redis started."
##########################
# Django commands
##########################
if [ "$DJANGO_CONTAINER" = true ]; then
python $BACKEND_PATH/manage.py migrate
fi
exec "$@"