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