#!/usr/bin/env bash # Inner entrypoint for the npm-bench Docker container; not called directly. Installs # dependencies, starts computerd, and runs npm-bench.sh. Not meant to be # called directly — run-npm-bench.sh is the user-facing entry point. set -u apt-get update >/dev/null 2>&1 apt-get install -y --no-install-recommends \ fuse3 attr util-linux coreutils findutils \ ca-certificates curl nodejs npm >/dev/null 2>&1 mkdir -p /tmp/workspace /tmp/baseline # Only node_modules is local-only, so package.json and the lock stay # synced, as in a real project. MOUNT_IGNORE="" if [ "${IGNORE_NODE_MODULES:-0}" = "1" ]; then MOUNT_IGNORE="/ignored/*/node_modules" fi COMPUTERD_FUSE_TRACE="${COMPUTERD_FUSE_TRACE:-}" \ COMPUTERD_FUSE_TRACE_FILE="${COMPUTERD_FUSE_TRACE_FILE:-}" \ COMPUTERD_FUSE_PASSTHROUGH="${COMPUTERD_FUSE_PASSTHROUGH:-}" \ MOUNT_IGNORE="$MOUNT_IGNORE" \ COMPUTERD_FUSE_NATIVE_ROOTS="${COMPUTERD_FUSE_NATIVE_ROOTS:-}" \ PORT=45678 MOUNT_POINT=/tmp/workspace /usr/local/bin/computerd >/tmp/computerd.log 2>&1 & COMPUTERD_PID=$! for i in $(seq 1 60); do if curl -fsS http://127.0.0.1:45678/health >/dev/null 2>&1; then echo "computerd ready after ${i}s" break fi sleep 1 done if ! kill -0 "$COMPUTERD_PID" 2>/dev/null; then echo "computerd died:" cat /tmp/computerd.log exit 1 fi COMPUTERD_URL="" if [ -n "$MOUNT_IGNORE" ]; then COMPUTERD_URL=http://127.0.0.1:45678 fi COMPUTERD_URL="$COMPUTERD_URL" MOUNT=/tmp/workspace BASE=/tmp/baseline /usr/local/bin/npm-bench status=$? if [ -n "$MOUNT_IGNORE" ]; then echo "[bench] passthrough status:" curl -fsS http://127.0.0.1:45678/__computerd/info | tr ',' '\n' | grep -i -E 'passthrough|nativeRoots|"mounts"|"failures"' || true fi kill -USR2 "$COMPUTERD_PID" 2>/dev/null && sleep 1 kill "$COMPUTERD_PID" 2>/dev/null wait "$COMPUTERD_PID" 2>/dev/null exit $status