# We MUST use Node 22 for the build to succeed FROM node:22 # 1. Install Security Certificates RUN apt-get update && apt-get install -y ca-certificates openssl && update-ca-certificates # 2. Install pnpm RUN npm install -g pnpm WORKDIR /app # 3. Clone the bot RUN git clone https://github.com/openclaw/openclaw.git . # --- FIX 1: The "IPv4 Implant" --- # This script forces the bot to ignore IPv6, fixing the "Fetch Failed" error. RUN echo "const dns = require('dns'); \ if (dns.setDefaultResultOrder) { dns.setDefaultResultOrder('ipv4first'); } \ const os = require('os'); os.hostname = () => 'clawbot';" > /app/system_patch.cjs # 4. Install Dependencies RUN pnpm install # 5. Build the bot (This will succeed on Node 22) RUN pnpm run build # --- FIX 2: Force Port & Address --- RUN grep -rl "127.0.0.1" . | xargs sed -i 's/127.0.0.1/0.0.0.0/g' RUN grep -rl "18789" . | xargs sed -i 's/18789/7860/g' # --- FIX 3: Apply the Patch --- # We load the system_patch.cjs before anything else runs. # We also disable SSL strictness just in case that was blocking it. ENV NODE_OPTIONS="--max-old-space-size=8192 --require /app/system_patch.cjs" ENV NODE_TLS_REJECT_UNAUTHORIZED="0" # Gateway Password ENV OPENCLAW_GATEWAY_TOKEN="12345-secret-password" # Start the bot CMD ["node", "scripts/run-node.mjs", "gateway", "--allow-unconfigured"]