From 6516bc2f70da4011fadc31c412a3a16100956391 Mon Sep 17 00:00:00 2001 From: Jason Ross Date: Sat, 20 Jun 2026 20:19:05 -0500 Subject: [PATCH] tested config + Postgres tweaks --- Makefile | 31 +++++++++++++------- README.md | 4 +-- compose.dev.yml | 20 ------------- deploy/quadlets/postgres.container | 4 ++- deploy/secrets-examples/postgres.env.example | 3 +- 5 files changed, 27 insertions(+), 35 deletions(-) delete mode 100644 compose.dev.yml diff --git a/Makefile b/Makefile index 85f6ccb..efedd20 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,12 @@ # idea-collect — developer tasks -# Override COMPOSE with `podman compose` or `podman-compose` if you prefer Podman locally. -COMPOSE ?= docker compose +# Dev mirrors production: everything runs under rootless Podman. DB_URL ?= postgres://idea:idea@localhost:5432/idea?sslmode=disable +# Dev Postgres (rootless Podman). Same image as the production quadlet. +PG_IMAGE ?= docker.io/library/postgres:18 +PG_CONTAINER ?= idea-collect-db +PG_VOLUME ?= idea-collect-pgdata + .DEFAULT_GOAL := help .PHONY: help @@ -12,12 +16,18 @@ help: ## Show this help ## ---- Database ---- .PHONY: db-up db-down db-logs -db-up: ## Start Postgres 18 (dev) - $(COMPOSE) -f compose.dev.yml up -d db -db-down: ## Stop dev Postgres (keeps volume) - $(COMPOSE) -f compose.dev.yml down +db-up: ## Start Postgres 18 (rootless Podman; idempotent) + podman run -d --replace --name $(PG_CONTAINER) \ + -e POSTGRES_USER=idea -e POSTGRES_PASSWORD=idea -e POSTGRES_DB=idea \ + -p 5432:5432 \ + -v $(PG_VOLUME):/var/lib/postgresql \ + --health-cmd 'pg_isready -U idea -d idea' \ + --health-interval 5s --health-retries 10 \ + $(PG_IMAGE) +db-down: ## Stop and remove dev Postgres (keeps the data volume) + -podman rm -f -t 5 $(PG_CONTAINER) db-logs: ## Tail Postgres logs - $(COMPOSE) -f compose.dev.yml logs -f db + podman logs -f $(PG_CONTAINER) ## ---- Backend ---- .PHONY: backend-run backend-build backend-test admin @@ -46,9 +56,8 @@ e2e: db-up ## Start DB then run backend (use frontend-dev in another shell) $(MAKE) backend-run ## ---- Containers ---- -# Use podman locally to mirror production; override with ENGINE=docker. -ENGINE ?= podman +# Rootless Podman mirrors production (the quadlets load these same images). .PHONY: images images: ## Build the backend + custom Caddy images - $(ENGINE) build -t localhost/idea-collect-backend:latest -f backend/Containerfile backend - $(ENGINE) build -t localhost/idea-collect-caddy:latest deploy/caddy + podman build -t localhost/idea-collect-backend:latest -f backend/Containerfile backend + podman build -t localhost/idea-collect-caddy:latest deploy/caddy diff --git a/README.md b/README.md index 8128739..10409d1 100644 --- a/README.md +++ b/README.md @@ -35,10 +35,10 @@ deploy/ ## Quick start (local dev) -Prerequisites: Go 1.26+, Node 20+, Podman or Docker. +Prerequisites: Go 1.26+, Node 20+, rootless Podman. ```bash -# 1. Start Postgres 18 +# 1. Start Postgres 18 (rootless Podman; mirrors the production quadlet) make db-up # 2. Run the backend (applies migrations on startup) diff --git a/compose.dev.yml b/compose.dev.yml deleted file mode 100644 index 54d089d..0000000 --- a/compose.dev.yml +++ /dev/null @@ -1,20 +0,0 @@ -# Local development only. Production uses Podman quadlets in deploy/quadlets/. -services: - db: - image: postgres:18 - environment: - POSTGRES_USER: idea - POSTGRES_PASSWORD: idea - POSTGRES_DB: idea - ports: - - "5432:5432" - volumes: - - pgdata:/var/lib/postgresql/data - healthcheck: - test: ["CMD-SHELL", "pg_isready -U idea -d idea"] - interval: 5s - timeout: 5s - retries: 10 - -volumes: - pgdata: diff --git a/deploy/quadlets/postgres.container b/deploy/quadlets/postgres.container index e2fdac6..be8f1d6 100644 --- a/deploy/quadlets/postgres.container +++ b/deploy/quadlets/postgres.container @@ -7,7 +7,9 @@ After=network-online.target Image=docker.io/library/postgres:18 ContainerName=postgres Network=idea-collect.network -Volume=idea-pgdata.volume:/var/lib/postgresql/data:Z +# Mount the parent so postgres:18 stores data in its version-specific subdir +# (/var/lib/postgresql/18/...), which keeps in-place pg_upgrade possible. +Volume=idea-pgdata.volume:/var/lib/postgresql:Z EnvironmentFile=%h/idea-collect/secrets/postgres.env # Only reachable inside idea-collect.network; no PublishPort. HealthCmd=pg_isready -U idea -d idea diff --git a/deploy/secrets-examples/postgres.env.example b/deploy/secrets-examples/postgres.env.example index 661be3e..5425146 100644 --- a/deploy/secrets-examples/postgres.env.example +++ b/deploy/secrets-examples/postgres.env.example @@ -1,5 +1,6 @@ # -> %h/idea-collect/secrets/postgres.env (rendered by Ansible from vault) +# No PGDATA: the postgres:18 image defaults to a version-specific subdir under +# the mounted /var/lib/postgresql volume (see deploy/quadlets/postgres.container). POSTGRES_USER=idea POSTGRES_PASSWORD=change-me-strong POSTGRES_DB=idea -PGDATA=/var/lib/postgresql/data