FROM python:3.12-slim-bookworm

RUN apt-get update && apt-get install -y \
    mariadb-client \
    openssh-client \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

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

COPY app.py .
COPY templates/ ./templates/
COPY static/ ./static/

RUN mkdir -p /app/downloads /app/ssh-keys

ENV FLASK_APP=app:app
ENV FLASK_ENV=production
ENV PYTHONUNBUFFERED=1

EXPOSE 8082

CMD ["gunicorn", "--bind", "0.0.0.0:8082", "--workers", "2", "--threads", "4", "app:app"]
