# syntax=docker/dockerfile:1.4
FROM python:3.13.1-slim AS base
LABEL authors="UdoChudo"

# Установка системных зависимостей и очистка
RUN apt-get update && apt-get install -y \
    gcc \
    libpq-dev \
    tzdata \
    sqlite3 \
    && apt-get clean && rm -rf /var/lib/apt/lists/*

ENV TZ=Europe/Moscow
ENV PYTHONUNBUFFERED=1

WORKDIR /app

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

# ====================
# Образ для Flask
# ====================
FROM base AS flask

ENV APP_TYPE=flask
ENV FLASK_APP=app

EXPOSE 5000

ENTRYPOINT ["/bin/sh", "-c"]
CMD ["gunicorn --access-logfile - --error-logfile - -b 0.0.0.0:5000 'app:create_app()'"]

# ====================
# Образ для Telegram бота
# ====================
FROM base AS telegram

ENV APP_TYPE=telegram

ENTRYPOINT ["/bin/sh", "-c"]
CMD ["python run_telegram.py"]
