SmokeyBandit commited on
Commit
cb87df1
·
verified ·
1 Parent(s): 613861f

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +25 -13
Dockerfile CHANGED
@@ -1,10 +1,10 @@
1
- # ----------------------
2
- # Dockerfile
3
- # ----------------------
4
- # 1) Start from an official Python image
5
  FROM python:3.9-slim
6
 
7
- # 2) Install system dependencies needed by Playwright
 
 
 
8
  RUN apt-get update && apt-get install -y \
9
  wget \
10
  gnupg \
@@ -23,21 +23,33 @@ RUN apt-get update && apt-get install -y \
23
  libgtk-3-0 \
24
  && rm -rf /var/lib/apt/lists/*
25
 
26
- # 3) Upgrade pip
27
  RUN pip install --upgrade pip
28
 
29
- # 4) Install Python packages: playwright, gradio, requests, beautifulsoup4
30
  RUN pip install playwright==1.32.0 gradio==3.23.0 requests beautifulsoup4
31
 
32
- # 5) Install Playwright browsers (Chromium, Firefox, WebKit)
33
  RUN playwright install
34
 
35
- # 6) Copy our app code into the container
36
  WORKDIR /app
37
- COPY app.py /app
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
- # 7) Expose port 7860 for Gradio
40
  EXPOSE 7860
41
 
42
- # 8) Run our Gradio app
43
- CMD ["python", "app.py"]
 
1
+ # Start from an official Python image
 
 
 
2
  FROM python:3.9-slim
3
 
4
+ # Create a non-root user
5
+ RUN useradd -m -u 1000 appuser
6
+
7
+ # Install system dependencies needed by Playwright
8
  RUN apt-get update && apt-get install -y \
9
  wget \
10
  gnupg \
 
23
  libgtk-3-0 \
24
  && rm -rf /var/lib/apt/lists/*
25
 
26
+ # Upgrade pip
27
  RUN pip install --upgrade pip
28
 
29
+ # Install Python packages
30
  RUN pip install playwright==1.32.0 gradio==3.23.0 requests beautifulsoup4
31
 
32
+ # Install Playwright browsers
33
  RUN playwright install
34
 
35
+ # Set up directories with proper permissions
36
  WORKDIR /app
37
+ COPY app.py /app/
38
+
39
+ # Create and set permissions for matplotlib cache directory
40
+ ENV MPLCONFIGDIR=/tmp/matplotlib
41
+ RUN mkdir -p /tmp/matplotlib && \
42
+ chown -R appuser:appuser /tmp/matplotlib
43
+
44
+ # Create and set permissions for fontconfig cache
45
+ RUN mkdir -p /home/appuser/.cache/fontconfig && \
46
+ chown -R appuser:appuser /home/appuser/.cache
47
+
48
+ # Switch to non-root user
49
+ USER appuser
50
 
51
+ # Expose port 7860 for Gradio
52
  EXPOSE 7860
53
 
54
+ # Run Gradio app
55
+ CMD ["python", "app.py"]