Dockerfile (python:3.11, waitress), compose: api1/api2 + postgres + migrate + s3 (pinned minio, без опубликованных портов) + s3-bootstrap + lb (haproxy, round-robin, healthcheck на /health/ready). Секреты DATABASE_URL и S3 — через Docker secrets, локальная инициализация — scripts/init_local.py.
6 lines
1.1 KiB
Markdown
6 lines
1.1 KiB
Markdown
# S3 and DB boundaries
|
|
|
|
`minio/minio:RELEASE.2025-02-07T23-21-09Z` runs as `s3` on internal port 9000; it has a persistent Docker volume `s3_data`. Console is not exposed and S3 port is not published. `s3-bootstrap` creates private `messenger-attachments` bucket idempotently. The API uploads bytes to S3 before committing PostgreSQL metadata; 201 follows commit. A failed SQL transaction triggers best-effort S3 delete. This does **not** guarantee orphan-free operation if delete or host process fails; full reconciliation belongs to level 4/5.
|
|
|
|
Only server-generated random object keys are used; filenames never become paths. GET enforces chat membership before contacting object storage. PostgreSQL `attachments` contains metadata and an internal key, while `message_attachments` preserves ordering. `s3_data` and `postgres_data` must survive restart. For local demonstration credentials live in ignored `secrets/` files; this level-3 exercise uses the same S3 root credential for bootstrap and API (narrow scoped credentials are a level-4 task). Do not deploy to public internet without TLS and restricted credentials.
|