Spaces:
Sleeping
Sleeping
Fix PermissionError by setting TRANSFORMERS_CACHE to /app/.cache
Browse files- Dockerfile +13 -0
- requirements.txt +2 -1
Dockerfile
CHANGED
|
@@ -2,11 +2,24 @@ FROM python:3.9-slim
|
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
|
|
|
| 5 |
COPY requirements.txt .
|
|
|
|
|
|
|
| 6 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 7 |
|
|
|
|
| 8 |
COPY . .
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
EXPOSE 7860
|
| 11 |
|
|
|
|
| 12 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
+
# Copy requirements first to leverage caching
|
| 6 |
COPY requirements.txt .
|
| 7 |
+
|
| 8 |
+
# Install dependencies
|
| 9 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 10 |
|
| 11 |
+
# Copy the rest of the application
|
| 12 |
COPY . .
|
| 13 |
|
| 14 |
+
# Set environment variable for Hugging Face cache
|
| 15 |
+
ENV TRANSFORMERS_CACHE=/app/.cache
|
| 16 |
+
ENV HF_HOME=/app/.cache/huggingface
|
| 17 |
+
|
| 18 |
+
# Create cache directory and set permissions
|
| 19 |
+
RUN mkdir -p /app/.cache && chmod -R 777 /app/.cache
|
| 20 |
+
|
| 21 |
+
# Expose the port
|
| 22 |
EXPOSE 7860
|
| 23 |
|
| 24 |
+
# Run the application
|
| 25 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
requirements.txt
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
fastapi
|
| 2 |
uvicorn
|
| 3 |
transformers
|
| 4 |
-
torch
|
|
|
|
|
|
| 1 |
fastapi
|
| 2 |
uvicorn
|
| 3 |
transformers
|
| 4 |
+
torch
|
| 5 |
+
huggingface_hub
|