Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +22 -15
Dockerfile
CHANGED
|
@@ -1,28 +1,35 @@
|
|
| 1 |
FROM python:3.11.9-slim
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
RUN apt-get update && apt-get install -y \
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
&& rm -rf /var/lib/apt/lists/*
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
|
|
|
|
|
|
| 15 |
RUN pip3 install -r requirements.txt
|
| 16 |
|
| 17 |
-
#
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
EXPOSE 8501
|
| 25 |
-
|
| 26 |
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
|
| 27 |
|
| 28 |
ENTRYPOINT ["streamlit", "run", "src/app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|
|
|
|
| 1 |
FROM python:3.11.9-slim
|
| 2 |
|
| 3 |
+
# 1) System deps
|
|
|
|
| 4 |
RUN apt-get update && apt-get install -y \
|
| 5 |
+
build-essential \
|
| 6 |
+
curl \
|
| 7 |
+
software-properties-common \
|
| 8 |
+
git \
|
| 9 |
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
|
| 11 |
+
# 2) Create app user with home dir
|
| 12 |
+
RUN useradd -m -u 10001 -s /usr/sbin/nologin appuser
|
| 13 |
+
|
| 14 |
+
WORKDIR /app
|
| 15 |
+
# Make sure /app is owned by our user
|
| 16 |
+
RUN chown appuser:appuser /app
|
| 17 |
|
| 18 |
+
# 3) Copy & install Python deps as root
|
| 19 |
+
COPY requirements.txt .
|
| 20 |
RUN pip3 install -r requirements.txt
|
| 21 |
|
| 22 |
+
# 4) Copy your source & switch to nonβroot
|
| 23 |
+
COPY src/ ./src/
|
| 24 |
+
USER appuser
|
| 25 |
+
|
| 26 |
+
# 5) Ensure Streamlit config dir exists in the new home
|
| 27 |
+
ENV HOME=/home/appuser \
|
| 28 |
+
STREAMLIT_DATA_DIR=/home/appuser/.streamlit \
|
| 29 |
+
XDG_CONFIG_HOME=/home/appuser/.streamlit
|
| 30 |
+
RUN mkdir -p /home/appuser/.streamlit
|
| 31 |
|
| 32 |
EXPOSE 8501
|
|
|
|
| 33 |
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
|
| 34 |
|
| 35 |
ENTRYPOINT ["streamlit", "run", "src/app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|