two api-replicas with LB-nginx

This commit is contained in:
2026-11-04 17:20:59 +03:00
parent f20b751207
commit 5c191c3bc5
50 changed files with 2991 additions and 311 deletions
+7 -5
View File
@@ -1,5 +1,7 @@
FROM python:3.12.15-slim-bookworm
LABEL io.mtusi.messenger.secrets="file-v1"
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
@@ -16,14 +18,14 @@ COPY alembic.ini ./
COPY migrations ./migrations
COPY app ./app
USER appuser
ARG API_BUILD_REVISION
LABEL io.mtusi.messenger.revision=$API_BUILD_REVISION
# TODO(4.1): uvicorn корректно завершается по SIGTERM (сигнал Docker по умолчанию).
# Проверьте, что python — PID 1 (exec-форма CMD), иначе сигнал не дойдёт.
USER appuser
EXPOSE 8080
HEALTHCHECK --interval=10s --timeout=3s --start-period=5s --retries=3 \
CMD ["python", "-c", "import os, urllib.request; urllib.request.urlopen('http://127.0.0.1:' + os.environ['APP_PORT'] + '/health/live', timeout=2)"]
HEALTHCHECK --interval=3s --timeout=3s --start-period=10s --retries=2 \
CMD ["python", "-c", "import os, urllib.request; urllib.request.urlopen('http://127.0.0.1:' + os.environ['APP_PORT'] + '/health/ready', timeout=2.5)"]
CMD ["python", "-m", "app"]