# Backend Dockerfile for Flask-SocketIO Spotify service
FROM python:3.11-slim

# Prevent interactive prompts
ENV PYTHONUNBUFFERED=1

# Set working directory
WORKDIR /app

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

# Install Python dependencies first (leveraging Docker layer cache)
COPY requirements.txt ./
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt

# Install FFmpeg for SpotDL downloads - CRITICAL FIX
RUN spotdl --download-ffmpeg

# Copy rest of backend source
COPY . /app

EXPOSE 5140

CMD ["python", "app.py"]
