feat(infra): 落地 M01 基础框架与本机开发环境

交付 FastAPI/Celery/Vue 薄壳、FORCE RLS、Compose 回环与 review 修复证据,关闭 M01 DONE_LOCAL。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
unknownandCursor committed 2026-11-17 15:00:39 +08:00
1 parent 8b2a809f06
commit 8fb16f4a4a
97 files changed
+8059 -22

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
# Dev/runtime image for Watchman API, worker, and beat.
FROM python:3.12-slim-bookworm
WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
UV_LINK_MODE=copy
COPY --from=ghcr.io/astral-sh/uv:0.13.7 /uv /usr/local/bin/uv
COPY pyproject.toml uv.lock .python-version ./
COPY services/watchman ./services/watchman
RUN uv sync --frozen --no-dev --package watchman \
&& useradd --create-home --uid 10001 --shell /usr/sbin/nologin watchman \
&& chown -R watchman:watchman /app
ENV PATH="/app/.venv/bin:$PATH"
USER watchman
WORKDIR /app
CMD ["python", "-m", "watchman", "api"]
+116
View File
@@ -0,0 +1,116 @@
# Dev-only Compose. All published ports bind to 127.0.0.1.
# Do not reuse these bindings in test/prod deploy configs.
# Secrets come from env_file / shell env — never commit real passwords here.
name: watchman-dev
services:
rabbitmq:
image: rabbitmq:3.13-management-alpine
container_name: watchman-dev-rabbitmq
ports:
- "127.0.0.1:56729:5672"
- "127.0.0.1:15679:15672"
healthcheck:
test: ["CMD", "rabbitmq-diagnostics", "-q", "ping"]
interval: 5s
timeout: 5s
retries: 12
volumes:
- watchman_dev_rabbitmq:/var/lib/rabbitmq
# Optional isolated Postgres for containerized runs. Host Postgres on :5432 remains the
# default for local M01 development documented in docs/runbook.md.
postgres:
profiles: ["compose-db"]
image: postgres:17-alpine
container_name: watchman-dev-postgres
environment:
POSTGRES_USER: ${COMPOSE_POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${COMPOSE_POSTGRES_PASSWORD:?set COMPOSE_POSTGRES_PASSWORD in .env.local}
POSTGRES_DB: ${WATCHMAN_DATABASE_NAME:-watchman}
ports:
- "127.0.0.1:54329:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
interval: 5s
timeout: 5s
retries: 12
volumes:
- watchman_dev_postgres:/var/lib/postgresql/data
api:
profiles: ["app"]
build:
context: ..
dockerfile: deploy/Dockerfile
container_name: watchman-dev-api
command: ["python", "-m", "watchman", "api"]
env_file:
- path: ../.env.shared
required: false
- path: ../.env.local
required: true
environment:
# DEV ONLY: bind all interfaces inside the container network namespace.
# Host publish remains 127.0.0.1:8000 (see ports). Do not copy to deploy configs.
API_HOST: 0.0.0.0
# DEV ONLY: RabbitMQ image default guest/guest — local compose only.
CELERY_BROKER_URL: ${CELERY_BROKER_URL_DOCKER:-amqp://guest:guest@rabbitmq:5672//}
DATABASE_URL: ${DATABASE_URL_DOCKER:?set DATABASE_URL_DOCKER in .env.local}
DATABASE_MIGRATOR_URL: ${DATABASE_MIGRATOR_URL_DOCKER:?set DATABASE_MIGRATOR_URL_DOCKER in .env.local}
ports:
- "127.0.0.1:8000:8000"
extra_hosts:
- "host.docker.internal:host-gateway"
depends_on:
rabbitmq:
condition: service_healthy
worker:
profiles: ["app"]
build:
context: ..
dockerfile: deploy/Dockerfile
container_name: watchman-dev-worker
command: ["python", "-m", "watchman", "worker"]
env_file:
- path: ../.env.shared
required: false
- path: ../.env.local
required: true
environment:
CELERY_BROKER_URL: ${CELERY_BROKER_URL_DOCKER:-amqp://guest:guest@rabbitmq:5672//}
DATABASE_URL: ${DATABASE_URL_DOCKER:?set DATABASE_URL_DOCKER in .env.local}
DATABASE_MIGRATOR_URL: ${DATABASE_MIGRATOR_URL_DOCKER:?set DATABASE_MIGRATOR_URL_DOCKER in .env.local}
extra_hosts:
- "host.docker.internal:host-gateway"
depends_on:
rabbitmq:
condition: service_healthy
beat:
profiles: ["app"]
build:
context: ..
dockerfile: deploy/Dockerfile
container_name: watchman-dev-beat
command: ["python", "-m", "watchman", "beat"]
env_file:
- path: ../.env.shared
required: false
- path: ../.env.local
required: true
environment:
CELERY_BROKER_URL: ${CELERY_BROKER_URL_DOCKER:-amqp://guest:guest@rabbitmq:5672//}
DATABASE_URL: ${DATABASE_URL_DOCKER:?set DATABASE_URL_DOCKER in .env.local}
DATABASE_MIGRATOR_URL: ${DATABASE_MIGRATOR_URL_DOCKER:?set DATABASE_MIGRATOR_URL_DOCKER in .env.local}
extra_hosts:
- "host.docker.internal:host-gateway"
depends_on:
rabbitmq:
condition: service_healthy
volumes:
watchman_dev_rabbitmq:
watchman_dev_postgres: