Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

refactor: using one dockerfile

Luigi Agosti2a391456f5a1
diff --git a/.gitignore b/.gitignore
index c2614244..8c3bb163 100644
--- a/.gitignore
+++ b/.gitignore
@@ -42,6 +42,7 @@ MY_PROJECT_NOTES.md
debug.log
pinchtab.exe
+.gomodcache/
.gocache
.DS_Store
# E2E test results
diff --git a/pdev b/pdev
index 22b638aa..2811d5e6 100755
--- a/pdev
+++ b/pdev
@@ -26,7 +26,6 @@ COMMANDS=(
" system:πŸ”¬:System tests only"
"doctor:🩺:Setup dev environment"
"e2e:🐳:E2E tests (Docker)"
- " e2e local:🐳:E2E tests (local)"
"check go:πŸ§ͺ:Go only"
"check dashboard:πŸ§ͺ:Dashboard only"
"check security:πŸ§ͺ:Gosec security scan"
@@ -103,17 +102,17 @@ run_command() {
echo ""
exec bash scripts/test.sh all
;;
- "unit")
+ "test unit"|"unit")
echo " ${ACCENT}${BOLD}πŸ”¬ Unit tests${NC}"
echo ""
exec bash scripts/test.sh unit
;;
- "integration")
+ "test integration"|"integration")
echo " ${ACCENT}${BOLD}πŸ”¬ Integration tests${NC}"
echo ""
exec bash scripts/test.sh integration
;;
- "system")
+ "test system"|"system")
echo " ${ACCENT}${BOLD}πŸ”¬ System tests${NC}"
echo ""
exec bash scripts/test.sh system
@@ -123,12 +122,8 @@ run_command() {
echo ""
exec docker compose -f tests/e2e/docker-compose.yml up --build --abort-on-container-exit
;;
- "e2e local")
- echo " ${ACCENT}${BOLD}🐳 E2E tests (local)${NC}"
- echo ""
- exec bash tests/e2e/run-local.sh
- ;;
"build") exec bash scripts/dev.sh ;;
+ "run") exec bash scripts/run.sh ;;
"doctor") exec bash scripts/doctor.sh ;;
"hooks") exec bash scripts/install-hooks.sh ;;
*)
diff --git a/scripts/README.md b/scripts/README.md
index f046eab4..b793a293 100644
--- a/scripts/README.md
+++ b/scripts/README.md
@@ -21,6 +21,7 @@ Development and CI scripts for PinchTab.
|--------|---------|
| `build-dashboard.sh` | Generate TS types (tygo) + build React dashboard + copy to Go embed |
| `dev.sh` | Full build (dashboard + Go) and run |
+| `run.sh` | Run the existing `./pinchtab` binary |
## Setup
diff --git a/scripts/run.sh b/scripts/run.sh
new file mode 100755
index 00000000..ec4ab3ed
--- /dev/null
+++ b/scripts/run.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+# Run an existing PinchTab binary from the repo root.
+set -euo pipefail
+
+cd "$(dirname "$0")/.."
+
+if [ ! -x ./pinchtab ]; then
+ echo "pinchtab binary not found at ./pinchtab"
+ echo "Build it first with: go build -o pinchtab ./cmd/pinchtab"
+ exit 1
+fi
+
+exec ./pinchtab "$@"
diff --git a/tests/e2e/Dockerfile.pinchtab b/tests/e2e/Dockerfile.pinchtab
deleted file mode 100644
index f05707a9..00000000
--- a/tests/e2e/Dockerfile.pinchtab
+++ /dev/null
@@ -1,53 +0,0 @@
-# Build stage
-FROM golang:1.26-alpine AS builder
-RUN apk add --no-cache git
-WORKDIR /build
-COPY go.mod go.sum ./
-RUN go mod download
-COPY . .
-RUN go build -ldflags="-s -w" -o pinchtab ./cmd/pinchtab
-
-# Runtime stage
-FROM alpine:latest
-
-# Install Chromium and dependencies (same as main Dockerfile)
-RUN apk add --no-cache \
- chromium \
- nss \
- freetype \
- harfbuzz \
- ca-certificates \
- ttf-freefont \
- curl \
- dumb-init
-
-# Create non-root user and state directory
-RUN adduser -D -g '' pinchtab && \
- mkdir -p /data && \
- chown pinchtab:pinchtab /data
-
-# Copy binary from builder
-COPY --from=builder /build/pinchtab /usr/local/bin/pinchtab
-
-# Stay as root for --no-sandbox Chrome
-WORKDIR /data
-
-# Environment variables for headless Chrome in Docker
-ENV PINCHTAB_BIND=0.0.0.0 \
- PINCHTAB_PORT=9999 \
- PINCHTAB_HEADLESS=true \
- PINCHTAB_STATE_DIR=/data \
- CHROME_BIN=/usr/bin/chromium-browser
-
-# Create config with Chrome flags for Docker, IDPI allowlist, and security features enabled
-# Config goes in XDG_CONFIG_HOME which defaults to ~/.config
-# AllowedDomains replaces defaults, so include localhost + fixtures
-# Enable evaluate/download/upload for comprehensive E2E testing
-# Use LRU tab eviction with lower limit for memory efficiency
-RUN mkdir -p /root/.config/pinchtab && \
- echo '{"browser":{"extraFlags":"--no-sandbox --disable-dev-shm-usage"},"instanceDefaults":{"maxTabs":10,"tabEvictionPolicy":"close_lru"},"security":{"allowEvaluate":true,"allowDownload":true,"allowUpload":true,"idpi":{"enabled":true,"allowedDomains":["localhost","127.0.0.1","::1","fixtures"]}}}' > /root/.config/pinchtab/config.json
-
-EXPOSE 9999
-
-ENTRYPOINT ["/usr/bin/dumb-init", "--"]
-CMD ["pinchtab", "server"]
diff --git a/tests/e2e/Dockerfile.pinchtab-secure b/tests/e2e/Dockerfile.pinchtab-secure
deleted file mode 100644
index a4deb0ac..00000000
--- a/tests/e2e/Dockerfile.pinchtab-secure
+++ /dev/null
@@ -1,56 +0,0 @@
-# Pinchtab with STRICT security settings (features DISABLED)
-# Used to test that security controls actually block requests
-
-# Build stage
-FROM golang:1.26-alpine AS builder
-RUN apk add --no-cache git
-WORKDIR /build
-COPY go.mod go.sum ./
-RUN go mod download
-COPY . .
-RUN go build -ldflags="-s -w" -o pinchtab ./cmd/pinchtab
-
-# Runtime stage
-FROM alpine:latest
-
-# Install Chromium and dependencies (same as main Dockerfile)
-RUN apk add --no-cache \
- chromium \
- nss \
- freetype \
- harfbuzz \
- ca-certificates \
- ttf-freefont \
- curl \
- dumb-init
-
-# Create non-root user and state directory
-RUN adduser -D -g '' pinchtab && \
- mkdir -p /data && \
- chown pinchtab:pinchtab /data
-
-# Copy binary from builder
-COPY --from=builder /build/pinchtab /usr/local/bin/pinchtab
-
-# Stay as root for --no-sandbox Chrome
-WORKDIR /data
-
-# Environment variables for headless Chrome in Docker
-ENV PINCHTAB_BIND=0.0.0.0 \
- PINCHTAB_PORT=9999 \
- PINCHTAB_HEADLESS=true \
- PINCHTAB_STATE_DIR=/data \
- CHROME_BIN=/usr/bin/chromium-browser
-
-# STRICT security config:
-# - evaluate DISABLED
-# - download DISABLED
-# - upload DISABLED
-# - IDPI ENABLED with restrictive allowlist (only internal-test.invalid)
-RUN mkdir -p /root/.config/pinchtab && \
- echo '{"browser":{"extraFlags":"--no-sandbox --disable-dev-shm-usage"},"instanceDefaults":{"maxTabs":10,"tabEvictionPolicy":"close_lru"},"security":{"allowEvaluate":false,"allowDownload":false,"allowUpload":false,"idpi":{"enabled":true,"strictMode":true,"allowedDomains":["internal-test.invalid"]}}}' > /root/.config/pinchtab/config.json
-
-EXPOSE 9999
-
-ENTRYPOINT ["/usr/bin/dumb-init", "--"]
-CMD ["pinchtab", "server"]
diff --git a/tests/e2e/README.md b/tests/e2e/README.md
index 07199143..8cc5123b 100644
--- a/tests/e2e/README.md
+++ b/tests/e2e/README.md
@@ -15,27 +15,14 @@ Or directly:
docker compose -f tests/e2e/docker-compose.yml up --build
```
-### Local (without Docker)
-
-Requires: pinchtab binary, python3 or node
-
-```bash
-./pdev e2e local
-```
-
-Or directly:
-```bash
-go build -o pinchtab ./cmd/pinchtab
-./tests/e2e/run-local.sh
-```
-
## Architecture
```
tests/e2e/
β”œβ”€β”€ docker-compose.yml # Orchestrates all services
-β”œβ”€β”€ Dockerfile.pinchtab # Builds pinchtab with Chrome
-β”œβ”€β”€ run-local.sh # Local runner (no Docker)
+β”œβ”€β”€ config/ # E2E-specific PinchTab configs
+β”‚ β”œβ”€β”€ pinchtab.json
+β”‚ └── pinchtab-secure.json
β”œβ”€β”€ fixtures/ # Static HTML test pages
β”‚ β”œβ”€β”€ index.html
β”‚ β”œβ”€β”€ form.html
@@ -55,6 +42,8 @@ tests/e2e/
└── results/ # Test output (gitignored)
```
+The Docker stack reuses the repository root `Dockerfile` and mounts explicit config files with `PINCHTAB_CONFIG` instead of maintaining separate e2e-only images.
+
## Test Scenarios
| Script | Tests |
diff --git a/tests/e2e/config/pinchtab-secure.json b/tests/e2e/config/pinchtab-secure.json
new file mode 100644
index 00000000..3f31f0c6
--- /dev/null
+++ b/tests/e2e/config/pinchtab-secure.json
@@ -0,0 +1,25 @@
+{
+ "server": {
+ "bind": "0.0.0.0",
+ "port": "9999"
+ },
+ "browser": {
+ "extraFlags": "--no-sandbox --disable-dev-shm-usage"
+ },
+ "instanceDefaults": {
+ "maxTabs": 10,
+ "tabEvictionPolicy": "close_lru"
+ },
+ "security": {
+ "allowEvaluate": false,
+ "allowDownload": false,
+ "allowUpload": false,
+ "idpi": {
+ "enabled": true,
+ "strictMode": true,
+ "allowedDomains": [
+ "internal-test.invalid"
+ ]
+ }
+ }
+}
diff --git a/tests/e2e/config/pinchtab.json b/tests/e2e/config/pinchtab.json
new file mode 100644
index 00000000..4a7d17b5
--- /dev/null
+++ b/tests/e2e/config/pinchtab.json
@@ -0,0 +1,27 @@
+{
+ "server": {
+ "bind": "0.0.0.0",
+ "port": "9999"
+ },
+ "browser": {
+ "extraFlags": "--no-sandbox --disable-dev-shm-usage"
+ },
+ "instanceDefaults": {
+ "maxTabs": 10,
+ "tabEvictionPolicy": "close_lru"
+ },
+ "security": {
+ "allowEvaluate": true,
+ "allowDownload": true,
+ "allowUpload": true,
+ "idpi": {
+ "enabled": true,
+ "allowedDomains": [
+ "localhost",
+ "127.0.0.1",
+ "::1",
+ "fixtures"
+ ]
+ }
+ }
+}
diff --git a/tests/e2e/docker-compose.yml b/tests/e2e/docker-compose.yml
index 862c45c3..5cf0b6fb 100644
--- a/tests/e2e/docker-compose.yml
+++ b/tests/e2e/docker-compose.yml
@@ -3,13 +3,19 @@ services:
pinchtab:
build:
context: ../..
- dockerfile: tests/e2e/Dockerfile.pinchtab
+ dockerfile: Dockerfile
+ environment:
+ PINCHTAB_CONFIG: /config/pinchtab.json
+ PINCHTAB_PORT: "9999"
+ CHROME_BIN: /usr/bin/chromium
+ volumes:
+ - ./config/pinchtab.json:/config/pinchtab.json:ro
ports:
- "9999:9999"
# Chrome needs more shared memory in Docker
shm_size: '2gb'
healthcheck:
- test: ["CMD", "curl", "-sf", "http://localhost:9999/health"]
+ test: ["CMD-SHELL", "wget -q -O /dev/null http://localhost:9999/health"]
interval: 3s
timeout: 10s
retries: 20
@@ -19,12 +25,18 @@ services:
pinchtab-secure:
build:
context: ../..
- dockerfile: tests/e2e/Dockerfile.pinchtab-secure
+ dockerfile: Dockerfile
+ environment:
+ PINCHTAB_CONFIG: /config/pinchtab-secure.json
+ PINCHTAB_PORT: "9999"
+ CHROME_BIN: /usr/bin/chromium
+ volumes:
+ - ./config/pinchtab-secure.json:/config/pinchtab-secure.json:ro
ports:
- "9998:9999"
shm_size: '2gb'
healthcheck:
- test: ["CMD", "curl", "-sf", "http://localhost:9999/health"]
+ test: ["CMD-SHELL", "wget -q -O /dev/null http://localhost:9999/health"]
interval: 3s
timeout: 10s
retries: 20
@@ -35,7 +47,7 @@ services:
volumes:
- ./fixtures:/usr/share/nginx/html:ro
healthcheck:
- test: ["CMD", "curl", "-f", "http://localhost:80/"]
+ test: ["CMD-SHELL", "wget -q -O /dev/null http://localhost:80/"]
interval: 2s
timeout: 5s
retries: 5
diff --git a/tests/e2e/run-local.sh b/tests/e2e/run-local.sh
deleted file mode 100755
index a37c8045..00000000
--- a/tests/e2e/run-local.sh
+++ /dev/null
@@ -1,89 +0,0 @@
-#!/bin/bash
-# run-local.sh - Run E2E tests locally without Docker
-#
-# Prerequisites:
-# - pinchtab built and in PATH or ./pinchtab
-# - A simple HTTP server for fixtures (python or node)
-#
-# Usage:
-# ./tests/e2e/run-local.sh
-
-set -euo pipefail
-
-SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
-PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
-
-# Colors
-RED='\033[0;31m'
-GREEN='\033[0;32m'
-YELLOW='\033[0;33m'
-NC='\033[0m'
-
-cleanup() {
- echo -e "\n${YELLOW}Cleaning up...${NC}"
- [ -n "${PINCHTAB_PID:-}" ] && kill "$PINCHTAB_PID" 2>/dev/null || true
- [ -n "${FIXTURE_PID:-}" ] && kill "$FIXTURE_PID" 2>/dev/null || true
-}
-trap cleanup EXIT
-
-# Find pinchtab binary
-PINCHTAB_BIN=""
-if [ -x "$PROJECT_ROOT/pinchtab" ]; then
- PINCHTAB_BIN="$PROJECT_ROOT/pinchtab"
-elif command -v pinchtab &>/dev/null; then
- PINCHTAB_BIN="$(command -v pinchtab)"
-else
- echo -e "${RED}Error: pinchtab binary not found${NC}"
- echo "Build it first: go build -o pinchtab ./cmd/pinchtab"
- exit 1
-fi
-
-echo -e "${GREEN}Using pinchtab: $PINCHTAB_BIN${NC}"
-
-# Start fixture server
-FIXTURES_PORT=8765
-echo -e "${YELLOW}Starting fixture server on port $FIXTURES_PORT...${NC}"
-
-if command -v python3 &>/dev/null; then
- (cd "$SCRIPT_DIR/fixtures" && python3 -m http.server "$FIXTURES_PORT" &>/dev/null) &
- FIXTURE_PID=$!
-elif command -v npx &>/dev/null; then
- (cd "$SCRIPT_DIR/fixtures" && npx serve -l "$FIXTURES_PORT" &>/dev/null) &
- FIXTURE_PID=$!
-else
- echo -e "${RED}Error: Need python3 or npx for fixture server${NC}"
- exit 1
-fi
-
-sleep 2
-
-# Start pinchtab server
-PINCHTAB_PORT=9876
-echo -e "${YELLOW}Starting pinchtab on port $PINCHTAB_PORT...${NC}"
-
-PINCHTAB_PORT=$PINCHTAB_PORT PINCHTAB_HEADLESS=true "$PINCHTAB_BIN" server &>/dev/null &
-PINCHTAB_PID=$!
-
-# Wait for pinchtab to be ready
-for i in {1..30}; do
- if curl -s "http://localhost:$PINCHTAB_PORT/health" &>/dev/null; then
- echo -e "${GREEN}Pinchtab ready${NC}"
- break
- fi
- sleep 1
-done
-
-# Check if pinchtab started
-if ! curl -s "http://localhost:$PINCHTAB_PORT/health" &>/dev/null; then
- echo -e "${RED}Error: Pinchtab failed to start${NC}"
- exit 1
-fi
-
-# Run tests
-echo -e "\n${YELLOW}Running E2E tests...${NC}\n"
-
-export PINCHTAB_URL="http://localhost:$PINCHTAB_PORT"
-export FIXTURES_URL="http://localhost:$FIXTURES_PORT"
-export RESULTS_DIR=""
-
-"$SCRIPT_DIR/scenarios/run-all.sh"