Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +16 -10
Dockerfile
CHANGED
@@ -1,22 +1,28 @@
|
|
1 |
-
# Use slim base image
|
2 |
FROM python:3.10-slim
|
3 |
|
4 |
-
#
|
5 |
-
RUN mkdir -p /home/user/.cache && chmod -R 777 /home/user/.cache
|
6 |
-
|
7 |
WORKDIR /app
|
8 |
|
9 |
-
#
|
10 |
-
ENV HF_HOME=/home/user/.cache/huggingface \
|
11 |
-
TRANSFORMERS_CACHE=/home/user/.cache/huggingface \
|
12 |
-
SENTENCE_TRANSFORMERS_HOME=/home/user/.cache/huggingface
|
13 |
-
|
14 |
-
# Install dependencies
|
15 |
COPY requirements.txt .
|
16 |
RUN pip install --no-cache-dir -r requirements.txt
|
17 |
|
|
|
18 |
COPY . .
|
19 |
|
|
|
20 |
ENV PYTHONUNBUFFERED=1
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
1 |
+
# Use a slim Python base image
|
2 |
FROM python:3.10-slim
|
3 |
|
4 |
+
# Set working directory
|
|
|
|
|
5 |
WORKDIR /app
|
6 |
|
7 |
+
# Install Python dependencies
|
|
|
|
|
|
|
|
|
|
|
8 |
COPY requirements.txt .
|
9 |
RUN pip install --no-cache-dir -r requirements.txt
|
10 |
|
11 |
+
# Copy project files
|
12 |
COPY . .
|
13 |
|
14 |
+
# Set environment for faster, clearer logging
|
15 |
ENV PYTHONUNBUFFERED=1
|
16 |
|
17 |
+
# Set cache directories to writable /tmp
|
18 |
+
ENV HF_HOME=/tmp/huggingface \
|
19 |
+
TRANSFORMERS_CACHE=/tmp/huggingface/transformers \
|
20 |
+
HF_DATASETS_CACHE=/tmp/huggingface/datasets \
|
21 |
+
HUGGINGFACE_HUB_CACHE=/tmp/huggingface/hub \
|
22 |
+
XDG_CACHE_HOME=/tmp/huggingface
|
23 |
+
|
24 |
+
# Expose the HF Spaces-required port
|
25 |
+
EXPOSE 7860
|
26 |
+
|
27 |
+
# Start the FastAPI app via uvicorn
|
28 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|