skald/entrypoint.sh
Cobb Hayes 346cea515d Public-flip audit: env-driven paths, scrub audit-ticket prefixes, terser README
Lucy bind paths + LAN host pins replaced with env defaults. Repository URLs
→ git.sulkta.com. Audit-changelog scaffolding stripped from inline comments
(technical reasoning preserved). README sheds marketing scaffolding. AI-speak
in load-bearing prompts/SOULs left alone — that IS the product.
2026-05-27 11:42:58 -07:00

32 lines
1.2 KiB
Bash

#!/usr/bin/env bash
# Boots the embedded postgres via the pgvector image's own
# docker-entrypoint, waits for it to accept connections, then execs
# `skald` in the foreground. Tini is PID 1; postgres becomes our
# child. When the DB is extracted to its own container, this reduces
# to `exec /usr/local/bin/skald "$@"`.
set -eo pipefail
# Hand off to the pgvector image's own initdb + start dance.
/usr/local/bin/docker-entrypoint.sh postgres &
PG_PID=$!
# Wait for postgres to accept connections — initdb-on-first-run can
# take a few seconds. 60s cap so we don't hang forever.
for i in $(seq 1 120); do
if pg_isready -h localhost -p 5432 -U "${POSTGRES_USER:-skald}" -d "${POSTGRES_DB:-skald}" >/dev/null 2>&1; then
echo "skald-entrypoint: postgres ready after ${i} polls"
break
fi
if [ "$i" -eq 120 ]; then
echo "skald-entrypoint: postgres failed to become ready after 60s" >&2
kill "$PG_PID" 2>/dev/null || true
exit 1
fi
sleep 0.5
done
# Exec skald in the foreground. Container's lifecycle now tracks
# skald — if skald exits, the container exits, postgres comes down
# with it, restart policy decides whether to recycle.
exec /usr/local/bin/skald "$@"