merge dockerfile

This commit is contained in:
alexwarm
2025-05-09 20:34:30 +08:00
parent 81c0f47775
commit a04773266c
13 changed files with 625 additions and 637 deletions

View File

@@ -1,5 +1,8 @@
FROM python:3.11-slim
# Set platform for multi-arch builds (Docker Buildx will set this)
ARG TARGETPLATFORM
# Install system dependencies
RUN apt-get update && apt-get install -y \
wget \
@@ -28,7 +31,6 @@ RUN apt-get update && apt-get install -y \
fonts-liberation \
dbus \
xauth \
xvfb \
x11vnc \
tigervnc-tools \
supervisor \
@@ -47,33 +49,45 @@ RUN git clone https://github.com/novnc/noVNC.git /opt/novnc \
&& git clone https://github.com/novnc/websockify /opt/novnc/utils/websockify \
&& ln -s /opt/novnc/vnc.html /opt/novnc/index.html
# Set platform for ARM64 compatibility
ARG TARGETPLATFORM=linux/amd64
# Set up working directory
WORKDIR /app
# Copy requirements and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Ensure 'patchright' is in your requirements.txt or install it directly
# RUN pip install --no-cache-dir -r requirements.txt patchright # If not in requirements
RUN pip install --no-cache-dir -r requirements.txt # Assuming patchright is in requirements.txt
RUN pip install --no-cache-dir patchright # Or install it explicitly
# Install Playwright and browsers with system dependencies
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
RUN playwright install --with-deps chromium
RUN playwright install-deps
# Install Patchright browsers and dependencies
# Patchright documentation suggests PLAYWRIGHT_BROWSERS_PATH is still relevant
# or that Patchright installs to a similar default location that Playwright would.
# Let's assume Patchright respects PLAYWRIGHT_BROWSERS_PATH or its default install location is findable.
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-browsers
RUN mkdir -p $PLAYWRIGHT_BROWSERS_PATH
# Install recommended: Google Chrome (instead of just Chromium for better undetectability)
# The 'patchright install chrome' command might download and place it.
# The '--with-deps' equivalent for patchright install is to run 'patchright install-deps chrome' after.
RUN patchright install chrome
RUN patchright install-deps chrome
# Alternative: Install Chromium if Google Chrome is problematic in certain environments
RUN patchright install chromium
RUN patchright install-deps chromium
# Copy the application code
COPY . .
# Set environment variables
# Set environment variables (Updated Names)
ENV PYTHONUNBUFFERED=1
ENV BROWSER_USE_LOGGING_LEVEL=info
ENV CHROME_PATH=/ms-playwright/chromium-*/chrome-linux/chrome
# BROWSER_PATH will be determined by Patchright installation, supervisord will find it.
ENV ANONYMIZED_TELEMETRY=false
ENV DISPLAY=:99
ENV RESOLUTION=1920x1080x24
ENV VNC_PASSWORD=vncpassword
ENV CHROME_PERSISTENT_SESSION=true
ENV VNC_PASSWORD=youvncpassword
ENV KEEP_BROWSER_OPEN=true
ENV RESOLUTION_WIDTH=1920
ENV RESOLUTION_HEIGHT=1080
@@ -81,6 +95,6 @@ ENV RESOLUTION_HEIGHT=1080
RUN mkdir -p /var/log/supervisor
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
EXPOSE 7788 6080 5901
EXPOSE 7788 6080 5901 9222
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]