From 9233b72dcfd4f44f7e30dd0d699530493e87072d Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 30 Nov 2025 16:48:43 +0900 Subject: feat(db): add Docker Compose for PostgreSQL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add docker-compose.yml with PostgreSQL 17 Alpine image for local development. Includes healthcheck, volume persistence, and environment variable configuration. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .env.example | 3 +++ .envrc | 1 + .gitignore | 1 + README.md | 9 +++++---- compose.yaml | 21 +++++++++++++++++++++ docs/dev/roadmap.md | 2 +- 6 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 .env.example create mode 100644 .envrc create mode 100644 compose.yaml diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..012ade7 --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +POSTGRES_USER=kioku +POSTGRES_PASSWORD=kioku +POSTGRES_DB=kioku diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..fe7c01a --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +dotenv diff --git a/.gitignore b/.gitignore index 06e6038..946936c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules dist *.tsbuildinfo +.env diff --git a/README.md b/README.md index 46bfb35..4d90b2f 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,9 @@ A spaced repetition learning application (Anki clone) with PWA offline support a - Node.js 22+ - pnpm 10+ -- PostgreSQL 15+ -- Docker (optional) +- PostgreSQL 18+ +- Docker +- Direnv (optional) ### Development @@ -24,8 +25,8 @@ A spaced repetition learning application (Anki clone) with PWA offline support a # Install dependencies pnpm install -# Start PostgreSQL (with Docker) -docker compose up -d postgres +# Start containers +docker compose up # Run database migrations pnpm --filter server db:migrate diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..494e60f --- /dev/null +++ b/compose.yaml @@ -0,0 +1,21 @@ +services: + db: + image: postgres:18 + container_name: kioku-db + restart: unless-stopped + environment: + POSTGRES_USER: ${POSTGRES_USER} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + POSTGRES_DB: ${POSTGRES_DB} + expose: + - 5432 + volumes: + - db_data:/var/lib/postgresql + healthcheck: + test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"] + interval: 10s + timeout: 5s + retries: 5 + +volumes: + db_data: diff --git a/docs/dev/roadmap.md b/docs/dev/roadmap.md index 9f49f5d..4ca1ef1 100644 --- a/docs/dev/roadmap.md +++ b/docs/dev/roadmap.md @@ -17,7 +17,7 @@ - [x] Logger middleware ### Database -- [ ] Docker Compose with PostgreSQL +- [x] Docker Compose with PostgreSQL - [ ] Drizzle ORM setup - [ ] Database migrations -- cgit v1.2.3-70-g09d2