Dockerfile 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. # ── Stage 1: Builder ──────────────────────────────────────────────────
  2. FROM node:22-bookworm AS builder
  3. WORKDIR /build
  4. # System deps for native modules (node-pty, sharp, bcrypt, better-sqlite3)
  5. RUN apt-get update && apt-get install -y --no-install-recommends \
  6. python3 make g++ git \
  7. && rm -rf /var/lib/apt/lists/*
  8. # Copy package manifests first for layer caching.
  9. # ui/ is a npm workspace — root pnpm install handles both.
  10. COPY package.json pnpm-lock.yaml pnpm-workspace.yaml tsconfig.json ./
  11. # NOTE: edgeclaw-memory-core is consumed via a local `file:` dependency.
  12. # Copy the full directory before install so pnpm snapshots complete sources/types.
  13. COPY src/context/memory/edgeclaw-memory-core/ src/context/memory/edgeclaw-memory-core/
  14. COPY ui/package.json ui/
  15. COPY ui/scripts/ ui/scripts/
  16. # Single pnpm install resolves root + workspace (ui) + file dep (edgeclaw-memory-core).
  17. # Pin pnpm so CI builds do not pick up stricter build-script policy changes
  18. # before the lockfile/workspace config is updated.
  19. RUN npm install -g pnpm@10.32.1 \
  20. && pnpm --version \
  21. && HUSKY=0 pnpm install --frozen-lockfile
  22. # Copy all source files
  23. COPY src/ src/
  24. COPY scripts/ scripts/
  25. COPY ui/ ui/
  26. COPY skills/ skills/
  27. # Build edgeclaw-memory-core (src/ → lib/)
  28. RUN cd src/context/memory/edgeclaw-memory-core && npm run build
  29. # Build gateway (TypeScript → dist/)
  30. RUN npm run build
  31. # Build UI frontend (Vite → ui/dist/)
  32. RUN cd ui && npm run build
  33. # ── Stage 2: Runtime ─────────────────────────────────────────────────
  34. FROM node:22-bookworm-slim
  35. WORKDIR /app
  36. # Runtime system dependencies + tsx/concurrently for process management
  37. RUN apt-get update && apt-get install -y --no-install-recommends \
  38. ripgrep git curl procps \
  39. && rm -rf /var/lib/apt/lists/* \
  40. && npm install -g tsx concurrently
  41. # Copy built application from builder
  42. COPY --from=builder /build/package.json /build/pnpm-lock.yaml ./
  43. COPY --from=builder /build/tsconfig.json ./
  44. COPY --from=builder /build/node_modules/ node_modules/
  45. COPY --from=builder /build/dist/ dist/
  46. COPY --from=builder /build/src/ src/
  47. COPY --from=builder /build/scripts/ scripts/
  48. COPY --from=builder /build/skills/ skills/
  49. COPY --from=builder /build/ui/package.json ui/package.json
  50. COPY --from=builder /build/ui/node_modules/ ui/node_modules/
  51. COPY --from=builder /build/ui/server/ ui/server/
  52. COPY --from=builder /build/ui/dist/ ui/dist/
  53. COPY --from=builder /build/ui/scripts/ ui/scripts/
  54. COPY --from=builder /build/ui/shared/ ui/shared/
  55. COPY --from=builder /build/ui/vite.config.js ui/vite.config.js
  56. # Create PilotDeck state/workspace directories used by the gateway, UI server,
  57. # permissions, skills/plugins, memory, auth, and router stats.
  58. RUN mkdir -p \
  59. /root/.pilotdeck/projects \
  60. /root/.pilotdeck/router \
  61. /root/.pilotdeck/skills \
  62. /root/.pilotdeck/plugins \
  63. /root/.pilotdeck/memory \
  64. /workspace
  65. # Entrypoint
  66. COPY docker-entrypoint.sh /docker-entrypoint.sh
  67. RUN chmod +x /docker-entrypoint.sh
  68. ENV NODE_ENV=production
  69. ENV PILOT_HOME=/root/.pilotdeck
  70. ENV HOST=0.0.0.0
  71. ENV SERVER_PORT=3001
  72. ENV PILOTDECK_GATEWAY_PORT=18789
  73. EXPOSE 3001
  74. ENTRYPOINT ["/docker-entrypoint.sh"]