FROM python:3.11-slim

# Install system dependencies
RUN apt-get update && apt-get install -y \
    ffmpeg \
    curl \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

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

# Copy application code
COPY app/ ./app/
COPY start.sh .
RUN chmod +x start.sh

# Create necessary directories
RUN mkdir -p config/thumbnails videos

# Default ports
ENV API_PORT=8055
ENV STREAMLIT_PORT=8505

# Expose ports
EXPOSE 8055 8505

# Set Environment Variables
ENV CONFIG_DIR=/app/config
ENV VIDEOS_DIR=/app/videos
ENV PYTHONUNBUFFERED=1

CMD ["./start.sh"]
