Update Dockerfile
Browse files- Dockerfile +7 -103
Dockerfile
CHANGED
@@ -1,112 +1,16 @@
|
|
1 |
-
FROM
|
2 |
-
USER root
|
3 |
-
ENV PYTHONDONTWRITEBYTECODE=1
|
4 |
-
ENV PYTHONUNBUFFERED=1
|
5 |
-
ENV DEBIAN_FRONTEND=noninteractive
|
6 |
-
ENV PIP_ROOT_USER_ACTION=ignore
|
7 |
-
ENV HOME=/home/user
|
8 |
-
ENV PLAYWRIGHT_BROWSERS_PATH=${HOME}/.cache/ms-playwright
|
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 \
|
23 |
-
python3-pip \
|
24 |
-
python3.11-dev \
|
25 |
-
wget \
|
26 |
-
unzip \
|
27 |
-
ca-certificates \
|
28 |
-
libnss3 \
|
29 |
-
libnss3-tools \
|
30 |
-
libnspr4 \
|
31 |
-
libatk1.0-0 \
|
32 |
-
libatk-bridge2.0-0 \
|
33 |
-
libatspi2.0-0 \
|
34 |
-
libcups2 \
|
35 |
-
libxcomposite1 \
|
36 |
-
libxdamage1 \
|
37 |
-
libxrandr2 \
|
38 |
-
libxkbcommon0 \
|
39 |
-
libx11-xcb1 \
|
40 |
-
libxcursor1 \
|
41 |
-
libxi6 \
|
42 |
-
libxss1 \
|
43 |
-
libxtst6 \
|
44 |
-
libasound2 \
|
45 |
-
libx11-6 \
|
46 |
-
libxcb1 \
|
47 |
-
libxext6 \
|
48 |
-
libxfixes3 \
|
49 |
-
libxrender1 \
|
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/ && \
|
64 |
-
ln -s /usr/lib/x86_64-linux-gnu/libnspr4.so /usr/lib/playwright/ && \
|
65 |
-
ln -s /usr/lib/x86_64-linux-gnu/libatk-1.0.so.0 /usr/lib/playwright/ && \
|
66 |
-
ln -s /usr/lib/x86_64-linux-gnu/libatk-bridge-2.0.so.0 /usr/lib/playwright/ && \
|
67 |
-
ln -s /usr/lib/x86_64-linux-gnu/libcups.so.2 /usr/lib/playwright/ && \
|
68 |
-
ln -s /usr/lib/x86_64-linux-gnu/libatspi.so.0 /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
|
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
|
112 |
-
CMD ["
|
|
|
1 |
+
FROM mcr.microsoft.com/playwright:v1.37.0-jammy
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
WORKDIR /app
|
4 |
+
|
5 |
+
# Install Python dependencies
|
6 |
COPY requirements.txt ./
|
7 |
RUN pip3 install --no-cache-dir -r requirements.txt
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
# Copy application code
|
10 |
COPY . .
|
11 |
|
12 |
+
# Set permissions if needed
|
13 |
+
RUN chmod -R 755 /app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
+
# Run the app
|
16 |
+
CMD ["streamlit", "run", "app/main.py"]
|