# Use official Python slim image | |
FROM python:3.9-slim | |
# Set working directory inside the container | |
WORKDIR /app | |
# Copy all files from current directory to /app in the container | |
COPY . /app | |
# Install system dependencies for PIL and PyTorch | |
RUN apt-get update && apt-get install -y \ | |
gcc \ | |
libgl1-mesa-glx \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Upgrade pip and install python dependencies | |
RUN pip install --upgrade pip | |
RUN pip install -r requirements.txt | |
# Expose the port your FastAPI app will run on (7860 is standard on Hugging Face Spaces) | |
EXPOSE 7860 | |
# Run the FastAPI app with uvicorn | |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |