31 lines
981 B
Docker
31 lines
981 B
Docker
# syntax=docker/dockerfile:1
|
||
FROM python:3.12-slim
|
||
|
||
ENV PYTHONUNBUFFERED=1 \
|
||
PYTHONDONTWRITEBYTECODE=1 \
|
||
PIP_NO_CACHE_DIR=1 \
|
||
PIP_DISABLE_PIP_VERSION_CHECK=1
|
||
|
||
WORKDIR /app
|
||
|
||
# Непривилегированный пользователь
|
||
RUN useradd --create-home --uid 1000 app
|
||
|
||
COPY requirements.txt ./
|
||
RUN pip install --no-cache-dir -r requirements.txt
|
||
|
||
COPY common ./common
|
||
COPY bot ./bot
|
||
COPY images ./images
|
||
|
||
RUN mkdir -p /app/media && chown app:app /app/media
|
||
|
||
USER app
|
||
|
||
# Живость процесса: бот обновляет файл-heartbeat (см. bot/services/heartbeat.py).
|
||
# Путь должен совпадать с HEARTBEAT_PATH (по умолчанию /tmp/dispelevilbot.heartbeat).
|
||
HEALTHCHECK --interval=30s --timeout=5s --start-period=40s --retries=3 \
|
||
CMD python -c "import os,sys,time; p='/tmp/dispelevilbot.heartbeat'; sys.exit(0 if os.path.exists(p) and time.time()-os.path.getmtime(p) < 120 else 1)"
|
||
|
||
CMD ["python", "-m", "bot"]
|