# Use official Python lightweight image
FROM python:3.10-slim

# Set the working directory
WORKDIR /app

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

# Copy the rest of the application files
COPY . .

# Set up a non-root user (Required by Hugging Face Spaces)
RUN useradd -m -u 1000 user
RUN chown -R user:user /app
USER user

# Expose the default Hugging Face Space port
EXPOSE 7860

# Command to run the FastAPI application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]