Update Dockerfile
Browse files- Dockerfile +19 -5
Dockerfile
CHANGED
|
@@ -8,14 +8,28 @@ RUN apt-get update && apt-get install -y \
|
|
| 8 |
git \
|
| 9 |
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
|
|
|
| 13 |
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
EXPOSE 8501
|
| 18 |
|
| 19 |
-
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
|
| 20 |
|
| 21 |
-
ENTRYPOINT ["streamlit", "run", "src/app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|
|
|
|
| 8 |
git \
|
| 9 |
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
|
| 11 |
+
# Create a non-root user
|
| 12 |
+
RUN useradd -ms /bin/bash appuser
|
| 13 |
+
USER appuser
|
| 14 |
|
| 15 |
+
# Set Hugging Face & Streamlit cache dirs to user-writable locations
|
| 16 |
+
ENV TRANSFORMERS_CACHE=/app/.cache/huggingface/transformers
|
| 17 |
+
ENV HF_HOME=/app/.cache/huggingface
|
| 18 |
+
ENV XDG_CACHE_HOME=/app/.cache
|
| 19 |
+
ENV STREAMLIT_HOME=/app/.streamlit
|
| 20 |
+
|
| 21 |
+
# Make directories
|
| 22 |
+
RUN mkdir -p $TRANSFORMERS_CACHE $HF_HOME $XDG_CACHE_HOME $STREAMLIT_HOME
|
| 23 |
|
| 24 |
+
# Copy code
|
| 25 |
+
COPY --chown=appuser:appuser requirements.txt ./
|
| 26 |
+
COPY --chown=appuser:appuser src/ ./src/
|
| 27 |
+
|
| 28 |
+
# Install dependencies
|
| 29 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 30 |
|
| 31 |
EXPOSE 8501
|
| 32 |
|
| 33 |
+
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
|
| 34 |
|
| 35 |
+
ENTRYPOINT ["streamlit", "run", "src/app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|