Реализовал уровень 3: PostgreSQL, пароли и сохраняемые сессии
This commit is contained in:
+8
-22
@@ -1,26 +1,12 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
FROM python:3.11-slim-bookworm
|
||||
|
||||
FROM python:3.11.10-slim-bookworm
|
||||
WORKDIR /app
|
||||
|
||||
# Create non-root user
|
||||
# Приложение работает без прав root.
|
||||
RUN groupadd -r appuser && useradd -r -g appuser appuser
|
||||
|
||||
# Install dependencies first for layer caching
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Copy application source
|
||||
COPY src/ ./src/
|
||||
|
||||
# Switch to non-root user
|
||||
COPY requirements.lock.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.lock.txt
|
||||
COPY src/ src/
|
||||
COPY migrations/ migrations/
|
||||
USER appuser
|
||||
|
||||
# Healthcheck
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
|
||||
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8080/health/live')" || exit 1
|
||||
|
||||
HEALTHCHECK --interval=5s --timeout=5s --start-period=15s --retries=5 CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8080/health/ready')"
|
||||
EXPOSE 8080
|
||||
|
||||
# Uvicorn handles SIGTERM gracefully (default timeout 10s)
|
||||
CMD ["python", "-m", "uvicorn", "src.app:app", "--host", "0.0.0.0", "--port", "8080", "--log-level", "info"]
|
||||
CMD ["sh", "-c", "python -m src.migrate && exec python -m uvicorn src.app:app --host 0.0.0.0 --port 8080 --timeout-graceful-shutdown 8"]
|
||||
|
||||
Reference in New Issue
Block a user