Update Dockerfile
Browse files- Dockerfile +18 -9
Dockerfile
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
FROM python:3.13.5-slim
|
| 2 |
|
| 3 |
-
|
|
|
|
| 4 |
|
| 5 |
-
WORKDIR /app
|
| 6 |
|
| 7 |
RUN apt-get update && apt-get install -y \
|
| 8 |
build-essential \
|
|
@@ -10,8 +24,8 @@ RUN apt-get update && apt-get install -y \
|
|
| 10 |
git \
|
| 11 |
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
|
| 13 |
-
COPY requirements.txt ./
|
| 14 |
-
COPY src/ ./src/
|
| 15 |
|
| 16 |
RUN pip3 install -r requirements.txt
|
| 17 |
|
|
@@ -19,9 +33,4 @@ EXPOSE 8501
|
|
| 19 |
|
| 20 |
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
|
| 21 |
|
| 22 |
-
USER user
|
| 23 |
-
|
| 24 |
-
ENV HOME=/home/user \
|
| 25 |
-
PATH=/home/user/.local/bin:$PATH
|
| 26 |
-
|
| 27 |
ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|
|
|
|
| 1 |
+
# Set up a new user named "user" with user ID 1000
|
| 2 |
+
RUN useradd -m -u 1000 user
|
| 3 |
+
|
| 4 |
+
# Switch to the "user" user
|
| 5 |
+
USER user
|
| 6 |
+
|
| 7 |
+
# Set home to the user's home directory
|
| 8 |
+
ENV HOME=/home/user \
|
| 9 |
+
PATH=/home/user/.local/bin:$PATH
|
| 10 |
+
|
| 11 |
+
# Set the working directory to the user's home directory
|
| 12 |
+
WORKDIR $HOME/app
|
| 13 |
+
|
| 14 |
FROM python:3.13.5-slim
|
| 15 |
|
| 16 |
+
# Try and run pip command after setting the user with `USER user` to avoid permission issues with Python
|
| 17 |
+
RUN pip install --no-cache-dir --upgrade pip
|
| 18 |
|
| 19 |
+
# WORKDIR /app
|
| 20 |
|
| 21 |
RUN apt-get update && apt-get install -y \
|
| 22 |
build-essential \
|
|
|
|
| 24 |
git \
|
| 25 |
&& rm -rf /var/lib/apt/lists/*
|
| 26 |
|
| 27 |
+
COPY --chown=user requirements.txt ./
|
| 28 |
+
COPY --chown=user src/ ./src/
|
| 29 |
|
| 30 |
RUN pip3 install -r requirements.txt
|
| 31 |
|
|
|
|
| 33 |
|
| 34 |
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|