File size: 1,939 Bytes
9ede49e
5afbe18
264ac69
5e1192b
16973c0
 
5e1192b
ec959b4
ce859c4
264ac69
 
 
 
 
a86f496
 
ec959b4
 
 
 
a86f496
 
 
73b4d32
ce859c4
 
264ac69
5e1192b
 
 
 
 
264ac69
5e1192b
5afbe18
264ac69
 
 
 
5e1192b
264ac69
 
 
 
 
 
5e1192b
264ac69
5afbe18
264ac69
 
 
 
73b4d32
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
FROM python:3.10-slim

# Set environment variables
ENV PYTHONUNBUFFERED=1
# Prevents interactive prompts during apt-get install
ENV DEBIAN_FRONTEND=noninteractive

# Install base system dependencies including debconf-utils
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        ffmpeg \
        libsm6 \
        libxext6 \
        fontconfig \
        debconf-utils

# Pre-accept EULA and install Microsoft Core Fonts
# Using full path for debconf-set-sections for robustness
RUN echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" | /usr/bin/debconf-set-sections && \
    apt-get install -y --no-install-recommends ttf-mscorefonts-installer

# Update font cache and clean up
RUN fc-cache -f -v && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

# Create a non-root user and group for security and permission handling
ARG APP_USER_UID=1000
ARG APP_USER_GID=1000
RUN groupadd --gid $APP_USER_GID appgroup && \
    useradd --uid $APP_USER_UID --gid appgroup --shell /bin/bash --create-home appuser

# Set the working directory (this will also be appuser's home directory)
WORKDIR /home/appuser/app

# Copy requirements.txt first to leverage Docker build cache
COPY --chown=appuser:appgroup requirements.txt ./

# Upgrade pip and install Python dependencies as the appuser
USER appuser
RUN python -m pip install --no-cache-dir --upgrade pip
RUN python -m pip install --no-cache-dir -r requirements.txt

# Copy the rest of the application code as the appuser
# This ensures correct ownership from the start
COPY --chown=appuser:appgroup . .

# Expose Streamlit's default port
EXPOSE 8501

# Command to run Streamlit
# Using server.headless=true is good practice for containers.
# Streamlit will try to create .streamlit in the user's home dir (/home/appuser)
CMD ["streamlit", "run", "app.py", "--server.headless=true", "--server.port=8501", "--server.fileWatcherType=none"]