newHandsupModel / Dockerfile
mutarisi
docker port
ed81575
# 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"]