From 8f2d2aec3da91f7949f61ac88cc6ee758b57dac4 Mon Sep 17 00:00:00 2001 From: Oleh Luchkiv Date: Thu, 4 Sep 2025 09:58:53 -0500 Subject: [PATCH 1/3] Local setup containing Chromium (Neko) + Custom Devtools --- Dockerfile.local | 269 ++++++++++++++++++++++++ Makefile | 115 ++++++++++ nginx-devtools.conf | 79 +++++++ run-local.sh | 71 +++++++ supervisor/services/nginx-devtools.conf | 15 ++ 5 files changed, 549 insertions(+) create mode 100644 Dockerfile.local create mode 100644 Makefile create mode 100644 nginx-devtools.conf create mode 100755 run-local.sh create mode 100644 supervisor/services/nginx-devtools.conf diff --git a/Dockerfile.local b/Dockerfile.local new file mode 100644 index 0000000..0bb0ada --- /dev/null +++ b/Dockerfile.local @@ -0,0 +1,269 @@ +# Extended Dockerfile combining kernel-images with DevTools frontend +# This extends the kernel-images base with Browser Operator DevTools static files + +# DevTools Frontend build stage using browser-operator-core +FROM --platform=linux/amd64 ubuntu:22.04 AS devtools-builder + +# Install required packages for DevTools frontend build +RUN apt-get update && apt-get install -y \ + curl \ + git \ + python3 \ + python3-pip \ + python-is-python3 \ + wget \ + unzip \ + sudo \ + ca-certificates \ + build-essential \ + && rm -rf /var/lib/apt/lists/* + +# Install Node.js 18.x +RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \ + apt-get install -y nodejs && \ + rm -rf /var/lib/apt/lists/* + +WORKDIR /workspace + +# Clone depot_tools +RUN git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git +ENV PATH="/workspace/depot_tools:${PATH}" +ENV DEPOT_TOOLS_UPDATE=0 + +# Follow README instructions exactly - fetching code +RUN mkdir devtools +WORKDIR /workspace/devtools +RUN fetch devtools-frontend + +# Build steps +WORKDIR /workspace/devtools/devtools-frontend + +RUN gclient sync +RUN /workspace/depot_tools/ensure_bootstrap + +# Build standard DevTools first +RUN npm run build + +# Add Browser Operator fork and switch to it +RUN git remote add upstream https://github.com/BrowserOperator/browser-operator-core.git +RUN git fetch upstream +RUN git checkout upstream/main + +# Build Browser Operator version +RUN npm run build + +# ============================================================================ +# Use kernel-images base with DevTools integration +# ============================================================================ +FROM docker.io/golang:1.25.0 AS server-builder +WORKDIR /workspace/server + +ARG TARGETOS +ARG TARGETARCH +ENV CGO_ENABLED=0 + +COPY kernel-images/server/go.mod ./ +COPY kernel-images/server/go.sum ./ +RUN go mod download + +COPY kernel-images/server/ . +RUN GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} \ + go build -ldflags="-s -w" -o /out/kernel-images-api ./cmd/api + +# webrtc client +FROM node:22-bullseye-slim AS client +WORKDIR /src +COPY kernel-images/images/chromium-headful/client/package*.json ./ +RUN npm install +COPY kernel-images/images/chromium-headful/client/ . +RUN npm run build + +# xorg dependencies +FROM docker.io/ubuntu:22.04 AS xorg-deps +WORKDIR /xorg +ENV DEBIAN_FRONTEND=noninteractive +RUN set -eux; \ + apt-get update; \ + apt-get install -y \ + git gcc pkgconf autoconf automake libtool make xorg-dev xutils-dev \ + && rm -rf /var/lib/apt/lists/*; +COPY kernel-images/images/chromium-headful/xorg-deps/ /xorg/ +# build xf86-video-dummy v0.3.8 with RandR support +RUN set -eux; \ + cd xf86-video-dummy/v0.3.8; \ + patch -p1 < ../01_v0.3.8_xdummy-randr.patch; \ + autoreconf -v --install; \ + ./configure; \ + make -j$(nproc); \ + make install; +# build custom input driver +RUN set -eux; \ + cd xf86-input-neko; \ + ./autogen.sh --prefix=/usr; \ + ./configure; \ + make -j$(nproc); \ + make install; + +FROM ghcr.io/onkernel/neko/base:3.0.6-v1.0.1 AS neko +# ^--- now has event.SYSTEM_PONG with legacy support to keepalive + +# Final stage: kernel-images base + DevTools static files +FROM docker.io/ubuntu:22.04 + +ENV DEBIAN_FRONTEND=noninteractive +ENV DEBIAN_PRIORITY=high + +RUN apt-get update && \ + apt-get -y upgrade && \ + apt-get -y install \ + # UI Requirements + xvfb \ + xterm \ + xdotool \ + scrot \ + imagemagick \ + sudo \ + mutter \ + # Python/pyenv reqs + build-essential \ + libssl-dev \ + zlib1g-dev \ + libbz2-dev \ + libreadline-dev \ + libsqlite3-dev \ + curl \ + git \ + libncursesw5-dev \ + xz-utils \ + tk-dev \ + libxml2-dev \ + libxmlsec1-dev \ + libffi-dev \ + liblzma-dev \ + # Network tools + net-tools \ + netcat \ + # PPA req + software-properties-common \ + # Add nginx for DevTools serving + nginx && \ + # Userland apps + sudo add-apt-repository ppa:mozillateam/ppa && \ + sudo apt-get install -y --no-install-recommends \ + chromium-browser \ + libreoffice \ + x11-apps \ + xpdf \ + gedit \ + xpaint \ + tint2 \ + galculator \ + pcmanfm \ + wget \ + xdg-utils \ + libvulkan1 \ + fonts-liberation \ + unzip && \ + apt-get clean + +# install ffmpeg manually since the version available in apt is from the 4.x branch due to #drama. +# as of writing these static builds will be the latest 7.0.x release. +RUN set -eux; \ + URL="https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz"; \ + echo "Downloading FFmpeg static build from $URL"; \ + curl -fsSL "$URL" -o /tmp/ffmpeg.tar.xz; \ + tar -xJf /tmp/ffmpeg.tar.xz -C /tmp; \ + install -m755 /tmp/ffmpeg-*/ffmpeg /usr/local/bin/ffmpeg; \ + install -m755 /tmp/ffmpeg-*/ffprobe /usr/local/bin/ffprobe; \ + rm -rf /tmp/ffmpeg* + +# runtime +ENV USERNAME=root +RUN set -eux; \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + wget ca-certificates python2 supervisor xclip xdotool \ + pulseaudio dbus-x11 xserver-xorg-video-dummy \ + libcairo2 libxcb1 libxrandr2 libxv1 libopus0 libvpx7 \ + gstreamer1.0-plugins-base gstreamer1.0-plugins-good \ + gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly \ + gstreamer1.0-pulseaudio gstreamer1.0-omx; \ + # + # install libxcvt0 (not available in debian:bullseye) + ARCH=$(dpkg --print-architecture); \ + wget http://ftp.de.debian.org/debian/pool/main/libx/libxcvt/libxcvt0_0.1.2-1_${ARCH}.deb; \ + apt-get install --no-install-recommends ./libxcvt0_0.1.2-1_${ARCH}.deb; \ + rm ./libxcvt0_0.1.2-1_${ARCH}.deb; \ + # + # workaround for an X11 problem: http://blog.tigerteufel.de/?p=476 + mkdir /tmp/.X11-unix; \ + chmod 1777 /tmp/.X11-unix; \ + chown $USERNAME /tmp/.X11-unix/; \ + # + # make directories for neko + mkdir -p /etc/neko /var/www /var/log/neko \ + /tmp/runtime-$USERNAME \ + /home/$USERNAME/.config/pulse \ + /home/$USERNAME/.local/share/xorg; \ + chmod 1777 /var/log/neko; \ + chown $USERNAME /var/log/neko/ /tmp/runtime-$USERNAME; \ + chown -R $USERNAME:$USERNAME /home/$USERNAME; \ + # clean up + apt-get clean -y; \ + rm -rf /var/lib/apt/lists/* /var/cache/apt/ + +# install chromium and sqlite3 for debugging the cookies file +RUN add-apt-repository -y ppa:xtradeb/apps +RUN apt update -y && apt install -y chromium sqlite3 + +# setup desktop env & app +ENV DISPLAY_NUM=1 +ENV HEIGHT=768 +ENV WIDTH=1024 +ENV WITHDOCKER=true + +# Copy kernel-images configuration and binaries +COPY kernel-images/images/chromium-headful/xorg.conf /etc/neko/xorg.conf +COPY kernel-images/images/chromium-headful/neko.yaml /etc/neko/neko.yaml +COPY --from=neko /usr/bin/neko /usr/bin/neko +COPY --from=client /src/dist/ /var/www +COPY --from=xorg-deps /usr/local/lib/xorg/modules/drivers/dummy_drv.so /usr/lib/xorg/modules/drivers/dummy_drv.so +COPY --from=xorg-deps /usr/local/lib/xorg/modules/input/neko_drv.so /usr/lib/xorg/modules/input/neko_drv.so + +COPY kernel-images/images/chromium-headful/image-chromium/ / +COPY kernel-images/images/chromium-headful/start-chromium.sh /images/chromium-headful/start-chromium.sh +RUN chmod +x /images/chromium-headful/start-chromium.sh +COPY kernel-images/images/chromium-headful/wrapper.sh /wrapper.sh +COPY kernel-images/images/chromium-headful/supervisord.conf /etc/supervisor/supervisord.conf +COPY kernel-images/images/chromium-headful/supervisor/services/ /etc/supervisor/conf.d/services/ + +# copy the kernel-images API binary built in the builder stage +COPY --from=server-builder /out/kernel-images-api /usr/local/bin/kernel-images-api + +# ============================================================================ +# DevTools Integration +# ============================================================================ + +# Copy DevTools static files from builder +COPY --from=devtools-builder /workspace/devtools/devtools-frontend/out/Default/gen/front_end /usr/share/nginx/devtools + +# Create DevTools nginx configuration +COPY nginx-devtools.conf /etc/nginx/sites-available/devtools +RUN ln -s /etc/nginx/sites-available/devtools /etc/nginx/sites-enabled/devtools && \ + rm /etc/nginx/sites-enabled/default + +# Add DevTools nginx service to supervisor +COPY supervisor/services/nginx-devtools.conf /etc/supervisor/conf.d/services/nginx-devtools.conf + +# Create nginx temp directories and set permissions +RUN mkdir -p /var/lib/nginx/body \ + /var/lib/nginx/proxy \ + /var/lib/nginx/fastcgi \ + /var/lib/nginx/uwsgi \ + /var/lib/nginx/scgi && \ + chown -R www-data:www-data /var/lib/nginx && \ + chown -R www-data:www-data /usr/share/nginx/devtools + +RUN useradd -m -s /bin/bash kernel + +ENTRYPOINT [ "/wrapper.sh" ] \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..24c7cdc --- /dev/null +++ b/Makefile @@ -0,0 +1,115 @@ +# Makefile for kernel-browser local development +# Using kernel-images native build system + +.PHONY: help build run stop logs clean dev status shell test + +# Default target +help: ## Show this help message + @echo "Kernel Browser - Local Development (using kernel-images build system)" + @echo "==================================================================" + @echo "" + @echo "Available commands:" + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-15s %s\n", $$1, $$2}' + +init: ## Initialize submodules (run this first) + git submodule update --init --recursive + @echo "โœ… Submodules initialized" + +build: init ## Build extended image with DevTools frontend + @echo "๐Ÿ”จ Building extended kernel-browser with DevTools frontend..." + docker build -f Dockerfile.local -t kernel-browser:extended . + @echo "โœ… Extended build complete" + +run: ## Run extended container with DevTools (interactive) + @echo "๐Ÿš€ Starting extended kernel-browser with DevTools..." + ./run-local.sh + +compose-up: build ## Start with docker-compose (background) + @echo "๐Ÿš€ Starting with docker-compose..." + docker-compose up -d + @$(MAKE) --no-print-directory info + @echo "" + @echo "๐Ÿ“Š View logs with: make logs" + +compose-dev: build ## Start with docker-compose (foreground with logs) + @echo "๐Ÿš€ Starting with docker-compose in development mode..." + docker-compose up + +dev: compose-dev ## Alias for compose-dev + +stop: ## Stop all containers + @echo "๐Ÿ›‘ Stopping containers..." + docker-compose down + docker stop kernel-browser-extended 2>/dev/null || true + docker rm kernel-browser-extended 2>/dev/null || true + @echo "โœ… Containers stopped" + +restart: ## Restart containers + @$(MAKE) --no-print-directory stop + @$(MAKE) --no-print-directory compose-up + +logs: ## Show container logs + docker-compose logs -f kernel-browser || docker logs -f kernel-browser-local + +status: ## Show container status + @echo "Docker Compose Status:" + @docker-compose ps || true + @echo "" + @echo "Direct Container Status:" + @docker ps --filter name=kernel-browser + +shell: ## Get shell access to running container + docker exec -it kernel-browser-extended bash || docker-compose exec kernel-browser bash + +info: ## Show connection information + @echo "" + @echo "๐ŸŒ Service Access Points:" + @echo " WebRTC Client: http://localhost:8080" + @echo " Chrome DevTools: http://localhost:9222/json" + @echo " Recording API: http://localhost:444/api" + @echo " Enhanced DevTools UI: http://localhost:8001" + @echo " DevTools Health: http://localhost:8001/health" + +test: ## Test service endpoints + @echo "๐Ÿงช Testing service endpoints..." + @echo -n "WebRTC Client (8080): " + @curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/ || echo "Failed to connect" + @echo "" + @echo -n "Chrome DevTools (9222): " + @curl -s -o /dev/null -w "%{http_code}" http://localhost:9222/json/version || echo "Failed to connect" + @echo "" + @echo -n "Recording API (444): " + @curl -s -o /dev/null -w "%{http_code}" http://localhost:444/ && echo " (404 is normal - API is running)" || echo "Failed to connect" + @echo "" + @echo -n "DevTools UI (8001): " + @curl -s -o /dev/null -w "%{http_code}" http://localhost:8001/ || echo "Failed to connect" + @echo "" + @echo -n "DevTools Health (8001): " + @curl -s -o /dev/null -w "%{http_code}" http://localhost:8001/health || echo "Failed to connect" + @echo "" + @echo "๐ŸŽฏ All services are ready! Access points:" + @echo " WebRTC Client: http://localhost:8080" + @echo " Chrome DevTools: http://localhost:9222/json" + @echo " Enhanced DevTools UI: http://localhost:8001" + +clean: stop ## Clean up everything + @echo "๐Ÿงน Cleaning up..." + docker-compose down -v 2>/dev/null || true + docker rmi kernel-browser:extended 2>/dev/null || true + docker system prune -f + rm -rf recordings/* 2>/dev/null || true + rm -rf kernel-images/images/chromium-headful/.tmp 2>/dev/null || true + @echo "โœ… Cleanup complete" + +# Alternative commands for different approaches +native-build: init ## Build using kernel-images native script directly + cd kernel-images/images/chromium-headful && \ + UKC_TOKEN=dummy-token UKC_METRO=dummy-metro IMAGE=kernel-browser:local ./build-docker.sh + +native-run: ## Run using kernel-images native script directly + cd kernel-images/images/chromium-headful && \ + UKC_TOKEN=dummy-token UKC_METRO=dummy-metro IMAGE=kernel-browser:local NAME=kernel-browser-local ENABLE_WEBRTC=true ./run-docker.sh + +# Quick development workflow +quick: init build compose-up test ## Quick setup: init + build + run + test + diff --git a/nginx-devtools.conf b/nginx-devtools.conf new file mode 100644 index 0000000..42db1a1 --- /dev/null +++ b/nginx-devtools.conf @@ -0,0 +1,79 @@ +server { + listen 8001; + listen [::]:8001; + server_name localhost; + + # Root directory for DevTools frontend + root /usr/share/nginx/devtools; + index inspector.html devtools_app.html index.html; + + # Compression + gzip on; + gzip_vary on; + gzip_min_length 1024; + gzip_types text/plain text/css text/xml text/javascript application/javascript application/xml+rss application/json application/wasm; + + # Security headers + add_header X-Frame-Options "SAMEORIGIN" always; + add_header X-Content-Type-Options "nosniff" always; + add_header X-XSS-Protection "1; mode=block" always; + + # CORS headers for DevTools + add_header Access-Control-Allow-Origin "*" always; + add_header Access-Control-Allow-Methods "GET, POST, OPTIONS" always; + add_header Access-Control-Allow-Headers "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range" always; + + # Handle OPTIONS requests + if ($request_method = 'OPTIONS') { + return 204; + } + + # Cache control for static assets + location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot|avif)$ { + expires 1d; + add_header Cache-Control "public, immutable"; + } + + # Specific handling for WebAssembly files + location ~ \.wasm$ { + add_header Content-Type application/wasm; + } + + # JSON files + location ~ \.json$ { + add_header Content-Type application/json; + } + + # Main location + location / { + try_files $uri $uri/ /index.html; + } + + # Specific paths for DevTools + location /front_end/ { + alias /usr/share/nginx/devtools/; + try_files $uri $uri/ =404; + } + + # Health check for DevTools service + location /health { + access_log off; + add_header Content-Type application/json; + return 200 '{"status": "healthy", "service": "devtools-frontend"}'; + } + + # Error pages + error_page 404 /404.html; + location = /404.html { + internal; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + internal; + } + + # Logging + access_log /var/log/nginx/devtools-access.log; + error_log /var/log/nginx/devtools-error.log warn; +} \ No newline at end of file diff --git a/run-local.sh b/run-local.sh new file mode 100755 index 0000000..dc4cbe0 --- /dev/null +++ b/run-local.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash + +# Extended local run wrapper for kernel-images chromium-headful + DevTools +set -e -o pipefail + +echo "๐Ÿš€ Starting kernel-browser (EXTENDED) locally using kernel-images run system..." + +# Ensure we're in the right directory +SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) +cd "$SCRIPT_DIR" + +# Check if kernel-images submodule exists +if [ ! -d "kernel-images" ] || [ ! -f "kernel-images/images/chromium-headful/run-docker.sh" ]; then + echo "โŒ Error: kernel-images submodule not found or incomplete" + echo " Run: git submodule update --init --recursive" + exit 1 +fi + +# Create local recordings directory +mkdir -p "$SCRIPT_DIR/recordings" + +# Change to kernel-images directory +cd kernel-images/images/chromium-headful + +# Make run script executable +chmod +x run-docker.sh + +# Set environment variables for extended local development +export IMAGE="kernel-browser:extended" +export NAME="kernel-browser-extended" +export ENABLE_WEBRTC="true" +export RUN_AS_ROOT="false" + +# Set dummy UKC variables to bypass cloud requirements (we only need Docker) +export UKC_TOKEN="dummy-token-for-local-run" +export UKC_METRO="dummy-metro-for-local-run" + +# Local-friendly Chrome flags (less restrictive than cloud) + custom DevTools frontend +export CHROMIUM_FLAGS="--user-data-dir=/home/kernel/user-data --disable-dev-shm-usage --start-maximized --remote-allow-origins=* --no-sandbox --disable-setuid-sandbox --custom-devtools-frontend=http://localhost:8001/" + +echo "๐Ÿ”ง Configuration:" +echo " Image: $IMAGE" +echo " Container: $NAME" +echo " WebRTC: $ENABLE_WEBRTC" +echo " DevTools UI: enabled" +echo " Run as root: $RUN_AS_ROOT" +echo " Recordings: $SCRIPT_DIR/recordings" +echo "" + +echo "๐Ÿƒ Starting extended container with kernel-images run system..." + +# Backup original run-docker.sh to modify port mappings +if [ ! -f run-docker.sh.original ]; then + cp run-docker.sh run-docker.sh.original +fi + +# Create modified run script that adds DevTools port mapping +cat run-docker.sh.original | \ +sed 's/docker run -it/docker run -it -p 8001:8001/' > run-docker.sh.extended + +chmod +x run-docker.sh.extended + +# Run using the modified run script with DevTools port +./run-docker.sh.extended + +echo "" +echo "๐ŸŒ Extended service should be accessible at:" +echo " WebRTC Client: http://localhost:8080" +echo " Chrome DevTools: http://localhost:9222" +echo " Recording API: http://localhost:444" +echo " Enhanced DevTools UI: http://localhost:8001" \ No newline at end of file diff --git a/supervisor/services/nginx-devtools.conf b/supervisor/services/nginx-devtools.conf new file mode 100644 index 0000000..442cf08 --- /dev/null +++ b/supervisor/services/nginx-devtools.conf @@ -0,0 +1,15 @@ +[program:nginx-devtools] +command=nginx -g 'daemon off;' +autostart=true +autorestart=true +startretries=3 +user=root +stdout_logfile=/var/log/nginx-devtools-stdout.log +stderr_logfile=/var/log/nginx-devtools-stderr.log +stdout_logfile_maxbytes=10MB +stderr_logfile_maxbytes=10MB +stdout_logfile_backups=3 +stderr_logfile_backups=3 +redirect_stderr=false +killasgroup=true +stopasgroup=true \ No newline at end of file From 5d5ba1501ae84d85c510cc1652abe20ab821bc27 Mon Sep 17 00:00:00 2001 From: Oleh Luchkiv Date: Thu, 4 Sep 2025 22:38:28 -0500 Subject: [PATCH 2/3] Cleanup and refactoring --- Dockerfile.local | 6 ++--- run-local.sh | 65 ++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 56 insertions(+), 15 deletions(-) diff --git a/Dockerfile.local b/Dockerfile.local index 0bb0ada..fc46aac 100644 --- a/Dockerfile.local +++ b/Dockerfile.local @@ -146,11 +146,9 @@ RUN apt-get update && \ # PPA req software-properties-common \ # Add nginx for DevTools serving - nginx && \ + nginx \ # Userland apps - sudo add-apt-repository ppa:mozillateam/ppa && \ - sudo apt-get install -y --no-install-recommends \ - chromium-browser \ + && apt-get install -y --no-install-recommends \ libreoffice \ x11-apps \ xpdf \ diff --git a/run-local.sh b/run-local.sh index dc4cbe0..75b8dc0 100755 --- a/run-local.sh +++ b/run-local.sh @@ -31,10 +31,11 @@ export NAME="kernel-browser-extended" export ENABLE_WEBRTC="true" export RUN_AS_ROOT="false" -# Set dummy UKC variables to bypass cloud requirements (we only need Docker) +# Set dummy UKC variables to satisfy kernel-images script requirements (not used in local Docker) export UKC_TOKEN="dummy-token-for-local-run" export UKC_METRO="dummy-metro-for-local-run" + # Local-friendly Chrome flags (less restrictive than cloud) + custom DevTools frontend export CHROMIUM_FLAGS="--user-data-dir=/home/kernel/user-data --disable-dev-shm-usage --start-maximized --remote-allow-origins=* --no-sandbox --disable-setuid-sandbox --custom-devtools-frontend=http://localhost:8001/" @@ -49,19 +50,61 @@ echo "" echo "๐Ÿƒ Starting extended container with kernel-images run system..." -# Backup original run-docker.sh to modify port mappings -if [ ! -f run-docker.sh.original ]; then - cp run-docker.sh run-docker.sh.original -fi +# Execute the kernel-images script setup but override the final docker run command +# We'll replicate the essential parts here to avoid the sed hack + +# Source common build vars +source ../../shared/ensure-common-build-run-vars.sh chromium-headful -# Create modified run script that adds DevTools port mapping -cat run-docker.sh.original | \ -sed 's/docker run -it/docker run -it -p 8001:8001/' > run-docker.sh.extended +# Directory on host where recordings will be saved +HOST_RECORDINGS_DIR="$SCRIPT_DIR/recordings" +mkdir -p "$HOST_RECORDINGS_DIR" -chmod +x run-docker.sh.extended +# Build Chromium flags file and mount +CHROMIUM_FLAGS_DEFAULT="--user-data-dir=/home/kernel/user-data --disable-dev-shm-usage --disable-gpu --start-maximized --disable-software-rasterizer --remote-allow-origins=*" +if [[ "$RUN_AS_ROOT" == "true" ]]; then + CHROMIUM_FLAGS_DEFAULT="$CHROMIUM_FLAGS_DEFAULT --no-sandbox --no-zygote" +fi +CHROMIUM_FLAGS="${CHROMIUM_FLAGS:-$CHROMIUM_FLAGS_DEFAULT}" +rm -rf .tmp/chromium +mkdir -p .tmp/chromium +FLAGS_FILE="$(pwd)/.tmp/chromium/flags" +echo "$CHROMIUM_FLAGS" > "$FLAGS_FILE" + +# Build docker run argument list +RUN_ARGS=( + --name "$NAME" + --privileged + --tmpfs /dev/shm:size=2g + -v "$HOST_RECORDINGS_DIR:/recordings" + --memory 8192m + -p 9222:9222 + -p 444:10001 + -p 8001:8001 + -e DISPLAY_NUM=1 + -e HEIGHT=768 + -e WIDTH=1024 + -e RUN_AS_ROOT="$RUN_AS_ROOT" + --mount type=bind,src="$FLAGS_FILE",dst=/chromium/flags,ro +) + +# WebRTC port mapping +if [[ "${ENABLE_WEBRTC:-}" == "true" ]]; then + echo "Running container with WebRTC" + RUN_ARGS+=( -p 8080:8080 ) + RUN_ARGS+=( -e ENABLE_WEBRTC=true ) + if [[ -n "${NEKO_ICESERVERS:-}" ]]; then + RUN_ARGS+=( -e NEKO_ICESERVERS="$NEKO_ICESERVERS" ) + else + RUN_ARGS+=( -e NEKO_WEBRTC_EPR=56000-56100 ) + RUN_ARGS+=( -e NEKO_WEBRTC_NAT1TO1=127.0.0.1 ) + RUN_ARGS+=( -p 56000-56100:56000-56100/udp ) + fi +fi -# Run using the modified run script with DevTools port -./run-docker.sh.extended +# Run with our additional DevTools port mapping +docker rm -f "$NAME" 2>/dev/null || true +docker run -it "${RUN_ARGS[@]}" "$IMAGE" echo "" echo "๐ŸŒ Extended service should be accessible at:" From 309ede5a8cd8dc3654c4b3d37caf269b22d43f91 Mon Sep 17 00:00:00 2001 From: Oleh Luchkiv Date: Thu, 4 Sep 2025 22:40:36 -0500 Subject: [PATCH 3/3] Minor renaming --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 24c7cdc..7c9e9eb 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ restart: ## Restart containers @$(MAKE) --no-print-directory compose-up logs: ## Show container logs - docker-compose logs -f kernel-browser || docker logs -f kernel-browser-local + docker-compose logs -f kernel-browser || docker logs -f kernel-browser-extended status: ## Show container status @echo "Docker Compose Status:"