FROM python:3.8-slim WORKDIR /code # Install system dependencies RUN apt-get update && apt-get install -y \ build-essential \ python3-dev \ git \ libcairo2-dev \ pkg-config \ && rm -rf /var/lib/apt/lists/* # Install PyTorch and torchvision RUN pip install torch==2.0.0 torchvision==0.15.1 --extra-index-url https://download.pytorch.org/whl/cpu # Install cairosvg and other dependencies RUN pip install cairosvg cairocffi cssselect2 defusedxml tinycss2 # Install FastAPI and other dependencies RUN pip install fastapi uvicorn pydantic pillow numpy requests # Copy the model files COPY . /code/ # Set environment variables ENV PYTHONUNBUFFERED=1 # Run the API server CMD ["uvicorn", "api:app", "--host", "0.0.0.0", "--port", "8000"]