Files
weirsoe-party-protocol/scripts/docker_dev_entrypoint.sh
Asger Geel Weirsøe a81bc1250c
Some checks failed
CI / test-and-quality (push) Failing after 4m4s
Big visual overhaul docker compsoe file etc
2026-03-23 14:11:30 +01:00

42 lines
1.2 KiB
Bash

#!/bin/sh
set -eu
WAIT_RETRIES="${WAIT_RETRIES:-60}"
WAIT_INTERVAL_SECONDS="${WAIT_INTERVAL_SECONDS:-2}"
wait_for_service() {
label="$1"
host="$2"
port="$3"
python - "$label" "$host" "$port" "$WAIT_RETRIES" "$WAIT_INTERVAL_SECONDS" <<'PY'
import socket
import sys
import time
label, host, port, retries, interval = sys.argv[1], sys.argv[2], int(sys.argv[3]), int(sys.argv[4]), float(sys.argv[5])
for attempt in range(1, retries + 1):
try:
socket.getaddrinfo(host, port, type=socket.SOCK_STREAM)
with socket.create_connection((host, port), timeout=2):
print(f"[docker-entrypoint] {label} ready at {host}:{port}")
raise SystemExit(0)
except OSError as exc:
print(
f"[docker-entrypoint] waiting for {label} ({attempt}/{retries}) at {host}:{port}: {exc}",
file=sys.stderr,
)
time.sleep(interval)
print(f"[docker-entrypoint] {label} never became reachable at {host}:{port}", file=sys.stderr)
raise SystemExit(1)
PY
}
wait_for_service "database" "${DB_HOST:-127.0.0.1}" "${DB_PORT:-3306}"
wait_for_service "redis" "${CHANNEL_REDIS_HOST:-127.0.0.1}" "${CHANNEL_REDIS_PORT:-6379}"
python manage.py migrate --noinput
exec python manage.py runserver 0.0.0.0:8000