nothere990 commited on
Commit
e8b238f
·
1 Parent(s): 3d1bbb9

update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +23 -48
Dockerfile CHANGED
@@ -1,85 +1,60 @@
1
  FROM python:3.9.5-buster
2
 
3
  # Install system dependencies
4
- RUN apt -qq update && \
5
- apt -qq install -y --no-install-recommends \
6
- ffmpeg \
7
  curl \
8
  git \
9
  gnupg2 \
10
  unzip \
11
  wget \
12
  xvfb \
13
- libxi6 \
14
  libgconf-2-4 \
15
- libappindicator3-1 \
16
  libxrender1 \
17
  libxtst6 \
18
- libnss3 \
19
  libatk1.0-0 \
20
  libxss1 \
21
  fonts-liberation \
22
  libasound2 \
23
- libgbm-dev \
24
- libu2f-udev \
25
  libvulkan1 \
26
- libgl1-mesa-dri \
27
  xdg-utils \
28
- python3-dev \
29
- python3-pip \
30
- libavformat-dev \
31
- libavcodec-dev \
32
- libavdevice-dev \
33
- libavfilter-dev \
34
- libavutil-dev \
35
- libswscale-dev \
36
- libswresample-dev \
37
- chromium \
38
- chromium-driver \
39
- neofetch && \
40
  apt-get clean && \
41
- rm -rf /var/lib/apt/lists/
42
-
43
- # Install Chrome using your preferred method
44
- RUN mkdir -p /tmp/ && \
45
- cd /tmp/ && \
46
- wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \
47
- dpkg -i ./google-chrome-stable_current_amd64.deb || apt-get install -fqqy && \
48
- rm ./google-chrome-stable_current_amd64.deb
49
-
50
- # Install Chromedriver using your specified method
51
- RUN mkdir -p /tmp/ && \
52
- cd /tmp/ && \
53
- wget -O chromedriver.zip https://chromedriver.storage.googleapis.com/$(curl -sS https://chromedriver.storage.googleapis.com/LATEST_RELEASE)/chromedriver_linux64.zip && \
54
- unzip -o chromedriver.zip chromedriver -d /usr/bin/ && \
55
  chmod +x /usr/bin/chromedriver && \
56
- rm chromedriver.zip
57
 
58
- # Create user with UID 1000
59
  RUN useradd -m -u 1000 user
60
-
61
- # Set environment variables
62
  ENV HOME=/home/user \
63
  PATH=/home/user/.local/bin:$PATH \
64
  CHROME_DRIVER=/usr/bin/chromedriver \
65
  CHROME_BIN=/usr/bin/google-chrome-stable \
66
  PYTHONUNBUFFERED=1
67
-
68
- # Set working directory
69
  WORKDIR $HOME/app
70
-
71
- # Switch to non-root user
72
  USER user
73
 
74
- # Copy requirements first to leverage Docker cache
75
  COPY --chown=user requirements.txt .
76
- RUN pip install --no-cache-dir --upgrade pip \
77
- && pip install --no-cache-dir -r requirements.txt
78
 
79
- # Copy application code
80
  COPY --chown=user . .
81
 
82
- # Verification commands
83
  RUN google-chrome --version && chromedriver --version
84
 
85
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
  FROM python:3.9.5-buster
2
 
3
  # Install system dependencies
4
+ RUN apt-get update && \
5
+ apt-get install -y --no-install-recommends \
 
6
  curl \
7
  git \
8
  gnupg2 \
9
  unzip \
10
  wget \
11
  xvfb \
 
12
  libgconf-2-4 \
13
+ libnss3 \
14
  libxrender1 \
15
  libxtst6 \
 
16
  libatk1.0-0 \
17
  libxss1 \
18
  fonts-liberation \
19
  libasound2 \
 
 
20
  libvulkan1 \
 
21
  xdg-utils \
22
+ ffmpeg && \
 
 
 
 
 
 
 
 
 
 
 
23
  apt-get clean && \
24
+ rm -rf /var/lib/apt/lists/*
25
+
26
+ # Install Chrome
27
+ RUN mkdir -p /tmp/chrome && cd /tmp/chrome && \
28
+ wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \
29
+ dpkg -i ./google-chrome*.deb || apt-get -y install -f && \
30
+ rm -rf /tmp/chrome
31
+
32
+ # Install Chromedriver
33
+ RUN mkdir -p /tmp/chromedriver && cd /tmp/chromedriver && \
34
+ wget -q https://chromedriver.storage.googleapis.com/$(curl -sS https://chromedriver.storage.googleapis.com/LATEST_RELEASE)/chromedriver_linux64.zip && \
35
+ unzip chromedriver.zip -d /usr/bin/ && \
 
 
36
  chmod +x /usr/bin/chromedriver && \
37
+ rm -rf /tmp/chromedriver
38
 
39
+ # Non-root user setup
40
  RUN useradd -m -u 1000 user
 
 
41
  ENV HOME=/home/user \
42
  PATH=/home/user/.local/bin:$PATH \
43
  CHROME_DRIVER=/usr/bin/chromedriver \
44
  CHROME_BIN=/usr/bin/google-chrome-stable \
45
  PYTHONUNBUFFERED=1
 
 
46
  WORKDIR $HOME/app
 
 
47
  USER user
48
 
49
+ # Python dependencies
50
  COPY --chown=user requirements.txt .
51
+ RUN pip install --no-cache-dir --upgrade pip && \
52
+ pip install --no-cache-dir -r requirements.txt
53
 
54
+ # Application code
55
  COPY --chown=user . .
56
 
57
+ # Verification
58
  RUN google-chrome --version && chromedriver --version
59
 
60
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]