waitfordb: initial tool + container + CI #1

Merged
benvin merged 3 commits from benvin/initial into main 2026-08-22 15:03:39 +10:00
Member

Why

A reusable wait-for-DB init container so we stop hand-writing psql-in-a-shell init containers (e.g. the arrstack sonarr/radarr/prowlarr deployments). Env-configured, generic across Postgres/MySQL.

How

  • Go CLI: polls the DB until SELECT 1 succeeds (server+auth+db all ready), then exit 0; exit 1 on timeout, 2 on config error.
  • Config via WAITFORDB_* env with libpq PG* fallback (precedence DSN > WAITFORDB_* > PG*); configurable TIMEOUT/INTERVAL/CONNECT_TIMEOUT; password redacted in logs.
  • Postgres + MySQL drivers behind a small abstraction. Distroless non-root image. Makefile patch|minor|major release. Woodpecker: build-check on PR/push, publish docker-internal/waitfordb on v* tag.
  • Unit tests (config precedence/redaction, wait-loop with fake clock, drivers) + a real postgres:16 integration test (wait-then-succeed).

Branch protection to be added once CI is green.

## Why A reusable wait-for-DB init container so we stop hand-writing psql-in-a-shell init containers (e.g. the arrstack sonarr/radarr/prowlarr deployments). Env-configured, generic across Postgres/MySQL. ## How - Go CLI: polls the DB until `SELECT 1` succeeds (server+auth+db all ready), then exit 0; exit 1 on timeout, 2 on config error. - Config via `WAITFORDB_*` env with libpq `PG*` fallback (precedence DSN > WAITFORDB_* > PG*); configurable `TIMEOUT`/`INTERVAL`/`CONNECT_TIMEOUT`; password redacted in logs. - Postgres + MySQL drivers behind a small abstraction. Distroless non-root image. Makefile `patch|minor|major` release. Woodpecker: build-check on PR/push, publish `docker-internal/waitfordb` on `v*` tag. - Unit tests (config precedence/redaction, wait-loop with fake clock, drivers) + a real postgres:16 integration test (wait-then-succeed). Branch protection to be added once CI is green.
unkin-agent added 1 commit 2026-08-22 13:32:06 +10:00
Small Go tool + distroless container used as a K8s initContainer to block an
app until its database (Postgres/MySQL) is reachable. Env-var configured
(WAITFORDB_* + libpq PG* fallback), configurable timeout/interval, redacted
logs, exit codes. Woodpecker CI publishes docker-internal/waitfordb on tag.
Author
Member

Genericised the docs per feedback: removed the 'replaces the hand-written psql-in-a-shell initContainers we used on the arrstack (sonarr/radarr/prowlarr)' line and swapped the example log/initContainer names to generic placeholders (appdb / app-db / postgres-rw.default.svc). The README now stands on its own with no references to other projects or past history.

Genericised the docs per feedback: removed the 'replaces the hand-written psql-in-a-shell initContainers we used on the arrstack (sonarr/radarr/prowlarr)' line and swapped the example log/initContainer names to generic placeholders (appdb / app-db / postgres-rw.default.svc). The README now stands on its own with no references to other projects or past history.
unkin-agent added 2 commits 2026-08-22 14:59:38 +10:00
benvin merged commit 3c9f9d6de4 into main 2026-08-22 15:03:39 +10:00
benvin deleted branch benvin/initial 2026-08-22 15:03:40 +10:00
Sign in to join this conversation.