File size: 995 Bytes
8f2735a
522f3ad
39ea8ea
8f2735a
 
522f3ad
 
 
 
8f2735a
 
522f3ad
 
39ea8ea
3ba272b
 
 
 
522f3ad
3ba272b
39ea8ea
3ba272b
 
522f3ad
39ea8ea
3ba272b
 
 
39ea8ea
3ba272b
8f2735a
 
 
39ea8ea
7ea39fc
 
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
# Start from a lightweight Python image
FROM python:3.9-slim

# 1. Install LaTeX and dependencies
RUN apt-get update && apt-get install -y \
    texlive-latex-base \
    texlive-latex-extra \
    texlive-fonts-recommended \
    texlive-fonts-extra \
    texlive-science \
    texlive-pictures \
    ghostscript \
    && rm -rf /var/lib/apt/lists/*

# 2. Create a non-root user FIRST
RUN useradd -m -u 1000 user

# 3. Set the working directory and ensure the user owns it
WORKDIR /app
RUN chown user:user /app

# 4. Copy requirements and install dependencies
COPY --chown=user:user requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# 5. Copy the rest of the application with correct ownership
#    (This is the CRITICAL fix)
COPY --chown=user:user . .

# 6. Switch to the non-root user
USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# 7. Run the application port 7860
CMD ["streamlit", "run", "app.py", "--server.port=8080", "--server.address=0.0.0.0"]