Update Dockerfile
Browse files- Dockerfile +5 -7
Dockerfile
CHANGED
|
@@ -2,9 +2,11 @@ FROM python:3.9-slim
|
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
-
# Install system dependencies
|
|
|
|
| 6 |
RUN apt-get update && apt-get install -y \
|
| 7 |
libgl1-mesa-glx \
|
|
|
|
| 8 |
&& rm -rf /var/lib/apt/lists/*
|
| 9 |
|
| 10 |
# Copy requirements and install dependencies as root to leverage caching
|
|
@@ -12,7 +14,6 @@ COPY requirements.txt ./
|
|
| 12 |
RUN pip3 install --no-cache-dir -r requirements.txt
|
| 13 |
|
| 14 |
# Copy the application code from your local `src` folder
|
| 15 |
-
# This will copy `src/streamlit_app.py` and `src/best.pt` to the container
|
| 16 |
COPY src/ ./src/
|
| 17 |
|
| 18 |
# --- User and Permission Setup ---
|
|
@@ -22,8 +23,7 @@ RUN groupadd --system appuser && useradd --system --gid appuser appuser
|
|
| 22 |
# Change ownership of the entire app directory to the new user
|
| 23 |
RUN chown -R appuser:appuser /app
|
| 24 |
|
| 25 |
-
# Set the HOME environment variable for the non-root user
|
| 26 |
-
# THIS IS THE CRITICAL FIX for the original PermissionError.
|
| 27 |
ENV HOME=/app
|
| 28 |
|
| 29 |
# Switch to the non-root user for security
|
|
@@ -34,7 +34,5 @@ EXPOSE 8501
|
|
| 34 |
|
| 35 |
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
|
| 36 |
|
| 37 |
-
#
|
| 38 |
-
# Removed the unsupported `--global.gatherUsageStats` flag.
|
| 39 |
-
# The `--browser.gatherUsageStats=false` is still valid and good practice.
|
| 40 |
ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0", "--browser.gatherUsageStats=false"]
|
|
|
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
+
# Install system dependencies
|
| 6 |
+
# ADDED libglib2.0-0 to fix the "libgthread" ImportError from OpenCV
|
| 7 |
RUN apt-get update && apt-get install -y \
|
| 8 |
libgl1-mesa-glx \
|
| 9 |
+
libglib2.0-0 \
|
| 10 |
&& rm -rf /var/lib/apt/lists/*
|
| 11 |
|
| 12 |
# Copy requirements and install dependencies as root to leverage caching
|
|
|
|
| 14 |
RUN pip3 install --no-cache-dir -r requirements.txt
|
| 15 |
|
| 16 |
# Copy the application code from your local `src` folder
|
|
|
|
| 17 |
COPY src/ ./src/
|
| 18 |
|
| 19 |
# --- User and Permission Setup ---
|
|
|
|
| 23 |
# Change ownership of the entire app directory to the new user
|
| 24 |
RUN chown -R appuser:appuser /app
|
| 25 |
|
| 26 |
+
# Set the HOME environment variable for the non-root user (fixes PermissionError)
|
|
|
|
| 27 |
ENV HOME=/app
|
| 28 |
|
| 29 |
# Switch to the non-root user for security
|
|
|
|
| 34 |
|
| 35 |
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
|
| 36 |
|
| 37 |
+
# Run the app and disable telemetry
|
|
|
|
|
|
|
| 38 |
ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0", "--browser.gatherUsageStats=false"]
|