Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +15 -6
Dockerfile
CHANGED
|
@@ -1,20 +1,29 @@
|
|
| 1 |
-
# Use lightweight Python base image
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
# Set working directory
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
# Copy
|
| 8 |
COPY requirements.txt .
|
| 9 |
|
| 10 |
# Install dependencies
|
| 11 |
-
RUN pip install --no-cache-dir
|
| 12 |
|
| 13 |
-
# Copy the app
|
| 14 |
COPY app.py .
|
| 15 |
|
| 16 |
-
# Expose the port Hugging Face Spaces
|
| 17 |
EXPOSE 7860
|
| 18 |
|
| 19 |
-
#
|
| 20 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
|
|
|
|
|
| 1 |
FROM python:3.10-slim
|
| 2 |
|
| 3 |
+
# Create writable cache directory for Hugging Face
|
| 4 |
+
RUN mkdir -p /tmp/huggingface && chmod -R 777 /tmp/huggingface
|
| 5 |
+
|
| 6 |
+
# Set environment variables globally (before Python starts)
|
| 7 |
+
ENV HF_HOME=/tmp/huggingface
|
| 8 |
+
ENV TRANSFORMERS_CACHE=/tmp/huggingface/transformers
|
| 9 |
+
ENV HF_DATASETS_CACHE=/tmp/huggingface/datasets
|
| 10 |
+
ENV XDG_CACHE_HOME=/tmp/huggingface
|
| 11 |
+
|
| 12 |
# Set working directory
|
| 13 |
WORKDIR /app
|
| 14 |
|
| 15 |
+
# Copy dependencies
|
| 16 |
COPY requirements.txt .
|
| 17 |
|
| 18 |
# Install dependencies
|
| 19 |
+
RUN pip install --no-cache-dir fastapi uvicorn transformers torch
|
| 20 |
|
| 21 |
+
# Copy the FastAPI app
|
| 22 |
COPY app.py .
|
| 23 |
|
| 24 |
+
# Expose the port expected by Hugging Face Spaces
|
| 25 |
EXPOSE 7860
|
| 26 |
|
| 27 |
+
# Run FastAPI server
|
| 28 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
| 29 |
+
|