Spaces:
Sleeping
Sleeping
File size: 1,095 Bytes
641b34a d00d46d 641b34a e014c8e 641b34a d00d46d 0ede3b3 d00d46d 498eb8f 641b34a 498eb8f 641b34a 498eb8f 641b34a 498eb8f 641b34a 498eb8f 641b34a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | # 1. Base Image Declaration (Corrected 'slim' tag)
FROM python:3.11-slim
# 2. Environment Variables & Cleanup
# Suppress Matplotlib cache permission warning
ENV MPLCONFIGDIR /tmp/.matplotlib
# Explicitly force CPU and suppress CUDA warnings (if not using a GPU space)
ENV CUDA_VISIBLE_DEVICES=""
# Ensure Python output is immediately available in logs
ENV PYTHONUNBUFFERED True
# Set the port required by Hugging Face Spaces/Uvicorn
ENV PORT 7860
# 3. System Dependencies (Required by OpenCV/cv2)
RUN apt-get update && \
apt-get install -y libgl1 libglib2.0-0 libsm6 libxext6 && \
rm -rf /var/lib/apt/lists/*
# 4. Working Directory
WORKDIR /app
# 5. Dependency Installation (Leverages Docker caching)
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# 6. Application Code
COPY . .
# 7. Port Documentation (EXPOSE is optional but good practice)
EXPOSE 7860
# 8. Define the command to start the Uvicorn server
# This runs the 'app' object in the 'app.py' module, listening on port 7860.
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|