# Default image for a pip-based Python web app (Flask via gunicorn).
# ADJUST the CMD at the bottom to match the app's entry point.
FROM python:3.12-slim

WORKDIR /app
ENV PYTHONUNBUFFERED=1 PIP_NO_CACHE_DIR=1

# sqlite3 CLI is used by the backup snapshot; curl for healthchecks.
RUN apt-get update \
    && apt-get install -y --no-install-recommends sqlite3 curl \
    && rm -rf /var/lib/apt/lists/*

COPY requirements.txt .
RUN pip install -r requirements.txt && pip install gunicorn requests

COPY . .

# Persistent data lives on a mounted volume, not in the image.
RUN mkdir -p /data/uploads/suggestions

COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

EXPOSE 8000
ENTRYPOINT ["/entrypoint.sh"]

# ---- ADJUST THIS LINE to the app's real entry point ----
# Flask  (app object named `app` in app.py):
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--workers", "2", "app:app"]
#
# FastAPI (app object named `app` in main.py) — swap the CMD for:
#   RUN pip install "uvicorn[standard]"
#   CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
#
# Django (project package `mysite`):
#   CMD ["gunicorn", "--bind", "0.0.0.0:8000", "mysite.wsgi:application"]
#
# Streamlit:
#   CMD ["streamlit", "run", "app.py", "--server.port=8000", "--server.address=0.0.0.0"]
