Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@
# All module-level settings (SMTP, Celery, users, etc.) are now managed in
# the admin UI at /settings/modules — no env vars needed.

# Database (required)
# Database (required). Default is local SQLite. To use the shared
# ../dev-services Postgres, uncomment the line below (db simple_module_python,
# user postgres/postgres):
SM_DATABASE_URL=sqlite+aiosqlite:///./app.db
# SM_DATABASE_URL=postgresql+asyncpg://sm:sm@localhost:5432/simple_module
# SM_DATABASE_URL=postgresql+asyncpg://postgres:postgres@localhost:5432/simple_module_python

# Celery against the shared ../dev-services Redis. Host-run worker/beat use
# localhost; the docker-compose worker/beat override to the `redis` hostname.
# This project owns Redis logical DBs 4 (broker) and 5 (result backend).
# SM_BG_TASKS_BROKER_URL=redis://localhost:6379/4
# SM_BG_TASKS_RESULT_BACKEND=redis://localhost:6379/5

# Process identity (production must override SM_SECRET_KEY)
SM_ENVIRONMENT=development
Expand Down
18 changes: 18 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,24 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co

Python 3.12 + FastAPI + SQLModel + Alembic on the backend; Inertia.js + React + Tailwind 4 + Vite on the frontend. `uv` workspaces for Python, `npm` workspaces for JS. Package managers: `uv sync --all-packages` and `npm install`.

## Local database & services (shared dev-services stack)

**Do NOT start your own Postgres/Redis container.** All repos in `~/Repos` share
one stack defined in `~/Repos/dev-services` (one PostGIS + Redis + MinIO + Adminer
on the `devnet` Docker network). `make docker-up` here brings that shared stack up
(it no longer starts a local postgres/redis); `make docker-down` only stops this
repo's own containers (worker/beat), never the shared stack.

This repo's slice:

- **Postgres**: `localhost:5432`, `postgres`/`postgres`, database
**`simple_module_python`** (the default `SM_DATABASE_URL` is SQLite; uncomment
the Postgres line in `.env.example` to use the shared DB).
- **Redis**: `localhost:6379`, logical DBs **4** (broker) / **5** (result backend).

If a port is taken by an old per-project container, stop that container rather
than remapping ports. To add a database, edit `dev-services/init/01-databases.sql`.

## Commands

All day-to-day tasks go through `make`:
Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,14 @@ kill:
@-lsof -ti:8000,5050,5173 | xargs kill -9 2>/dev/null
@echo "Ports 8000, 5050, 5173 freed."

# Docker
# Docker — Postgres/Redis now live in the shared ../dev-services stack.
# docker-up brings that shared stack up (idempotent, shared with other repos).
docker-up:
docker compose up -d postgres redis
docker compose -f ../dev-services/compose.yml up -d

# Only stop THIS project's own containers (worker/beat). Never tear down the
# shared stack here — other repos depend on it. Use `make down` in
# ../dev-services to stop the shared services.
docker-down:
docker compose down

Expand Down
59 changes: 16 additions & 43 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,20 @@
services:
postgres:
image: postgres:16
environment:
POSTGRES_DB: simple_module
POSTGRES_USER: sm
POSTGRES_PASSWORD: sm
ports:
- "5432:5432"
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U sm -d simple_module"]
interval: 5s
timeout: 5s
retries: 10

redis:
image: redis:7-alpine
ports:
- "6379:6379"
volumes:
- redisdata:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 10
# Postgres + Redis now come from the shared ../dev-services stack
# (one PostGIS + one Redis on the external `devnet` network). Start it first
# with `make up` in ~/Repos/dev-services. This project uses:
# database: simple_module_python (on shared postgres:5432, postgres/postgres)
# redis: DB 4 (broker) / DB 5 (result backend)

worker:
build:
context: .
dockerfile: docker/worker.Dockerfile
env_file: .env
environment:
SM_BG_TASKS_BROKER_URL: redis://redis:6379/0
SM_BG_TASKS_RESULT_BACKEND: redis://redis:6379/1
SM_DATABASE_URL: ${SM_DATABASE_URL:-postgresql+asyncpg://sm:sm@postgres:5432/simple_module}
depends_on:
redis:
condition: service_healthy
postgres:
condition: service_healthy
SM_BG_TASKS_BROKER_URL: redis://redis:6379/4
SM_BG_TASKS_RESULT_BACKEND: redis://redis:6379/5
SM_DATABASE_URL: ${SM_DATABASE_URL:-postgresql+asyncpg://postgres:postgres@postgres:5432/simple_module_python}
networks: [devnet]
command:
- "uv"
- "run"
Expand All @@ -58,14 +32,13 @@ services:
dockerfile: docker/worker.Dockerfile
env_file: .env
environment:
SM_BG_TASKS_BROKER_URL: redis://redis:6379/0
SM_BG_TASKS_RESULT_BACKEND: redis://redis:6379/1
SM_DATABASE_URL: ${SM_DATABASE_URL:-postgresql+asyncpg://sm:sm@postgres:5432/simple_module}
SM_BG_TASKS_BROKER_URL: redis://redis:6379/4
SM_BG_TASKS_RESULT_BACKEND: redis://redis:6379/5
SM_DATABASE_URL: ${SM_DATABASE_URL:-postgresql+asyncpg://postgres:postgres@postgres:5432/simple_module_python}
depends_on:
redis:
condition: service_healthy
worker:
condition: service_started
networks: [devnet]
command:
- "uv"
- "run"
Expand All @@ -76,6 +49,6 @@ services:
- "-l"
- "info"

volumes:
pgdata:
redisdata:
networks:
devnet:
external: true
Loading