dnote/host/docker/entrypoint.sh
Sung Won Cho 39d18638a9
Build Docker image (#316)
* Make preview image

* Use local build

* Fix build

* Release

* Build dnote docker

* Simplify

* Document
2019-11-18 16:59:53 +08:00

25 lines
495 B
Bash
Executable file

#!/bin/sh
wait_for_db() {
HOST=${DBHost:-postgres}
PORT=${DBPort:-5432}
echo "Waiting for the database connection..."
attempts=0
max_attempts=10
while [ $attempts -lt $max_attempts ]; do
nc -z "${HOST}" "${PORT}" 2>/dev/null && break
echo "Waiting for db at ${HOST}:${PORT}..."
sleep 5
attempts=$((attempts+1))
done
if [ $attempts -eq $max_attempts ]; then
echo "Timed out while waiting for db at ${HOST}:${PORT}"
exit 1
fi
}
wait_for_db
exec "$@"