feat(examples): add Postgres docker-compose overlays for both examples

feat(examples): add Postgres docker-compose overlays for both examples

#13 in tonybierman/arium — merged 2026-05-25

What

Mirrors the existing SQLite examples with an opt-in Postgres path for both the Dioxus and Leptos fullstack examples. SQLite stays the zero-dependency default.

Why it's not just a compose file

Backend is a compile-time choice — arium selects sqlite vs postgres via a cargo feature (with a compile_error! if both are on), so this can't be a runtime DATABASE_URL flip. The binary itself has to be built for Postgres.

Changes (per example)

  • Cargo features — split the backend out of server/ssr into mutually-exclusive sqlite / postgres features (sqlite is the default). Moved the sqlx driver feature out of the base dep so it tracks the choice. Leptos bin-features bumped to ["ssr", "sqlite"] since ssr no longer pulls a backend.
  • main.rs#[cfg]-gated pool construction (SQLite branch unchanged; Postgres branch requires DATABASE_URL via PgPoolOptions). Migrations are already dialect-aware, so migrator().run() just works.
  • arium::pool::Pool — re-exported through both adapters and used for the dioxus Auth::<…> type param, replacing the concrete sqlx::SqlitePool.
  • docker-compose.postgres.yml (new, per example) — overlay adding a postgres:16-alpine service (pgdata volume, pg_isready healthcheck, depends_on: condition: service_healthy) and overriding DATABASE_URL. Dockerfiles unchanged — they copy from the same target/ paths; only the build command differs.
  • READMEs + .env.example updated with the Postgres run steps and POSTGRES_* knobs.

Run it

# dioxus
dx bundle --release --platform web --package dioxus-fullstack-example --no-default-features --features web,server,postgres
docker compose -f docker-compose.yml -f docker-compose.postgres.yml up -d --build

# leptos
cargo leptos build --release --bin-features ssr,postgres
docker compose -f docker-compose.yml -f docker-compose.postgres.yml up -d --build

Verification

  • cargo check and cargo clippy -D warnings pass for both examples × both backends × default features.
  • Merged compose configs validate via docker compose config.
  • Not yet run end-to-end against a live Postgres container (needs the full bundle build).

Notes

  • CI still only exercises the SQLite path; a --features postgres check job for the examples could be added as a follow-up.

🤖 Generated with Claude Code

Last updated 2026-05-26