|
| 1 | +# Makefile for Browser Operator Core |
| 2 | +# Provides DevTools frontend + Agent Server deployments |
| 3 | + |
| 4 | +.PHONY: help build devtools-up up down logs status chrome chrome-clean |
| 5 | + |
| 6 | +# Chrome binary detection with cross-platform fallbacks |
| 7 | +# Override with: CHROME_BINARY=/path/to/chrome make chrome |
| 8 | +CHROME_BINARY ?= $(shell \ |
| 9 | + if command -v google-chrome >/dev/null 2>&1; then echo "google-chrome"; \ |
| 10 | + elif command -v chromium >/dev/null 2>&1; then echo "chromium"; \ |
| 11 | + elif command -v chromium-browser >/dev/null 2>&1; then echo "chromium-browser"; \ |
| 12 | + elif [ -x "/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary" ]; then echo "/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary"; \ |
| 13 | + elif [ -x "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" ]; then echo "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"; \ |
| 14 | + else echo "chrome-not-found"; \ |
| 15 | + fi) |
| 16 | + |
| 17 | +# Chrome profile directory (cleaned before each run) |
| 18 | +CHROME_PROFILE ?= /tmp/browser-operator-chrome-profile |
| 19 | + |
| 20 | +help: ## Show this help |
| 21 | + @echo "Browser Operator Core - Docker Deployments" |
| 22 | + @echo "===========================================" |
| 23 | + @echo "" |
| 24 | + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-12s %s\n", $$1, $$2}' |
| 25 | + @echo "" |
| 26 | + @echo "Deployment options:" |
| 27 | + @echo " Type 1: make devtools-up # DevTools only (AUTOMATED_MODE=true by default)" |
| 28 | + @echo " Type 2: make up # DevTools + Agent Server (lightweight)" |
| 29 | + @echo "" |
| 30 | + @echo "Full build (includes agent-server in image):" |
| 31 | + @echo " make build && docker-compose up -d" |
| 32 | + @echo "" |
| 33 | + @echo "For manual debugging mode (Type 1 without API key bypass):" |
| 34 | + @echo " docker-compose build --build-arg AUTOMATED_MODE=false && make devtools-up" |
| 35 | + |
| 36 | +build: ## Build full image (DevTools + Agent Server baked in) |
| 37 | + docker-compose build |
| 38 | + |
| 39 | +devtools-up: ## Start DevTools only (Type 1) |
| 40 | + docker-compose up -d |
| 41 | + @echo "" |
| 42 | + @echo "DevTools UI: http://localhost:8000" |
| 43 | + |
| 44 | +up: ## Start DevTools + Agent Server (Type 2 - lightweight) |
| 45 | + docker-compose -f docker-compose.lightweight.yml up -d |
| 46 | + @echo "" |
| 47 | + @echo "Services:" |
| 48 | + @echo " DevTools: http://localhost:8000" |
| 49 | + @echo " Agent API: http://localhost:8080" |
| 50 | + @echo " Agent WS: ws://localhost:8082" |
| 51 | + |
| 52 | +down: ## Stop all containers |
| 53 | + docker-compose -f docker-compose.lightweight.yml down 2>/dev/null || true |
| 54 | + docker-compose down 2>/dev/null || true |
| 55 | + |
| 56 | +logs: ## Show logs |
| 57 | + docker-compose -f docker-compose.lightweight.yml logs -f 2>/dev/null || docker-compose logs -f |
| 58 | + |
| 59 | +status: ## Show container status |
| 60 | + @docker ps --filter "name=browser-operator" |
| 61 | + |
| 62 | +chrome-clean: ## Remove Chrome debug profile |
| 63 | + @rm -rf "$(CHROME_PROFILE)" |
| 64 | + @echo "Cleaned Chrome profile: $(CHROME_PROFILE)" |
| 65 | + |
| 66 | +chrome: chrome-clean ## Launch Chrome with custom DevTools (clean profile) |
| 67 | + @if [ "$(CHROME_BINARY)" = "chrome-not-found" ]; then \ |
| 68 | + echo "Error: No Chrome/Chromium binary found."; \ |
| 69 | + echo "Set CHROME_BINARY=/path/to/chrome make chrome"; \ |
| 70 | + exit 1; \ |
| 71 | + fi |
| 72 | + @echo "Using Chrome: $(CHROME_BINARY)" |
| 73 | + @echo "Profile: $(CHROME_PROFILE)" |
| 74 | + "$(CHROME_BINARY)" \ |
| 75 | + --remote-debugging-port=9222 \ |
| 76 | + --remote-allow-origins="*" \ |
| 77 | + --auto-open-devtools-for-tabs \ |
| 78 | + --user-data-dir="$(CHROME_PROFILE)" \ |
| 79 | + --custom-devtools-frontend=http://localhost:8000/ |
0 commit comments