Update Dockerfile
Browse files- Dockerfile +17 -7
Dockerfile
CHANGED
|
@@ -1,8 +1,11 @@
|
|
| 1 |
FROM python:3.9-slim
|
| 2 |
|
|
|
|
|
|
|
|
|
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
-
# Install system dependencies
|
| 6 |
RUN apt-get update && apt-get install -y \
|
| 7 |
build-essential \
|
| 8 |
curl \
|
|
@@ -11,16 +14,23 @@ RUN apt-get update && apt-get install -y \
|
|
| 11 |
libgl1 \
|
| 12 |
&& rm -rf /var/lib/apt/lists/*
|
| 13 |
|
| 14 |
-
# Set up
|
| 15 |
-
RUN mkdir -p /app/.streamlit /app/.config
|
|
|
|
|
|
|
|
|
|
| 16 |
ENV HOME=/app
|
| 17 |
ENV XDG_CONFIG_HOME=/app/.config
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
# Install
|
| 23 |
-
RUN
|
| 24 |
|
| 25 |
EXPOSE 8501
|
| 26 |
|
|
|
|
| 1 |
FROM python:3.9-slim
|
| 2 |
|
| 3 |
+
# Create non-root user
|
| 4 |
+
RUN useradd -m streamlituser
|
| 5 |
+
|
| 6 |
WORKDIR /app
|
| 7 |
|
| 8 |
+
# Install system dependencies
|
| 9 |
RUN apt-get update && apt-get install -y \
|
| 10 |
build-essential \
|
| 11 |
curl \
|
|
|
|
| 14 |
libgl1 \
|
| 15 |
&& rm -rf /var/lib/apt/lists/*
|
| 16 |
|
| 17 |
+
# Set up config dirs and set permissions
|
| 18 |
+
RUN mkdir -p /app/.streamlit /app/.config /app/src && \
|
| 19 |
+
chown -R streamlituser:streamlituser /app
|
| 20 |
+
|
| 21 |
+
# Set environment variables
|
| 22 |
ENV HOME=/app
|
| 23 |
ENV XDG_CONFIG_HOME=/app/.config
|
| 24 |
|
| 25 |
+
# Switch to non-root user
|
| 26 |
+
USER streamlituser
|
| 27 |
+
|
| 28 |
+
# Copy files after switching to the user to preserve ownership
|
| 29 |
+
COPY --chown=streamlituser:streamlituser requirements.txt ./
|
| 30 |
+
COPY --chown=streamlituser:streamlituser src/ ./src/
|
| 31 |
|
| 32 |
+
# Install dependencies
|
| 33 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 34 |
|
| 35 |
EXPOSE 8501
|
| 36 |
|