Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +11 -15
Dockerfile
CHANGED
|
@@ -1,15 +1,16 @@
|
|
| 1 |
# Use lightweight python 3.9 image
|
| 2 |
FROM python:3.9-slim
|
|
|
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
-
# Install system
|
| 6 |
RUN apt-get update && apt-get install -y \
|
| 7 |
build-essential \
|
| 8 |
git \
|
| 9 |
-
curl \
|
| 10 |
-
|
| 11 |
|
| 12 |
-
# Set
|
| 13 |
ENV HF_HOME=/app/model_cache
|
| 14 |
ENV STREAMLIT_CONFIG_DIR=/app/.streamlit
|
| 15 |
|
|
@@ -18,24 +19,19 @@ COPY requirements.txt ./
|
|
| 18 |
COPY .streamlit/ .streamlit/
|
| 19 |
COPY src/ ./src/
|
| 20 |
|
| 21 |
-
# Install Python
|
| 22 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 23 |
|
| 24 |
-
# Create cache and config
|
| 25 |
RUN mkdir -p /app/model_cache && chmod -R 777 /app/model_cache
|
| 26 |
RUN mkdir -p /app/.streamlit && chmod -R 777 /app/.streamlit
|
| 27 |
|
| 28 |
-
# Pre-download
|
| 29 |
-
RUN python -c "from transformers import pipeline; pipeline('zero-shot-classification', model='facebook/bart-large-mnli'
|
| 30 |
-
python -c "from transformers import pipeline; pipeline('sentiment-analysis', model='distilbert-base-uncased-finetuned-sst-2-english'
|
| 31 |
-
python -c "from transformers import pipeline; pipeline('summarization', model='sshleifer/distilbart-cnn-6-6'
|
| 32 |
python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-MiniLM-L6-v2')"
|
| 33 |
|
| 34 |
-
# Expose Streamlit port
|
| 35 |
EXPOSE 8501
|
| 36 |
-
|
| 37 |
-
# Healthcheck to verify Streamlit is running
|
| 38 |
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
|
| 39 |
-
|
| 40 |
-
# Entrypoint to launch Streamlit app
|
| 41 |
ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|
|
|
|
| 1 |
# Use lightweight python 3.9 image
|
| 2 |
FROM python:3.9-slim
|
| 3 |
+
|
| 4 |
WORKDIR /app
|
| 5 |
|
| 6 |
+
# Install system deps
|
| 7 |
RUN apt-get update && apt-get install -y \
|
| 8 |
build-essential \
|
| 9 |
git \
|
| 10 |
+
curl && \
|
| 11 |
+
rm -rf /var/lib/apt/lists/*
|
| 12 |
|
| 13 |
+
# Set Hugging Face cache path
|
| 14 |
ENV HF_HOME=/app/model_cache
|
| 15 |
ENV STREAMLIT_CONFIG_DIR=/app/.streamlit
|
| 16 |
|
|
|
|
| 19 |
COPY .streamlit/ .streamlit/
|
| 20 |
COPY src/ ./src/
|
| 21 |
|
| 22 |
+
# Install Python deps
|
| 23 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 24 |
|
| 25 |
+
# Create cache and config dirs with permissions
|
| 26 |
RUN mkdir -p /app/model_cache && chmod -R 777 /app/model_cache
|
| 27 |
RUN mkdir -p /app/.streamlit && chmod -R 777 /app/.streamlit
|
| 28 |
|
| 29 |
+
# Pre-download models to cache
|
| 30 |
+
RUN python -c "from transformers import pipeline; pipeline('zero-shot-classification', model='facebook/bart-large-mnli')" && \
|
| 31 |
+
python -c "from transformers import pipeline; pipeline('sentiment-analysis', model='distilbert-base-uncased-finetuned-sst-2-english')" && \
|
| 32 |
+
python -c "from transformers import pipeline; pipeline('summarization', model='sshleifer/distilbart-cnn-6-6')" && \
|
| 33 |
python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-MiniLM-L6-v2')"
|
| 34 |
|
|
|
|
| 35 |
EXPOSE 8501
|
|
|
|
|
|
|
| 36 |
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
|
|
|
|
|
|
|
| 37 |
ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|