openpencil/Dockerfile.web-vue

76 lines
2.9 KiB
Docker
Raw Normal View History

# syntax=docker/dockerfile:1
#
# Dockerfile.web-vue — container for the VUE editor (master, v0.14.0) + MCP.
#
# Replaces the retired Dockerfile.web-rust (Rust web host, main branch). This
# image serves the static SPA build (the same `dist/` artifact that Cloudflare
# Pages deploys for app.openpencil.dev) on :3100 AND the @open-pencil/mcp
# Streamable-HTTP server on :7600, both from one container via the entrypoint.
# w4c-chatapi talks MCP to http://openpencil:7600/mcp (OpenPencilMcp__HttpEndpoint).
#
# Build:
# docker build -f Dockerfile.web-vue -t w4c-openpencil:latest .
#
# Run:
# docker run -p 3100:3100 -p 7600:7600 \
# -e OPENPENCIL_MCP_AUTH_TOKEN=... \
# -e OPENPENCIL_MCP_CORS_ORIGIN=https://openpencil.wiz4chat.com \
# -v openpencil_data:/data \
# w4c-openpencil:latest
# ── Stage 1: builder — bun, install + build the SPA and the MCP packages ─────
FROM oven/bun:1 AS builder
WORKDIR /app
# Lockfile + manifests first for layer caching.
COPY package.json bun.lock bunfig.toml ./
COPY packages/scene-graph/package.json packages/scene-graph/
COPY packages/pen/package.json packages/pen/
COPY packages/kiwi/package.json packages/kiwi/
COPY packages/fig/package.json packages/fig/
COPY packages/core/package.json packages/core/
COPY packages/dom-css/package.json packages/dom-css/
COPY packages/vue/package.json packages/vue/
COPY packages/cli/package.json packages/cli/
COPY packages/mcp/package.json packages/mcp/
COPY packages/harness/package.json packages/harness/
COPY packages/docs/package.json packages/docs/
COPY tools/docs/package.json tools/docs/
RUN bun install --frozen-lockfile
# Full source (excludes heavy local build outputs via .dockerignore).
COPY . .
# Same pipeline as the Cloudflare Pages deploy (app.yml): build:packages →
# lint → vite build. Lint runs on the vendored fork (includes our theme patch).
RUN bun run build
# Prune to production dependencies so the runtime layer is lean. bun keeps
# workspace symlinks; the MCP server's deps (hono, @modelcontextprotocol/sdk,
# ws, zod + @open-pencil/core) are all in the prod graph.
RUN bun install --production --frozen-lockfile
# ── Stage 2: runtime — static SPA (:3100) + MCP (:7600) ─────────────────────
FROM oven/bun:1-slim AS runtime
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/bun.lock ./bun.lock
COPY --from=builder /app/bunfig.toml ./bunfig.toml
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/packages ./packages
COPY --from=builder /app/docker/static-server.mjs ./static-server.mjs
COPY --from=builder /app/docker/entrypoint.sh /entrypoint.sh
# Writable document root for MCP file-scoped tools (open_file / new_document /
# save_file). Keep on a volume so documents survive container restarts.
ENV OPENPENCIL_MCP_ROOT=/data
EXPOSE 3100 7600
ENTRYPOINT ["/entrypoint.sh"]