hellorahulk commited on
Commit
ad61798
·
verified ·
1 Parent(s): a09426f

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -1
Dockerfile CHANGED
@@ -4,8 +4,12 @@ FROM python:3.10-slim
4
  RUN apt-get update && apt-get install -y \
5
  wget \
6
  gnupg \
 
7
  && rm -rf /var/lib/apt/lists/*
8
 
 
 
 
9
  # Install latest Chrome and its dependencies
10
  RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
11
  && echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list \
@@ -20,9 +24,15 @@ RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key
20
  libxss1 \
21
  && rm -rf /var/lib/apt/lists/*
22
 
23
- # Set up working directory
24
  WORKDIR /app
25
 
 
 
 
 
 
 
26
  # Copy requirements and install Python dependencies
27
  COPY requirements.txt .
28
  RUN pip install --no-cache-dir -r requirements.txt
@@ -33,11 +43,18 @@ RUN playwright install-deps
33
 
34
  # Copy application code
35
  COPY . .
 
36
 
37
  # Set environment variables
38
  ENV PYTHONUNBUFFERED=1
39
  ENV GRADIO_SERVER_NAME=0.0.0.0
40
  ENV GRADIO_SERVER_PORT=7860
 
 
 
 
 
 
41
 
42
  # Expose port
43
  EXPOSE 7860
 
4
  RUN apt-get update && apt-get install -y \
5
  wget \
6
  gnupg \
7
+ fontconfig \
8
  && rm -rf /var/lib/apt/lists/*
9
 
10
+ # Create non-root user
11
+ RUN useradd -m -u 1000 crawler
12
+
13
  # Install latest Chrome and its dependencies
14
  RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
15
  && echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list \
 
24
  libxss1 \
25
  && rm -rf /var/lib/apt/lists/*
26
 
27
+ # Set up working directory and permissions
28
  WORKDIR /app
29
 
30
+ # Create and set permissions for cache directories
31
+ RUN mkdir -p /home/crawler/.cache/fontconfig \
32
+ && mkdir -p /home/crawler/.crawl4ai \
33
+ && chown -R crawler:crawler /home/crawler \
34
+ && chown -R crawler:crawler /app
35
+
36
  # Copy requirements and install Python dependencies
37
  COPY requirements.txt .
38
  RUN pip install --no-cache-dir -r requirements.txt
 
43
 
44
  # Copy application code
45
  COPY . .
46
+ RUN chown -R crawler:crawler /app
47
 
48
  # Set environment variables
49
  ENV PYTHONUNBUFFERED=1
50
  ENV GRADIO_SERVER_NAME=0.0.0.0
51
  ENV GRADIO_SERVER_PORT=7860
52
+ ENV HOME=/home/crawler
53
+ ENV FONTCONFIG_PATH=/etc/fonts
54
+ ENV XDG_CACHE_HOME=/home/crawler/.cache
55
+
56
+ # Switch to non-root user
57
+ USER crawler
58
 
59
  # Expose port
60
  EXPOSE 7860