refactor(browser): split browser cores via build ARG, add core selector (#237)

* refactor(browser): split browser cores via build ARG, add core selector

- Replace playwright official image with ubuntu:noble base in both
  docker/Dockerfile.browser and devenv/Dockerfile.browser; install
  browsers at build time driven by ARG/ENV BROWSER_CORES
- Add GET /cores endpoint to Browser Gateway reporting available cores
- Proxy GET /browser-contexts/cores in Go handler to Browser Gateway
- Add `core` field to BrowserContextConfigModel and GatewayBrowserContext;
  context creation selects the appropriate browser instance by core
- Frontend context-setting page fetches available cores and renders a
  core selector; saves core as part of the config JSON
- install.sh prompts for browser core selection and writes BROWSER_CORES
  to .env; builds the browser image locally before docker compose up
- Regenerate OpenAPI spec and TypeScript SDK

* fix: lint
This commit is contained in:
Acbox Liu
2026-03-14 12:37:20 +08:00
committed by GitHub
parent 627b673a5c
commit c8728ffc2c
22 changed files with 364 additions and 33 deletions
+21 -1
View File
@@ -99,6 +99,7 @@ WORKSPACE="$WORKSPACE_DEFAULT"
MEMOH_DATA_DIR="$MEMOH_DATA_DIR_DEFAULT"
USE_CN_MIRROR="${USE_CN_MIRROR:-false}"
USE_SPARSE="${USE_SPARSE:-false}"
BROWSER_CORES="${BROWSER_CORES:-chromium,firefox}"
if [ "$SILENT" = false ]; then
echo "Configure Memoh (press Enter to use defaults):" > /dev/tty
@@ -148,6 +149,19 @@ if [ "$SILENT" = false ]; then
y|Y|yes|YES) USE_SPARSE=true ;;
esac
echo "" > /dev/tty
echo " Browser core selection:" > /dev/tty
echo " 1) Chromium only (smaller image)" > /dev/tty
echo " 2) Firefox only" > /dev/tty
echo " 3) Both Chromium and Firefox (default)" > /dev/tty
printf " Browser core [3]: " > /dev/tty
read -r input < /dev/tty || true
case "$input" in
1) BROWSER_CORES="chromium" ;;
2) BROWSER_CORES="firefox" ;;
*) BROWSER_CORES="chromium,firefox" ;;
esac
echo "" > /dev/tty
fi
@@ -222,11 +236,17 @@ fi
echo POSTGRES_PASSWORD="${PG_PASS}" >> .env
echo MEMOH_CONFIG=./config.toml >> .env
echo MEMOH_DATA_DIR="{$MEMOH_DATA_DIR}" >> .env
echo BROWSER_CORES="${BROWSER_CORES}" >> .env
echo USE_SPARSE="${USE_SPARSE}" >> .env
echo "${GREEN}✓ Browser cores: ${BROWSER_CORES}${NC}"
echo ""
echo "${GREEN}Pulling latest Docker images...${NC}"
$DOCKER compose $COMPOSE_FILES $COMPOSE_PROFILES pull
$DOCKER compose $COMPOSE_FILES $COMPOSE_PROFILES pull --ignore-buildable
echo ""
echo "${GREEN}Building browser image (cores: ${BROWSER_CORES})...${NC}"
$DOCKER compose $COMPOSE_FILES $COMPOSE_PROFILES build browser
echo ""
echo "${GREEN}Starting services (first startup may take a few minutes)...${NC}"