laichai commited on
Commit
8f2735a
·
verified ·
1 Parent(s): 8b6b615

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +19 -14
Dockerfile CHANGED
@@ -1,32 +1,37 @@
1
- # Use the official Python image
2
  FROM python:3.9-slim
3
 
4
- # 1. Install System Dependencies (LaTeX)
5
- # We use --no-install-recommends to keep the image smaller, but install the necessary parts.
6
- RUN apt-get update && \
7
- apt-get install -y \
 
8
  texlive-latex-base \
9
  texlive-latex-extra \
10
- texlive-science \
11
  texlive-fonts-recommended \
12
  texlive-fonts-extra \
 
 
13
  ghostscript \
14
  && rm -rf /var/lib/apt/lists/*
15
 
16
- # 2. Set up the working directory
17
  WORKDIR /app
18
 
19
- # 3. Copy your specific requirements file first (for caching)
20
  COPY requirements.txt .
21
-
22
- # 4. Install Python dependencies
23
  RUN pip install --no-cache-dir -r requirements.txt
24
 
25
- # 5. Copy the rest of your application code
26
  COPY . .
27
 
28
- # 6. Expose the port used by Streamlit (7860 is standard for Hugging Face)
29
- EXPOSE 7860
 
 
 
 
30
 
31
- # 7. Run the application
 
32
  CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
 
1
+ # Start from a lightweight Python image
2
  FROM python:3.9-slim
3
 
4
+ # 1. Install LaTeX and dependencies
5
+ # We run 'apt-get update' and install all necessary TeX Live packages
6
+ # 'texlive-science' is needed for your siunitx package
7
+ # 'texlive-pictures' is needed for your pgfplots package
8
+ RUN apt-get update && apt-get install -y \
9
  texlive-latex-base \
10
  texlive-latex-extra \
 
11
  texlive-fonts-recommended \
12
  texlive-fonts-extra \
13
+ texlive-science \
14
+ texlive-pictures \
15
  ghostscript \
16
  && rm -rf /var/lib/apt/lists/*
17
 
18
+ # 2. Set the working directory
19
  WORKDIR /app
20
 
21
+ # 3. Copy requirements and install Python libraries
22
  COPY requirements.txt .
 
 
23
  RUN pip install --no-cache-dir -r requirements.txt
24
 
25
+ # 4. Copy the rest of the app code
26
  COPY . .
27
 
28
+ # 5. Create a non-root user (Security best practice for Hugging Face)
29
+ # This prevents permission errors
30
+ RUN useradd -m -u 1000 user
31
+ USER user
32
+ ENV HOME=/home/user \
33
+ PATH=/home/user/.local/bin:$PATH
34
 
35
+ # 6. Command to run the app
36
+ # Streamlit runs on port 8501 by default, but HF expects 7860
37
  CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]