Skip to content

Commit ef6cb1f

Browse files
committed
Profiles retained locally
1 parent 6f892ab commit ef6cb1f

File tree

4 files changed

+49
-8
lines changed

4 files changed

+49
-8
lines changed

Dockerfile.local

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,21 @@ RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
315315
RUN echo '#!/bin/bash\ncd /opt/eval-server && node examples/with-http-wrapper.js' > /usr/local/bin/start-eval-server.sh && \
316316
chmod +x /usr/local/bin/start-eval-server.sh
317317

318+
# ============================================================================
319+
# Chromium Data Directory Configuration
320+
# ============================================================================
321+
322+
# Environment variable for configurable data directory
323+
ENV CHROMIUM_DATA_DIR=/data
324+
325+
# Create data directory structure for optional volume mounting
326+
RUN mkdir -p /data/user-data /data/config /data/cache && \
327+
chown -R kernel:kernel /data && \
328+
chmod -R 755 /data
329+
330+
# Declare volume for optional mounting of Chromium profiles and data
331+
VOLUME ["/data"]
332+
318333
# Expose ports
319334
EXPOSE 8000 8001 8080 8081 8082
320335

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ help: ## Show this help message
1010
@echo ""
1111
@echo "Available commands:"
1212
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-15s %s\n", $$1, $$2}'
13+
@echo ""
14+
@echo "Chromium Data Persistence:"
15+
@echo " - Set CHROMIUM_DATA_HOST=./chromium-data for persistent browser data"
16+
@echo " - Example: CHROMIUM_DATA_HOST=./chromium-data make run"
17+
@echo " - For docker-compose, uncomment the ./chromium-data:/data volume"
1318

1419
init: ## Initialize submodules (run this first)
1520
git submodule update --init --recursive
@@ -23,7 +28,8 @@ build: init ## Build extended image with DevTools frontend
2328
run: ## Run extended container with DevTools (interactive)
2429
@echo "🚀 Starting extended kernel-browser with DevTools..."
2530
@if [ -n "$(URLS)" ]; then echo "📄 Opening URLs: $(URLS)"; fi
26-
URLS='$(URLS)' ./run-local.sh
31+
@if [ -n "$(CHROMIUM_DATA_HOST)" ]; then echo "🗂️ Using persistent data: $(CHROMIUM_DATA_HOST)"; fi
32+
CHROMIUM_DATA_HOST='$(CHROMIUM_DATA_HOST)' URLS='$(URLS)' ./run-local.sh
2733

2834
compose-up: build ## Start with docker-compose (background)
2935
@echo "🚀 Starting with docker-compose..."

docker-compose.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ version: '3.8'
22

33
services:
44
kernel-browser:
5-
image: "kernel-browser:local"
6-
container_name: "kernel-browser-local"
5+
image: "kernel-browser:extended"
6+
container_name: "kernel-browser-extended"
77
privileged: true
88
shm_size: 2gb
99
deploy:
@@ -30,13 +30,15 @@ services:
3030
- NEKO_WEBRTC_NAT1TO1=127.0.0.1
3131
# Run as kernel user (not root)
3232
- RUN_AS_ROOT=false
33-
# Mount Chromium flags
34-
- CHROMIUM_FLAGS=--user-data-dir=/home/kernel/user-data --disable-dev-shm-usage --start-maximized --remote-allow-origins=* --no-sandbox --disable-setuid-sandbox
33+
# Mount Chromium flags (user-data-dir will be set automatically by start-chromium.sh using CHROMIUM_DATA_DIR)
34+
- CHROMIUM_FLAGS=--disable-dev-shm-usage --start-maximized --remote-allow-origins=* --no-sandbox --disable-setuid-sandbox
3535
volumes:
3636
# Persist recordings in local directory
3737
- "./recordings:/recordings"
3838
# Mount Chromium flags file (will be created by run script)
3939
- "./kernel-images/images/chromium-headful/.tmp/chromium/flags:/chromium/flags:ro"
40+
# Optional: Uncomment to persist Chromium data across container restarts
41+
# - "./chromium-data:/data"
4042
tmpfs:
4143
- /dev/shm:size=2g
4244
restart: unless-stopped

run-local.sh

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ export UKC_METRO="dummy-metro-for-local-run"
3737

3838

3939
# Local-friendly Chrome flags (less restrictive than cloud) + custom DevTools frontend
40-
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/"
40+
# Note: --user-data-dir will be set automatically by start-chromium.sh using CHROMIUM_DATA_DIR
41+
export CHROMIUM_FLAGS="--disable-dev-shm-usage --start-maximized --remote-allow-origins=* --no-sandbox --disable-setuid-sandbox --custom-devtools-frontend=http://localhost:8001/"
4142

4243
echo "🔧 Configuration:"
4344
echo " Image: $IMAGE"
@@ -56,12 +57,24 @@ echo "🏃 Starting extended container with kernel-images run system..."
5657
# Source common build vars
5758
source ../../shared/ensure-common-build-run-vars.sh chromium-headful
5859

59-
# Directory on host where recordings will be saved
60+
# Directory on host where recordings will be saved
6061
HOST_RECORDINGS_DIR="$SCRIPT_DIR/recordings"
6162
mkdir -p "$HOST_RECORDINGS_DIR"
6263

64+
# Optional Chromium data directory for persistence
65+
# Set CHROMIUM_DATA_HOST to enable volume mounting (e.g., ./chromium-data)
66+
if [[ -n "${CHROMIUM_DATA_HOST:-}" ]]; then
67+
echo "🗂️ Using persistent Chromium data directory: $CHROMIUM_DATA_HOST"
68+
mkdir -p "$CHROMIUM_DATA_HOST"
69+
CHROMIUM_DATA_VOLUME="-v $(realpath "$CHROMIUM_DATA_HOST"):/data"
70+
else
71+
echo "🔄 Using ephemeral Chromium data (no persistence)"
72+
CHROMIUM_DATA_VOLUME=""
73+
fi
74+
6375
# Build Chromium flags file and mount
64-
CHROMIUM_FLAGS_DEFAULT="--user-data-dir=/home/kernel/user-data --disable-dev-shm-usage --disable-gpu --start-maximized --disable-software-rasterizer --remote-allow-origins=*"
76+
# Note: --user-data-dir will be set automatically by start-chromium.sh using CHROMIUM_DATA_DIR
77+
CHROMIUM_FLAGS_DEFAULT="--disable-dev-shm-usage --disable-gpu --start-maximized --disable-software-rasterizer --remote-allow-origins=*"
6578
if [[ "$RUN_AS_ROOT" == "true" ]]; then
6679
CHROMIUM_FLAGS_DEFAULT="$CHROMIUM_FLAGS_DEFAULT --no-sandbox --no-zygote"
6780
fi
@@ -92,6 +105,11 @@ RUN_ARGS=(
92105
--mount type=bind,src="$FLAGS_FILE",dst=/chromium/flags,ro
93106
)
94107

108+
# Add Chromium data volume if specified
109+
if [[ -n "$CHROMIUM_DATA_VOLUME" ]]; then
110+
RUN_ARGS+=( $CHROMIUM_DATA_VOLUME )
111+
fi
112+
95113
# Add URLS environment variable if provided
96114
if [[ -n "${URLS:-}" ]]; then
97115
echo " URLs: $URLS"

0 commit comments

Comments
 (0)