-
Notifications
You must be signed in to change notification settings - Fork 1
Local setup containing Chromium (Neko) + Custom Devtools #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,267 @@ | ||
| # 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 | ||
| && apt-get install -y --no-install-recommends \ | ||
| libreoffice \ | ||
| x11-apps \ | ||
| xpdf \ | ||
| gedit \ | ||
| xpaint \ | ||
| tint2 \ | ||
| galculator \ | ||
| pcmanfm \ | ||
| wget \ | ||
| xdg-utils \ | ||
| libvulkan1 \ | ||
| fonts-liberation \ | ||
| unzip && \ | ||
tysonthomas9 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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" ] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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-extended | ||
|
|
||
| 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 | ||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.