Spaces:
Sleeping
Sleeping
# Use NVIDIA CUDA base image with Ubuntu 22.04, CUDA 12.2, and cuDNN 8 | |
FROM nvidia/cuda:12.2.2-cudnn8-runtime-ubuntu22.04 | |
# Set Python to run in unbuffered mode for better logging | |
ENV PYTHONUNBUFFERED=1 | |
# Install Python 3.10, pip, and system dependencies in a single layer | |
RUN apt-get update && apt-get install -y --no-install-recommends \ | |
python3.10 \ | |
python3-pip \ | |
libgl1 \ | |
&& ln -s /usr/bin/python3.10 /usr/bin/python \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Copy and install Python requirements | |
COPY requirements.txt . | |
RUN pip install --no-cache-dir -r requirements.txt | |
# Copy application code | |
COPY main.py utils.py ./ | |
# Verify the application can be imported without errors | |
RUN python -c "from main import app" | |
# Expose the application port | |
EXPOSE 7860 | |
# Start the FastAPI server | |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] |