Update Dockerfile
Browse files- Dockerfile +24 -4
Dockerfile
CHANGED
@@ -1,7 +1,5 @@
|
|
1 |
FROM ubuntu:22.04
|
2 |
-
|
3 |
USER root
|
4 |
-
|
5 |
ENV PYTHONDONTWRITEBYTECODE=1
|
6 |
ENV PYTHONUNBUFFERED=1
|
7 |
ENV DEBIAN_FRONTEND=noninteractive
|
@@ -11,12 +9,14 @@ ENV PLAYWRIGHT_BROWSERS_PATH=${HOME}/.cache/ms-playwright
|
|
11 |
ENV LD_LIBRARY_PATH=/usr/lib/playwright:/usr/lib/x86_64-linux-gnu
|
12 |
ENV GRADIO_NODE_PORT=disabled
|
13 |
|
|
|
14 |
RUN useradd -m -d /home/user user && \
|
15 |
mkdir -p ${HOME}/.cache/ms-playwright && \
|
16 |
mkdir -p /usr/lib/playwright && \
|
17 |
chown -R user:user ${HOME}/.cache && \
|
18 |
chmod -R 755 ${HOME}/.cache
|
19 |
|
|
|
20 |
RUN apt-get update && \
|
21 |
apt-get install -y --no-install-recommends \
|
22 |
python3.11 \
|
@@ -50,12 +50,14 @@ RUN apt-get update && \
|
|
50 |
libdbus-1-3 \
|
51 |
libdrm2 \
|
52 |
libpango-1.0-0 \
|
|
|
53 |
fonts-liberation \
|
54 |
fonts-noto-color-emoji \
|
55 |
gcc && \
|
56 |
apt-get clean && \
|
57 |
rm -rf /var/lib/apt/lists/*
|
58 |
|
|
|
59 |
RUN ln -s /usr/lib/x86_64-linux-gnu/libnss3.so /usr/lib/playwright/ && \
|
60 |
ln -s /usr/lib/x86_64-linux-gnu/libnssutil3.so /usr/lib/playwright/ && \
|
61 |
ln -s /usr/lib/x86_64-linux-gnu/libsmime3.so /usr/lib/playwright/ && \
|
@@ -67,26 +69,44 @@ RUN ln -s /usr/lib/x86_64-linux-gnu/libnss3.so /usr/lib/playwright/ && \
|
|
67 |
ln -s /usr/lib/x86_64-linux-gnu/libXcomposite.so.1 /usr/lib/playwright/ && \
|
68 |
ln -s /usr/lib/x86_64-linux-gnu/libXdamage.so.1 /usr/lib/playwright/
|
69 |
|
|
|
70 |
WORKDIR /app
|
71 |
-
|
72 |
COPY requirements.txt ./
|
73 |
RUN pip3 install --no-cache-dir -r requirements.txt
|
74 |
|
|
|
75 |
RUN PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 pip3 install playwright==1.26.0
|
76 |
|
|
|
77 |
RUN cd ${HOME}/.cache/ms-playwright && \
|
78 |
wget -q https://playwright.azureedge.net/builds/chromium/1045/chromium-linux.zip && \
|
79 |
unzip chromium-linux.zip && \
|
80 |
rm chromium-linux.zip && \
|
|
|
81 |
chmod -R 755 ${HOME}/.cache/ms-playwright
|
82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
COPY . .
|
84 |
|
|
|
85 |
RUN chown -R user:user /app && \
|
86 |
chmod -R 755 /app && \
|
87 |
chmod -R 755 ${HOME}/.cache/ms-playwright && \
|
88 |
chmod -R 755 /usr/lib/playwright
|
89 |
|
|
|
90 |
USER user
|
91 |
|
92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
FROM ubuntu:22.04
|
|
|
2 |
USER root
|
|
|
3 |
ENV PYTHONDONTWRITEBYTECODE=1
|
4 |
ENV PYTHONUNBUFFERED=1
|
5 |
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
9 |
ENV LD_LIBRARY_PATH=/usr/lib/playwright:/usr/lib/x86_64-linux-gnu
|
10 |
ENV GRADIO_NODE_PORT=disabled
|
11 |
|
12 |
+
# Create user and directories
|
13 |
RUN useradd -m -d /home/user user && \
|
14 |
mkdir -p ${HOME}/.cache/ms-playwright && \
|
15 |
mkdir -p /usr/lib/playwright && \
|
16 |
chown -R user:user ${HOME}/.cache && \
|
17 |
chmod -R 755 ${HOME}/.cache
|
18 |
|
19 |
+
# Install system dependencies
|
20 |
RUN apt-get update && \
|
21 |
apt-get install -y --no-install-recommends \
|
22 |
python3.11 \
|
|
|
50 |
libdbus-1-3 \
|
51 |
libdrm2 \
|
52 |
libpango-1.0-0 \
|
53 |
+
redis-server \
|
54 |
fonts-liberation \
|
55 |
fonts-noto-color-emoji \
|
56 |
gcc && \
|
57 |
apt-get clean && \
|
58 |
rm -rf /var/lib/apt/lists/*
|
59 |
|
60 |
+
# Create symbolic links for libraries
|
61 |
RUN ln -s /usr/lib/x86_64-linux-gnu/libnss3.so /usr/lib/playwright/ && \
|
62 |
ln -s /usr/lib/x86_64-linux-gnu/libnssutil3.so /usr/lib/playwright/ && \
|
63 |
ln -s /usr/lib/x86_64-linux-gnu/libsmime3.so /usr/lib/playwright/ && \
|
|
|
69 |
ln -s /usr/lib/x86_64-linux-gnu/libXcomposite.so.1 /usr/lib/playwright/ && \
|
70 |
ln -s /usr/lib/x86_64-linux-gnu/libXdamage.so.1 /usr/lib/playwright/
|
71 |
|
72 |
+
# Set working directory and install Python dependencies
|
73 |
WORKDIR /app
|
|
|
74 |
COPY requirements.txt ./
|
75 |
RUN pip3 install --no-cache-dir -r requirements.txt
|
76 |
|
77 |
+
# Install Playwright but skip browser download for now
|
78 |
RUN PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 pip3 install playwright==1.26.0
|
79 |
|
80 |
+
# Manually download and install Chromium
|
81 |
RUN cd ${HOME}/.cache/ms-playwright && \
|
82 |
wget -q https://playwright.azureedge.net/builds/chromium/1045/chromium-linux.zip && \
|
83 |
unzip chromium-linux.zip && \
|
84 |
rm chromium-linux.zip && \
|
85 |
+
mkdir -p chromium-1045/chrome-linux/locales && \
|
86 |
chmod -R 755 ${HOME}/.cache/ms-playwright
|
87 |
|
88 |
+
# Configure Redis to run without root
|
89 |
+
RUN mkdir -p /var/run/redis && \
|
90 |
+
chown -R user:user /var/run/redis && \
|
91 |
+
mkdir -p /etc/redis && \
|
92 |
+
echo "port 6379\ndaemonize yes\npidfile /var/run/redis/redis-server.pid\ndir /tmp\n" > /etc/redis/redis.conf && \
|
93 |
+
chown -R user:user /etc/redis
|
94 |
+
|
95 |
+
# Copy application code
|
96 |
COPY . .
|
97 |
|
98 |
+
# Set permissions
|
99 |
RUN chown -R user:user /app && \
|
100 |
chmod -R 755 /app && \
|
101 |
chmod -R 755 ${HOME}/.cache/ms-playwright && \
|
102 |
chmod -R 755 /usr/lib/playwright
|
103 |
|
104 |
+
# Switch to non-root user
|
105 |
USER user
|
106 |
|
107 |
+
# Create a wrapper script to start Redis and the app
|
108 |
+
RUN echo '#!/bin/bash\nredis-server /etc/redis/redis.conf\npython3 app.py' > /app/start.sh && \
|
109 |
+
chmod +x /app/start.sh
|
110 |
+
|
111 |
+
# Run the wrapper script
|
112 |
+
CMD ["/app/start.sh"]
|