File size: 1,420 Bytes
747e979
8e22681
747e979
 
 
8e22681
84f813e
747e979
 
8e22681
 
 
 
 
 
84f813e
 
747e979
84f813e
 
 
747e979
84f813e
 
 
747e979
84f813e
 
8e22681
84f813e
 
8e22681
747e979
 
8e22681
747e979
 
 
8e22681
84f813e
4fb085d
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
FROM python:3.11-slim

# Set up environment paths
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

WORKDIR /app

# Install system utilities needed for building packages
RUN apt-get update && apt-get install -y \
    build-essential \
    curl \
    git \
    && rm -rf /var/lib/apt/lists/*

# Copy the requirements file into the root working directory
COPY requirements.txt /app/requirements.txt

# FIX: Run pip install while still under root privileges to prevent permission errors
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir -r /app/requirements.txt

# Set up secure, non-root user execution required by Hugging Face
RUN useradd -m -u 1000 user
WORKDIR $HOME/app

# Copy all project files and change ownership to the non-root user
COPY --chown=user . $HOME/app

# Switch to the non-root user account for final runtime execution
USER user

# Expose the mandatory Hugging Face traffic proxy port
EXPOSE 7860

# Add container stability health check on the assigned port
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
    CMD curl --fail http://localhost:7860/_stcore/health || exit 1

# Execute app.py directly from the application folder on port 7860
ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0", "--client.showErrorDetails=false", "--server.enableCORS=false", "--server.enableXsrfProtection=false"]