aroniscunt/Browser_Web_UI_Automation
0
1FROM python:3.11-slim
2
3# Set platform for multi-arch builds (Docker Buildx will set this)
4ARG TARGETPLATFORM
5ARG NODE_MAJOR=20
6
7# Set Python version environment variables
8ENV PYTHON_VERSION=3.11
9ENV PYTHONUNBUFFERED=1
10
11# Install system dependencies
12RUN apt-get update && apt-get install -y \
13 wget \
14 netcat-traditional \
15 gnupg \
16 curl \
17 unzip \
18 xvfb \
19 libgconf-2-4 \
20 libxss1 \
21 libnss3 \
22 libnspr4 \
23 libasound2 \
24 libatk1.0-0 \
25 libatk-bridge2.0-0 \
26 libcups2 \
27 libdbus-1-3 \
28 libdrm2 \
29 libgbm1 \
30 libgtk-3-0 \
31 libxcomposite1 \
32 libxdamage1 \
33 libxfixes3 \
34 libxrandr2 \
35 xdg-utils \
36 fonts-liberation \
37 dbus \
38 xauth \
39 x11vnc \
40 tigervnc-tools \
41 supervisor \
42 net-tools \
43 procps \
44 git \
45 python3-numpy \
46 fontconfig \
47 fonts-dejavu \
48 fonts-dejavu-core \
49 fonts-dejavu-extra \
50 vim \
51 && rm -rf /var/lib/apt/lists/*
52
53# Install noVNC
54RUN git clone https://github.com/novnc/noVNC.git /opt/novnc \
55 && git clone https://github.com/novnc/websockify /opt/novnc/utils/websockify \
56 && ln -s /opt/novnc/vnc.html /opt/novnc/index.html
57
58# Install Node.js using NodeSource PPA
59RUN mkdir -p /etc/apt/keyrings \
60 && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
61 && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \
62 && apt-get update \
63 && apt-get install nodejs -y \
64 && rm -rf /var/lib/apt/lists/*
65
66# Verify Node.js and npm installation (optional, but good for debugging)
67RUN node -v && npm -v && npx -v
68
69# Set up working directory
70WORKDIR /app
71
72# Copy requirements and install Python dependencies
73COPY requirements.txt .
74
75# Upgrade pip and install Python dependencies
76RUN python -m pip install --upgrade pip && \
77 pip install --no-cache-dir -r requirements.txt
78
79# Install playwright browsers and dependencies
80# playwright documentation suggests PLAYWRIGHT_BROWSERS_PATH is still relevant
81# or that playwright installs to a similar default location that Playwright would.
82# Let's assume playwright respects PLAYWRIGHT_BROWSERS_PATH or its default install location is findable.
83ENV PLAYWRIGHT_BROWSERS_PATH=/ms-browsers
84RUN mkdir -p $PLAYWRIGHT_BROWSERS_PATH
85
86# Install recommended: Google Chrome (instead of just Chromium for better undetectability)
87# The 'playwright install chrome' command might download and place it.
88# The '--with-deps' equivalent for playwright install is to run 'playwright install-deps chrome' after.
89# RUN playwright install chrome --with-deps
90
91# Alternative: Install Chromium if Google Chrome is problematic in certain environments
92RUN playwright install chromium --with-deps
93
94
95# Copy the application code
96COPY . .
97
98# Set up supervisor configuration
99RUN mkdir -p /var/log/supervisor
100COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
101
102EXPOSE 7788 6080 5901 9222
103
104CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
105#CMD ["/bin/bash"]