Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,7 @@ service-account-key.json

# Backup files
*.bak
*.backup
*.backup

# Chromium persistent data
chromium-data/
15 changes: 15 additions & 0 deletions Dockerfile.local
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,21 @@ RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
RUN echo '#!/bin/bash\ncd /opt/eval-server && node examples/with-http-wrapper.js' > /usr/local/bin/start-eval-server.sh && \
chmod +x /usr/local/bin/start-eval-server.sh

# ============================================================================
# Chromium Data Directory Configuration
# ============================================================================

# Environment variable for configurable data directory
ENV CHROMIUM_DATA_DIR=/data

# Create data directory structure for optional volume mounting
RUN mkdir -p /data/user-data /data/config /data/cache && \
chown -R kernel:kernel /data && \
chmod -R 755 /data

# Declare volume for optional mounting of Chromium profiles and data
VOLUME ["/data"]

# Expose ports
EXPOSE 8000 8001 8080 8081 8082

Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ help: ## Show this help message
@echo ""
@echo "Available commands:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-15s %s\n", $$1, $$2}'
@echo ""
@echo "Chromium Data Persistence:"
@echo " - Browser data persists to ./chromium-data by default"
@echo " - Customize location: CHROMIUM_DATA_HOST=/path/to/data make run"
@echo " - Disable persistence: CHROMIUM_DATA_HOST=\"\" make run"

init: ## Initialize submodules (run this first)
git submodule update --init --recursive
Expand All @@ -23,7 +28,7 @@ build: init ## Build extended image with DevTools frontend
run: ## Run extended container with DevTools (interactive)
@echo "🚀 Starting extended kernel-browser with DevTools..."
@if [ -n "$(URLS)" ]; then echo "📄 Opening URLs: $(URLS)"; fi
URLS='$(URLS)' ./run-local.sh
@./run-local.sh

compose-up: build ## Start with docker-compose (background)
@echo "🚀 Starting with docker-compose..."
Expand Down
10 changes: 6 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ version: '3.8'

services:
kernel-browser:
image: "kernel-browser:local"
container_name: "kernel-browser-local"
image: "kernel-browser:extended"
container_name: "kernel-browser-extended"
privileged: true
shm_size: 2gb
deploy:
Expand All @@ -30,13 +30,15 @@ services:
- NEKO_WEBRTC_NAT1TO1=127.0.0.1
# Run as kernel user (not root)
- RUN_AS_ROOT=false
# Mount Chromium flags
- CHROMIUM_FLAGS=--user-data-dir=/home/kernel/user-data --disable-dev-shm-usage --start-maximized --remote-allow-origins=* --no-sandbox --disable-setuid-sandbox
# Chromium flags with persistent data directory
- CHROMIUM_FLAGS=--user-data-dir=/data/user-data --disable-dev-shm-usage --start-maximized --remote-allow-origins=* --no-sandbox --disable-setuid-sandbox
volumes:
# Persist recordings in local directory
- "./recordings:/recordings"
# Mount Chromium flags file (will be created by run script)
- "./kernel-images/images/chromium-headful/.tmp/chromium/flags:/chromium/flags:ro"
# Persist Chromium data across container restarts (set CHROMIUM_DATA_HOST env var to customize path)
- "${CHROMIUM_DATA_HOST:-./chromium-data}:/data"
tmpfs:
- /dev/shm:size=2g
restart: unless-stopped
Expand Down
34 changes: 31 additions & 3 deletions run-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ 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/"
export CHROMIUM_FLAGS="--user-data-dir=/data/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"
Expand All @@ -56,12 +56,35 @@ echo "🏃 Starting extended container with kernel-images run system..."
# Source common build vars
source ../../shared/ensure-common-build-run-vars.sh chromium-headful

# Directory on host where recordings will be saved
# Directory on host where recordings will be saved
HOST_RECORDINGS_DIR="$SCRIPT_DIR/recordings"
mkdir -p "$HOST_RECORDINGS_DIR"

# Chromium data directory for persistence
# Set CHROMIUM_DATA_HOST to customize location (default: ./chromium-data)
# Set CHROMIUM_DATA_HOST="" to disable persistence (ephemeral mode)
if [[ "${CHROMIUM_DATA_HOST+set}" == "set" && -z "$CHROMIUM_DATA_HOST" ]]; then
echo "🔄 Using ephemeral Chromium data (no persistence)"
CHROMIUM_DATA_VOLUME=""
else
# Default to ./chromium-data if not specified
CHROMIUM_DATA_HOST="${CHROMIUM_DATA_HOST:-$SCRIPT_DIR/chromium-data}"
echo "🗂️ Using persistent Chromium data directory: $CHROMIUM_DATA_HOST"
CHROMIUM_DATA_REAL=$(realpath "$CHROMIUM_DATA_HOST" 2>/dev/null || echo "")
if [[ -z "$CHROMIUM_DATA_REAL" ]]; then
# Path doesn't exist yet, try to create it first
mkdir -p "$CHROMIUM_DATA_HOST"
CHROMIUM_DATA_REAL=$(realpath "$CHROMIUM_DATA_HOST" 2>/dev/null || echo "")
if [[ -z "$CHROMIUM_DATA_REAL" ]]; then
echo "❌ Error: Invalid path $CHROMIUM_DATA_HOST"
exit 1
fi
fi
CHROMIUM_DATA_VOLUME="${CHROMIUM_DATA_REAL}:/data"
fi

# 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=*"
CHROMIUM_FLAGS_DEFAULT="--user-data-dir=/data/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
Expand Down Expand Up @@ -92,6 +115,11 @@ RUN_ARGS=(
--mount type=bind,src="$FLAGS_FILE",dst=/chromium/flags,ro
)

# Add Chromium data volume if specified
if [[ -n "$CHROMIUM_DATA_VOLUME" ]]; then
RUN_ARGS+=( -v "${CHROMIUM_DATA_VOLUME}" )
fi

# Add URLS environment variable if provided
if [[ -n "${URLS:-}" ]]; then
echo " URLs: $URLS"
Expand Down