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 CLIP RUN pip install git+https://github.com/openai/CLIP.git # 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/ # Make sure the handler and model are available RUN if [ -f /code/simplified_diffsketcher.py ]; then \ echo "Simplified DiffSketcher found"; \ else \ echo "Simplified DiffSketcher not found, using placeholder"; \ fi # Set environment variables ENV PYTHONUNBUFFERED=1 # Run the API server CMD ["uvicorn", "api:app", "--host", "0.0.0.0", "--port", "8000"]