From 2f69bff30135ab98e3f42e873b55a403bfb8e45c Mon Sep 17 00:00:00 2001 From: Chris Hendrickson Date: Mon, 4 May 2026 23:34:30 -0400 Subject: [PATCH] Add PostgreSQL 18 infra sample --- .project/infrastructure/README.md | 7 ++++ .../services/postgresql-18/README.md | 25 +++++++++++++ .../postgresql-18/configure.schema.json | 36 +++++++++++++++++++ .../postgresql-18/dew_postgresql_18.container | 24 +++++++++++++ .../dew_postgresql_18.container.d/.gitkeep | 1 + .../dew_postgresql_18.profiles.d/.gitkeep | 1 + .../services/postgresql-18/init.schema.json | 22 ++++++++++++ .../services/postgresql-18/manifest.yaml | 17 +++++++++ .project/kanban/done/DEW-0031.md | 8 +++++ docs/features/infra.md | 13 +++++++ packages/infra/lib/src/infra_runtime.dart | 2 +- 11 files changed, 155 insertions(+), 1 deletion(-) create mode 100644 .project/infrastructure/README.md create mode 100644 .project/infrastructure/services/postgresql-18/README.md create mode 100644 .project/infrastructure/services/postgresql-18/configure.schema.json create mode 100644 .project/infrastructure/services/postgresql-18/dew_postgresql_18.container create mode 100644 .project/infrastructure/services/postgresql-18/dew_postgresql_18.container.d/.gitkeep create mode 100644 .project/infrastructure/services/postgresql-18/dew_postgresql_18.profiles.d/.gitkeep create mode 100644 .project/infrastructure/services/postgresql-18/init.schema.json create mode 100644 .project/infrastructure/services/postgresql-18/manifest.yaml create mode 100644 .project/kanban/done/DEW-0031.md diff --git a/.project/infrastructure/README.md b/.project/infrastructure/README.md new file mode 100644 index 0000000..d0409f3 --- /dev/null +++ b/.project/infrastructure/README.md @@ -0,0 +1,7 @@ +# Dew Infrastructure Samples + +This directory contains sample services that exercise `dew infra` using the same +layout a project would use for local infrastructure. + +Each service lives under `services//` and is discovered from its +`manifest.yaml`. diff --git a/.project/infrastructure/services/postgresql-18/README.md b/.project/infrastructure/services/postgresql-18/README.md new file mode 100644 index 0000000..961c8a3 --- /dev/null +++ b/.project/infrastructure/services/postgresql-18/README.md @@ -0,0 +1,25 @@ +# PostgreSQL 18 + +Sample local PostgreSQL 18 service managed by `dew infra` and Podman Quadlets. + +```bash +dew infra validate postgresql-18 +dew infra up postgresql-18 +dew infra status postgresql-18 +dew infra logs postgresql-18 --lines 100 +``` + +The sample binds PostgreSQL to `127.0.0.1:5432` with: + +- database: `dew` +- user: `dew` +- password: `dew_dev_password` +- data volume: `dew_postgresql_18_data` + +Stop it with: + +```bash +dew infra down postgresql-18 +``` + +The named volume is intentionally retained after stopping the service. diff --git a/.project/infrastructure/services/postgresql-18/configure.schema.json b/.project/infrastructure/services/postgresql-18/configure.schema.json new file mode 100644 index 0000000..de1b555 --- /dev/null +++ b/.project/infrastructure/services/postgresql-18/configure.schema.json @@ -0,0 +1,36 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://artificery.dev/dew/samples/postgresql-18/configure.schema.json", + "title": "PostgreSQL 18 Sample Configuration", + "description": "Configuration values represented by the sample PostgreSQL 18 Quadlet.", + "type": "object", + "additionalProperties": false, + "properties": { + "host_port": { + "type": "integer", + "minimum": 1, + "maximum": 65535, + "default": 5432 + }, + "database": { + "type": "string", + "minLength": 1, + "default": "dew" + }, + "username": { + "type": "string", + "minLength": 1, + "default": "dew" + }, + "password": { + "type": "string", + "minLength": 8, + "default": "dew_dev_password" + }, + "volume": { + "type": "string", + "minLength": 1, + "default": "dew_postgresql_18_data" + } + } +} diff --git a/.project/infrastructure/services/postgresql-18/dew_postgresql_18.container b/.project/infrastructure/services/postgresql-18/dew_postgresql_18.container new file mode 100644 index 0000000..7e69df8 --- /dev/null +++ b/.project/infrastructure/services/postgresql-18/dew_postgresql_18.container @@ -0,0 +1,24 @@ +[Unit] +Description=Dew sample PostgreSQL 18 database +Wants=network-online.target +After=network-online.target + +[Container] +Image=docker.io/library/postgres:18 +ContainerName=dew_postgresql_18 +Environment=POSTGRES_DB=dew +Environment=POSTGRES_USER=dew +Environment=POSTGRES_PASSWORD=dew_dev_password +PublishPort=127.0.0.1:5432:5432 +Volume=dew_postgresql_18_data:/var/lib/postgresql/data:Z +HealthCmd=pg_isready -U dew -d dew +HealthInterval=10s +HealthTimeout=5s +HealthRetries=5 + +[Service] +Restart=on-failure +TimeoutStartSec=120 + +[Install] +WantedBy=default.target diff --git a/.project/infrastructure/services/postgresql-18/dew_postgresql_18.container.d/.gitkeep b/.project/infrastructure/services/postgresql-18/dew_postgresql_18.container.d/.gitkeep new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/.project/infrastructure/services/postgresql-18/dew_postgresql_18.container.d/.gitkeep @@ -0,0 +1 @@ + diff --git a/.project/infrastructure/services/postgresql-18/dew_postgresql_18.profiles.d/.gitkeep b/.project/infrastructure/services/postgresql-18/dew_postgresql_18.profiles.d/.gitkeep new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/.project/infrastructure/services/postgresql-18/dew_postgresql_18.profiles.d/.gitkeep @@ -0,0 +1 @@ + diff --git a/.project/infrastructure/services/postgresql-18/init.schema.json b/.project/infrastructure/services/postgresql-18/init.schema.json new file mode 100644 index 0000000..1191c9f --- /dev/null +++ b/.project/infrastructure/services/postgresql-18/init.schema.json @@ -0,0 +1,22 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://artificery.dev/dew/samples/postgresql-18/init.schema.json", + "title": "PostgreSQL 18 Sample Initialization", + "description": "Optional initialization notes for the sample PostgreSQL 18 service.", + "type": "object", + "additionalProperties": false, + "properties": { + "create_database": { + "type": "boolean", + "default": true + }, + "seed_sample_data": { + "type": "boolean", + "default": false + }, + "notes": { + "type": "string", + "default": "" + } + } +} diff --git a/.project/infrastructure/services/postgresql-18/manifest.yaml b/.project/infrastructure/services/postgresql-18/manifest.yaml new file mode 100644 index 0000000..82221e0 --- /dev/null +++ b/.project/infrastructure/services/postgresql-18/manifest.yaml @@ -0,0 +1,17 @@ +service: + id: postgresql-18 + name: PostgreSQL 18 + unit: dew_postgresql_18.service + container_name: dew_postgresql_18 + +runtime: + type: podman-quadlet + +container: + file: dew_postgresql_18.container + dropins_dir: dew_postgresql_18.container.d + profiles_dir: dew_postgresql_18.profiles.d + +schemas: + configure: configure.schema.json + init: init.schema.json diff --git a/.project/kanban/done/DEW-0031.md b/.project/kanban/done/DEW-0031.md new file mode 100644 index 0000000..71fd0da --- /dev/null +++ b/.project/kanban/done/DEW-0031.md @@ -0,0 +1,8 @@ +--- +id: DEW-0031 +title: Add PostgreSQL 18 infra sample +type: task +created: 2026-05-05T03:31:50.153499Z +--- + +Add a sample Dew infrastructure service that brings up PostgreSQL 18 through a Podman Quadlet manifest, including manifest.yaml, schemas, profile/drop-in directories, and documentation. diff --git a/docs/features/infra.md b/docs/features/infra.md index 2386bb7..45e6990 100644 --- a/docs/features/infra.md +++ b/docs/features/infra.md @@ -73,3 +73,16 @@ user systemd path or `--scope system` for `/etc/containers/systemd`. `dew infra up` installs missing Quadlet files, reloads systemd, then starts the unit. + +## Samples + +The Dew repository includes sample service bringups under +`.project/infrastructure/services/`. + +`postgresql-18` brings up a local PostgreSQL 18 container through Podman +Quadlets: + +```bash +dew infra validate postgresql-18 +dew infra up postgresql-18 +``` diff --git a/packages/infra/lib/src/infra_runtime.dart b/packages/infra/lib/src/infra_runtime.dart index 4f3bfcd..dc60b84 100644 --- a/packages/infra/lib/src/infra_runtime.dart +++ b/packages/infra/lib/src/infra_runtime.dart @@ -245,7 +245,7 @@ class PodmanQuadletRuntime implements ContainerRuntime { () => fs.directory(targetDropins).create(recursive: true), ); await for (final entity in fs.directory(dropinsPath).list()) { - if (entity is! File) continue; + if (entity is! File || p.extension(entity.path) != '.conf') continue; await _link( actions, dryRun,