chore(prod): startup migrations, readiness checks and backend healthcheck

- add backend entrypoint that can run alembic upgrade head on startup
- add RUN_MIGRATIONS_ON_STARTUP setting and compose wiring
- add /health/live and /health/ready endpoints with db+redis checks
- add backend container healthcheck against readiness endpoint
- document readiness and startup migration behavior
This commit is contained in:
2026-03-08 02:50:57 +03:00
parent 74d9163dde
commit df79a70baf
6 changed files with 61 additions and 3 deletions

View File

@@ -110,8 +110,14 @@ services:
condition: service_completed_successfully
environment:
<<: *app-env
RUN_MIGRATIONS_ON_STARTUP: ${RUN_MIGRATIONS_ON_STARTUP:-true}
ports:
- "${BACKEND_PORT:-8000}:8000"
healthcheck:
test: ["CMD-SHELL", "python -c \"import urllib.request; urllib.request.urlopen('http://localhost:8000/health/ready').read()\""]
interval: 10s
timeout: 5s
retries: 12
worker:
build:
@@ -127,6 +133,7 @@ services:
environment:
<<: *app-env
AUTO_CREATE_TABLES: false
RUN_MIGRATIONS_ON_STARTUP: false
mailpit:
image: axllent/mailpit:latest