File size: 1,162 Bytes
aacb488
 
 
 
1f9cc8d
 
aacb488
c4efd9b
1f9cc8d
aacb488
 
c4efd9b
b69043f
 
aacb488
c4efd9b
 
 
 
01aa22b
 
 
c4efd9b
01aa22b
 
1f9cc8d
c4efd9b
01aa22b
c4efd9b
 
 
01aa22b
aacb488
 
47ef030
aacb488
1f9cc8d
dc55fde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
FROM python:3.9-slim

WORKDIR /app

# Install system dependencies
# ADDED libglib2.0-0 to fix the "libgthread" ImportError from OpenCV
RUN apt-get update && apt-get install -y \
    libgl1-mesa-glx \
    libglib2.0-0 \
    && rm -rf /var/lib/apt/lists/*

# Copy requirements and install dependencies as root to leverage caching
COPY requirements.txt ./
RUN pip3 install --no-cache-dir -r requirements.txt

# Copy the application code from your local `src` folder
COPY src/ ./src/

# --- User and Permission Setup ---
# Create a group and user
RUN groupadd --system appuser && useradd --system --gid appuser appuser

# Change ownership of the entire app directory to the new user
RUN chown -R appuser:appuser /app

# Set the HOME environment variable for the non-root user (fixes PermissionError)
ENV HOME=/app

# Switch to the non-root user for security
USER appuser
# --- End of User Setup ---

EXPOSE 8501

HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1

# Run the app and disable telemetry
ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0", "--browser.gatherUsageStats=false"]