Files
serverAppConfigs/docs/Dankclaw/Postgres.md
T
Frank 04112e88e6 fix: gitea boot persistence via quadlet (incident 2026-08-16)
unattended-upgrades rebooted dankclaw at 15:01; the legacy
podman-compose gitea stack had no systemd units, so rootless podman
did not auto-start the containers. Gitea was down ~1 hour.

- add quadlet units (dankclaw/gitea/quadlet/): gitea-postgres,
  gitea-server, gitea-caddy + gitea.network (DNS enabled; the default
  rootless podman network has dns_enabled=false)
- add gitea stack Caddyfile (upstream gitea-server:3000) and
  .env.example; live password stays in /opt/gitea/.env (0600)
- fix latent name bugs in main stack config: DATABASE_HOST
  gitea-postgres, Caddyfile upstream gitea-server
- docs: rewrite Gitea page for the quadlet stack (management, boot
  persistence, secrets, gotchas, incident log); fix port 3000 in
  stack table; Postgres connection notes
- legacy compose retired on target to /opt/gitea/.deprecated/
2026-08-16 18:31:38 -07:00

1.9 KiB

Postgres

PostgreSQL is the database backend for Gitea. It runs on the same podman network as Gitea and holds the repository metadata, users, and issue data.

Host: Dankclaw — Docs: https://www.postgresql.org/docs

Facts

Item Value
Image docker.io/library/postgres:16-alpine
Port 5432 (internal only)
Data volume bind mount at /var/lib/postgresql/data

Configuration

services:
  postgres:
    image: docker.io/library/postgres:16-alpine
    restart: unless-stopped
    environment:
      POSTGRES_USER: gitea
      POSTGRES_PASSWORD: "${GITEA_DB_PASSWORD}"
      POSTGRES_DB: gitea
    volumes:
      - /opt/gitea/data/gitea-postgres:/var/lib/postgresql/data

Gitea Connection

Gitea reaches the database over the systemd-gitea network (quadlet-managed live, compose-managed after the full-stack deploy):

environment:
  DATABASE_TYPE: postgres
  DATABASE_HOST: gitea-postgres
  DATABASE_NAME: gitea
  DATABASE_USER: gitea
  DATABASE_PASSWD: "${GITEA_DB_PASSWORD}"

The live app.ini on the host overrides env vars. When you rename the database container, update its [database] HOST line. See Gitea Gotchas.

Migration

The live Gitea stack on Dankclaw already runs this image with the data at /opt/gitea/data/gitea-postgres. The migration keeps the bind mount in place; see Gitea.

Healthcheck

Use pg_isready:

healthcheck:
  test: ["CMD-SHELL", "pg_isready -U gitea"]
  interval: 30s
  timeout: 5s
  retries: 3

Gotchas

  • The database password must match between the postgres service and Gitea's DATABASE_PASSWD; both come from the same .env variable.
  • Do not change the Gitea SECRET_KEY or INTERNAL_TOKEN after migration — encrypted data becomes unreadable.
  • Back up with pg_dump; see Gitea Data Persistence (knowledge base).

See Also