# Stage 1: Builder FROM node:22-bookworm AS builder # Install build dependencies RUN apt-get update && apt-get install -y \ curl \ git \ python3 \ make \ g++ \ socat \ unzip \ && rm -rf /var/lib/apt/lists/* # Install Bun RUN curl -fsSL https://bun.sh/install | bash ENV BUN_INSTALL="/root/.bun" ENV PATH="${BUN_INSTALL}/bin:${PATH}" RUN corepack enable WORKDIR /app # Clone with depth 1 to save space (removes history) RUN git clone --depth 1 https://github.com/moltbot/moltbot.git . # Install dependencies RUN pnpm install --frozen-lockfile # Build Backend RUN CLAWDBOT_A2UI_SKIP_MISSING=1 pnpm build # Build UI ENV CLAWDBOT_PREFER_PNPM=1 RUN pnpm ui:install RUN pnpm ui:build # Remove devDependencies to reduce size RUN pnpm prune --prod # Remove .git folder to save space RUN rm -rf .git # Stage 2: Runner FROM node:22-bookworm-slim WORKDIR /home/node/app # Install runtime dependencies (lightweight) # build tools (make, g++) are not needed for runtime RUN apt-get update && apt-get install -y \ python3 \ socat \ git \ && rm -rf /var/lib/apt/lists/* # Set user USER node # Copy application from builder # We copy the entire folder as pruned by 'pnpm prune --prod' COPY --from=builder --chown=node:node /app /home/node/app # Start CMD ["node", "dist/index.js"]