openpencil/Dockerfile.web-vue
Vitali sharp8n c6a65c4878 feat(web): ship the Vue editor web build with online font providers
- Add Dockerfile.web-vue + docker/ container: static SPA on :3100 and the
  MCP Streamable-HTTP server on :7600 in one image, replacing the retired
  Rust web host used by the w4c iframe integration
- Allow online font providers (Google Fonts, Fontsource, Bunny, Fontshare)
  to load in the browser via native CORS-enabled fetch instead of gating
  them on the Tauri fetch proxy
- Rename webFontProvidersRequireDesktopApp to webFontLoadFailed and reword
  the toast for connection failures; drop the unconditional toast from the
  font family picker
- Support OPENPENCIL_MCP_HOST so the MCP server binds 0.0.0.0 in containers
2026-08-22 00:33:54 +03:00

76 lines
2.9 KiB
Docker

# 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"]