# ─── build stage ───────────────────────────────────────────────────────────── FROM node:24-slim AS builder WORKDIR /agent # Install all deps (including dev deps required by tsc) COPY package*.json tsconfig.json ./ RUN npm ci COPY src/ ./src/ # Compile TypeScript → /agent/dist/ RUN npm run build # Prune dev deps for the final image RUN npm prune --omit=dev # ─── runtime stage ──────────────────────────────────────────────────────────── FROM node:24-slim # Install pi globally so it is available as a shell tool (e.g. inside bash tool) RUN npm install -g @mariozechner/pi-coding-agent WORKDIR /agent # Copy compiled app + production deps COPY --from=builder /agent/dist ./dist COPY --from=builder /agent/node_modules ./node_modules COPY package.json ./ # /app is the project directory mounted at runtime VOLUME ["/app"] ENV NODE_ENV=production # Default working directory for the agent (overridable via CWD env var) ENV CWD=/app # Gateway defaults ENV RUN_MODE=gateway ENV GATEWAY_HOST=0.0.0.0 ENV GATEWAY_PORT=8787 EXPOSE 8787 CMD ["node", "dist/index.js"]