FROM python:3.11-slim

# Prevent Python from generating unnecessary .pyc files.
ENV PYTHONDONTWRITEBYTECODE=1

# Make Python output immediately visible in Docker logs.
ENV PYTHONUNBUFFERED=1

# Application directory.
WORKDIR /app


# ------------------------------------------------------------
# Install dependencies
# ------------------------------------------------------------

COPY requirements.txt .

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


# ------------------------------------------------------------
# Copy application
# ------------------------------------------------------------

COPY app.py .


# ------------------------------------------------------------
# Create upload directory
# ------------------------------------------------------------

RUN mkdir -p /app/uploads


# ------------------------------------------------------------
# Streamlit port
# ------------------------------------------------------------

EXPOSE 8501


# ------------------------------------------------------------
# Start Streamlit
# ------------------------------------------------------------

CMD ["streamlit", "run", "app.py", "--server.address=0.0.0.0", "--server.port=8501"]
