FROM python:3.11-slim

# Set working directory
WORKDIR /app

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

# Copy requirements
COPY requirements.txt .

# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy application code
COPY app ./app

# Create data and upload directories
RUN mkdir -p /app/data /app/uploads

# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV API_TOKEN=CHANGE_ME
ENV DATABASE_URL=sqlite:////app/data/data.db
ENV UPLOAD_DIR=/app/uploads

# Expose port
EXPOSE 8007

# Run application
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8007"]
