Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +19 -14
Dockerfile
CHANGED
@@ -1,26 +1,31 @@
|
|
|
|
1 |
FROM python:3.9-slim
|
2 |
|
3 |
-
# Set
|
4 |
ENV HF_HOME=/app/.cache/huggingface
|
5 |
|
|
|
6 |
WORKDIR /app
|
7 |
|
8 |
-
#
|
|
|
|
|
|
|
9 |
COPY requirements.txt .
|
10 |
RUN pip install --no-cache-dir -r requirements.txt
|
11 |
|
12 |
-
# Copy
|
13 |
-
COPY
|
14 |
-
|
15 |
-
# Set environment variable for HF token (pass your real token at build/run time or use build args)
|
16 |
-
ARG HF_TOKEN
|
17 |
-
ENV HF_TOKEN=${HF_TOKEN}
|
18 |
|
19 |
-
#
|
20 |
-
|
|
|
|
|
|
|
|
|
21 |
|
22 |
-
# Expose
|
23 |
-
EXPOSE
|
24 |
|
25 |
-
# Run
|
26 |
-
CMD ["streamlit", "run", "src/streamlit_app.py", "--server.port=
|
|
|
1 |
+
# Use lightweight Python base image
|
2 |
FROM python:3.9-slim
|
3 |
|
4 |
+
# Set Hugging Face cache directory (replaces deprecated TRANSFORMERS_CACHE)
|
5 |
ENV HF_HOME=/app/.cache/huggingface
|
6 |
|
7 |
+
# Set working directory
|
8 |
WORKDIR /app
|
9 |
|
10 |
+
# Create cache directory with open permissions
|
11 |
+
RUN mkdir -p /app/.cache/huggingface && chmod -R 777 /app/.cache/huggingface
|
12 |
+
|
13 |
+
# Install Python dependencies
|
14 |
COPY requirements.txt .
|
15 |
RUN pip install --no-cache-dir -r requirements.txt
|
16 |
|
17 |
+
# Copy app files
|
18 |
+
COPY . .
|
|
|
|
|
|
|
|
|
19 |
|
20 |
+
# Preload gated and public models using secret HF_TOKEN
|
21 |
+
RUN python3 -c "import os; from transformers import pipeline; \
|
22 |
+
pipe = pipeline('summarization', model='mistralai/Mistral-7B-Instruct-v0.1', \
|
23 |
+
tokenizer='mistralai/Mistral-7B-Instruct-v0.1', use_auth_token=os.getenv('HF_TOKEN'))" && \
|
24 |
+
python3 -c "from transformers import pipeline; \
|
25 |
+
pipeline('sentiment-analysis', model='distilbert-base-uncased-finetuned-sst-2-english')"
|
26 |
|
27 |
+
# Expose Streamlit default port
|
28 |
+
EXPOSE 7860
|
29 |
|
30 |
+
# Run Streamlit app
|
31 |
+
CMD ["streamlit", "run", "src/streamlit_app.py", "--server.port=7860", "--server.address=0.0.0.0"]
|