From 97087673e6a1eb0b2b1f270f83c3283642aa4ded Mon Sep 17 00:00:00 2001 From: mukunda katta Date: Wed, 8 Apr 2026 07:56:58 -0700 Subject: [PATCH] feat: add Docker GUI support with VNC and noVNC Adds Dockerfile.gui with Xvfb, VNC, and noVNC for running the bot with a visible browser in Docker: - Xvfb virtual framebuffer for headless display - x11vnc for VNC access - noVNC for browser-based access at http://localhost:6080 - Playwright chromium with system dependencies - docker-compose.gui.yml for easy startup --- Dockerfile.gui | 35 +++++++++++++++++++++++++++++++++++ docker-compose.gui.yml | 15 +++++++++++++++ docker-gui-entrypoint.sh | 24 ++++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 Dockerfile.gui create mode 100644 docker-compose.gui.yml create mode 100644 docker-gui-entrypoint.sh diff --git a/Dockerfile.gui b/Dockerfile.gui new file mode 100644 index 0000000..f9b4569 --- /dev/null +++ b/Dockerfile.gui @@ -0,0 +1,35 @@ +FROM python:3.10.14-slim + +# Install system dependencies including browser support and VNC +RUN apt-get update && apt-get install -y --no-install-recommends \ + ffmpeg \ + xvfb \ + x11vnc \ + novnc \ + websockify \ + fluxbox \ + && rm -rf /var/lib/apt/lists/* + +# Set display for headless browser +ENV DISPLAY=:99 +ENV VNC_PORT=5900 +ENV NOVNC_PORT=6080 + +RUN mkdir /app +ADD . /app +WORKDIR /app + +# Install Python dependencies +RUN pip install --no-cache-dir -r requirements.txt + +# Install Playwright browsers with system dependencies +RUN playwright install --with-deps chromium + +# Copy the entrypoint script +COPY docker-gui-entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +EXPOSE 5900 6080 + +ENTRYPOINT ["/entrypoint.sh"] +CMD ["python3", "main.py"] diff --git a/docker-compose.gui.yml b/docker-compose.gui.yml new file mode 100644 index 0000000..ef62e6f --- /dev/null +++ b/docker-compose.gui.yml @@ -0,0 +1,15 @@ +version: "3.8" + +services: + reddit-bot-gui: + build: + context: . + dockerfile: Dockerfile.gui + ports: + - "5900:5900" # VNC + - "6080:6080" # noVNC (web browser access) + volumes: + - ./results:/app/results + - ./.config.toml:/app/.config.toml + environment: + - DISPLAY=:99 diff --git a/docker-gui-entrypoint.sh b/docker-gui-entrypoint.sh new file mode 100644 index 0000000..f887048 --- /dev/null +++ b/docker-gui-entrypoint.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -e + +# Start virtual framebuffer +Xvfb :99 -screen 0 1920x1080x24 & +sleep 1 + +# Start lightweight window manager +fluxbox & + +# Start VNC server (no password by default, use -rfbauth for security) +x11vnc -display :99 -forever -nopw -rfbport ${VNC_PORT:-5900} & + +# Start noVNC web client (accessible via browser at http://localhost:6080) +websockify --web /usr/share/novnc/ ${NOVNC_PORT:-6080} localhost:${VNC_PORT:-5900} & + +echo "============================================" +echo " GUI is available at:" +echo " VNC: vnc://localhost:${VNC_PORT:-5900}" +echo " Web: http://localhost:${NOVNC_PORT:-6080}/vnc.html" +echo "============================================" + +# Run the main command +exec "$@"