Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +14 -23
Dockerfile
CHANGED
@@ -1,38 +1,32 @@
|
|
1 |
FROM python:3.10-slim
|
2 |
|
3 |
-
#
|
4 |
-
|
5 |
-
|
|
|
|
|
|
|
6 |
ENV PIP_NO_CACHE_DIR=1 \
|
7 |
PYTHONUNBUFFERED=1 \
|
8 |
EMBED_MODEL=Seznam/simcse-small-e-czech \
|
9 |
MIN_TOPIC_SIZE=10 \
|
10 |
MAX_DOCS=5000
|
11 |
|
12 |
-
#
|
13 |
-
# 2. Writable cache directories for Hugging Face & sentence-transformers
|
14 |
-
# ------------------------------------------------------------------
|
15 |
ENV HF_HOME=/tmp/hfcache \
|
16 |
TRANSFORMERS_CACHE=/tmp/hfcache \
|
17 |
-
SENTENCE_TRANSFORMERS_HOME=/tmp/hfcache
|
18 |
-
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
# ------------------------------------------------------------------
|
23 |
-
ENV NUMBA_CACHE_DIR=/tmp/numba_cache
|
24 |
-
RUN mkdir -p /tmp/numba_cache && chmod -R 777 /tmp/numba_cache
|
25 |
|
26 |
-
#
|
27 |
-
# 4. Install Python deps
|
28 |
-
# ------------------------------------------------------------------
|
29 |
WORKDIR /code
|
30 |
COPY requirements.txt .
|
31 |
RUN pip install --no-cache-dir -r requirements.txt
|
32 |
|
33 |
-
#
|
34 |
-
# 5. Pre-download the Czech SBERT and make that cache world-readable
|
35 |
-
# ------------------------------------------------------------------
|
36 |
RUN python - <<'PY'
|
37 |
from sentence_transformers import SentenceTransformer
|
38 |
SentenceTransformer(
|
@@ -42,10 +36,7 @@ SentenceTransformer(
|
|
42 |
PY
|
43 |
RUN chmod -R 777 /tmp/hfcache
|
44 |
|
45 |
-
#
|
46 |
-
# 6. Copy your app and run
|
47 |
-
# ------------------------------------------------------------------
|
48 |
COPY app.py .
|
49 |
-
|
50 |
EXPOSE 7860
|
51 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
1 |
FROM python:3.10-slim
|
2 |
|
3 |
+
# 1. Install git for pip VCS installs + clean up apt lists
|
4 |
+
RUN apt-get update \
|
5 |
+
&& apt-get install -y --no-install-recommends git \
|
6 |
+
&& rm -rf /var/lib/apt/lists/*
|
7 |
+
|
8 |
+
# 2. Generic runtime env flags
|
9 |
ENV PIP_NO_CACHE_DIR=1 \
|
10 |
PYTHONUNBUFFERED=1 \
|
11 |
EMBED_MODEL=Seznam/simcse-small-e-czech \
|
12 |
MIN_TOPIC_SIZE=10 \
|
13 |
MAX_DOCS=5000
|
14 |
|
15 |
+
# 3. Hugging Face / SBERT cache dirs (writable)
|
|
|
|
|
16 |
ENV HF_HOME=/tmp/hfcache \
|
17 |
TRANSFORMERS_CACHE=/tmp/hfcache \
|
18 |
+
SENTENCE_TRANSFORMERS_HOME=/tmp/hfcache \
|
19 |
+
NUMBA_CACHE_DIR=/tmp/numba_cache
|
20 |
|
21 |
+
RUN mkdir -p /tmp/hfcache /tmp/numba_cache \
|
22 |
+
&& chmod -R 777 /tmp/hfcache /tmp/numba_cache
|
|
|
|
|
|
|
23 |
|
24 |
+
# 4. Install Python deps in one shot
|
|
|
|
|
25 |
WORKDIR /code
|
26 |
COPY requirements.txt .
|
27 |
RUN pip install --no-cache-dir -r requirements.txt
|
28 |
|
29 |
+
# 5. Pre-download the Czech SBERT model so it’s cached ahead of runtime
|
|
|
|
|
30 |
RUN python - <<'PY'
|
31 |
from sentence_transformers import SentenceTransformer
|
32 |
SentenceTransformer(
|
|
|
36 |
PY
|
37 |
RUN chmod -R 777 /tmp/hfcache
|
38 |
|
39 |
+
# 6. Copy app and expose/run
|
|
|
|
|
40 |
COPY app.py .
|
|
|
41 |
EXPOSE 7860
|
42 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|