Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +10 -1
Dockerfile
CHANGED
|
@@ -14,7 +14,12 @@ RUN apt-get update && apt-get install -y \
|
|
| 14 |
# Upgrade pip
|
| 15 |
RUN python3 -m pip install --upgrade pip
|
| 16 |
|
| 17 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
COPY requirements.txt .
|
| 19 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 20 |
|
|
@@ -24,5 +29,9 @@ COPY app.py .
|
|
| 24 |
# Expose port (HF Spaces default)
|
| 25 |
EXPOSE 7860
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
# Run the FastAPI app with Uvicorn (workers=1 for single GPU, host=0.0.0.0 for external access)
|
| 28 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]
|
|
|
|
| 14 |
# Upgrade pip
|
| 15 |
RUN python3 -m pip install --upgrade pip
|
| 16 |
|
| 17 |
+
# Set cache directories to writable /app/.cache (fixes PermissionError)
|
| 18 |
+
ENV TRANSFORMERS_CACHE=/app/.cache/transformers
|
| 19 |
+
ENV HF_HOME=/app/.cache/huggingface
|
| 20 |
+
RUN mkdir -p /app/.cache/transformers /app/.cache/huggingface
|
| 21 |
+
|
| 22 |
+
# Copy requirements and install Python deps (no cache to slim image)
|
| 23 |
COPY requirements.txt .
|
| 24 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 25 |
|
|
|
|
| 29 |
# Expose port (HF Spaces default)
|
| 30 |
EXPOSE 7860
|
| 31 |
|
| 32 |
+
# Health check (optional, for Spaces monitoring)
|
| 33 |
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
|
| 34 |
+
CMD curl -f http://localhost:7860/health || exit 1
|
| 35 |
+
|
| 36 |
# Run the FastAPI app with Uvicorn (workers=1 for single GPU, host=0.0.0.0 for external access)
|
| 37 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]
|