Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +10 -9
Dockerfile
CHANGED
|
@@ -3,19 +3,11 @@ FROM python:3.11-slim
|
|
| 3 |
|
| 4 |
# Set environment variables to avoid writing to root
|
| 5 |
# Optional: Disable Usage Stats (telemetry) for Privacy / Stability
|
| 6 |
-
ENV HOME=/root
|
| 7 |
-
ENV MPLCONFIGDIR=/root/.config/matplotlib
|
| 8 |
-
ENV STREAMLIT_CONFIG_DIR=/root/.streamlit
|
| 9 |
ENV STREAMLIT_DISABLE_USAGE_STATS=true
|
| 10 |
|
| 11 |
# Set working directory inside container
|
| 12 |
WORKDIR /app
|
| 13 |
|
| 14 |
-
# Ensure /app and cache/config directories exist with proper permissions
|
| 15 |
-
RUN chown -R root:root /app && \
|
| 16 |
-
mkdir -p /root/.cache /root/.config/matplotlib /root/.streamlit && \
|
| 17 |
-
chmod -R 777 /root/.cache /root/.config /root/.streamlit /app
|
| 18 |
-
|
| 19 |
# Install dependencies
|
| 20 |
RUN apt-get update && apt-get install -y \
|
| 21 |
build-essential \
|
|
@@ -31,12 +23,21 @@ RUN apt-get update && apt-get install -y \
|
|
| 31 |
graphviz \
|
| 32 |
&& rm -rf /var/lib/apt/lists/*
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
# Copy source and requirements
|
| 35 |
COPY requirements.txt ./
|
| 36 |
COPY src/ ./src/
|
| 37 |
|
| 38 |
# Install Python dependencies including streamlit
|
| 39 |
-
RUN pip3 install -r requirements.txt
|
| 40 |
|
| 41 |
# Expose port
|
| 42 |
EXPOSE 8501
|
|
|
|
| 3 |
|
| 4 |
# Set environment variables to avoid writing to root
|
| 5 |
# Optional: Disable Usage Stats (telemetry) for Privacy / Stability
|
|
|
|
|
|
|
|
|
|
| 6 |
ENV STREAMLIT_DISABLE_USAGE_STATS=true
|
| 7 |
|
| 8 |
# Set working directory inside container
|
| 9 |
WORKDIR /app
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
# Install dependencies
|
| 12 |
RUN apt-get update && apt-get install -y \
|
| 13 |
build-essential \
|
|
|
|
| 23 |
graphviz \
|
| 24 |
&& rm -rf /var/lib/apt/lists/*
|
| 25 |
|
| 26 |
+
# Create a non-root user
|
| 27 |
+
RUN useradd --create-home --shell /bin/bash appuser
|
| 28 |
+
|
| 29 |
+
# Set permissions for the working directory
|
| 30 |
+
RUN chown -R appuser:appuser /app
|
| 31 |
+
|
| 32 |
+
# Switch to non-root user
|
| 33 |
+
USER appuser
|
| 34 |
+
|
| 35 |
# Copy source and requirements
|
| 36 |
COPY requirements.txt ./
|
| 37 |
COPY src/ ./src/
|
| 38 |
|
| 39 |
# Install Python dependencies including streamlit
|
| 40 |
+
RUN pip3 install --no-cache-dir --user -r requirements.txt
|
| 41 |
|
| 42 |
# Expose port
|
| 43 |
EXPOSE 8501
|