-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
35 lines (31 loc) · 957 Bytes
/
docker-entrypoint.sh
File metadata and controls
35 lines (31 loc) · 957 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/bash
set -o errexit
set -o pipefail
set -o nounset
export DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}"
postgres_ready() {
/app/.venv/bin/python << END
import sys
import psycopg
try:
psycopg.connect(
dbname="${POSTGRES_DB}",
user="${POSTGRES_USER}",
password="${POSTGRES_PASSWORD}",
host="${POSTGRES_HOST}",
port="${POSTGRES_PORT}",
)
except psycopg.OperationalError:
print("Can not connect to database ${POSTGRES_DB} on ${POSTGRES_HOST} yet")
sys.exit(-1)
sys.exit(0)
END
}
until postgres_ready; do
>&2 echo 'Waiting for PostgreSQL to become available...'
sleep 1
done
>&2 echo 'PostgreSQL is available'
/app/.venv/bin/python manage.py migrate --no-input
/app/.venv/bin/python manage.py collectstatic --no-input
/app/.venv/bin/gunicorn --workers 2 --bind 0.0.0.0:8080 --forwarded-allow-ips='*' config.wsgi:application