Files
openmotion/deploy/Dockerfile
open-design-crew[bot] 1765dd0b0b [OPEND-5936] OpenGame Stage 1 Cloud Launch: read-only MCP catalog, cookieless static play, 21-section skill & Game Studio (#1198)
* feat(game-static-play): add 274-template R2 zip packaging, cookieless static play deploy, and verification pipeline

* feat(game-skill): port 21-section OpenGame skill with dual-mode workflow and fast-play path

* feat(onboarding): upgrade Cloud MCP install guide and add shared OpenGame prompt builders

* feat(game-catalog): sync 274 official templates, 4 kits, downloads manifest, and game contract

* feat(cloud-mcp): add read-only game catalog, free asset search, guest catalog API, redirects, and Docker packaging

* feat(opengame): enable Stage 1 Game Studio routing, feature flags, and analytics

* feat(opengame): add Stage 1 market, multi-client modal, Cursor HTTP fix, SuperAgent prompt, and i18n

* fix(opengame): align nullable GameCardWithMeta fields and add opengame-catalog MCP capability

* test(mcp-onboarding): update registered public tool count from 22 to 24 for Stage 1 game tools

* chore(game-catalog): register 26 verified live R2 in-repo template bundles in game-downloads.json

* fix(opengame): address Stage 1 review feedback and failing CI lanes

- Send no play URL when GAME_PLAY_PUBLIC_ORIGIN is unset instead of a main-site
  path that no route serves; Studio falls back to bundled in-repo templates
- Keep legacy-host 301 redirects on the configured origin for network-path inputs
- Correct the BlenderKit page host in the asset search allowlist
- Reuse the shared withdrawn list, TOP earning tag, curated order and comparator in Studio
- Remove the unused shared prompt module; the shipped builders stay covered by Studio tests
- Drop the blurred launch backdrop and the in-dialog copy notices in favour of Toasts
- Describe the shipped read-only Game Studio boundary and 24-tool MCP contract in the architecture
- Schedule the game skill and static play suites in CI and budget the three OpenGame events

* fix(game-static-play): retry stalled template bundle downloads before failing the run

* fix(game-asset-search): size the pagination cursor limit for every supported query

A 200-unit query with non-ASCII, control or lone-surrogate characters produced a
cursor longer than the 512-character limit, so nextCursor was rejected by both
the decoder and the public schema. Share one limit derived from the worst-case
JSON/base64url expansion and add a round-trip test for maximum-length queries.

* fix(game-asset-search): accept BlenderKit pages on www.blendkit.com and guide licence checks

www.blenderkit.com now redirects to www.blendkit.com and the upstream catalog
returns that host, so requiring www.blenderkit.com dropped every BlenderKit
result. Restore the live host, pin a real upstream row in tests, and tell
Agents to confirm the licence on the source page when a source omits it.

* fix(deploy): forward game play origin and legacy redirect hosts to the API

deploy/.env.example and deploy/k8s/configmap.yaml declared GAME_PLAY_PUBLIC_ORIGIN
and APP_REDIRECT_FROM_HOSTS, but neither the compose api service nor the reference
api Deployment passed them to the process. Wire both and assert that every
reference ConfigMap key is read by a workload.

* Address review: keep legacy-host writes, enforce play-origin isolation, share catalog constants

- Legacy-host redirects answer GET/HEAD with 301 and every other method with 308,
  so MCP and API writes keep their method and body.
- parseConfig rejects a GAME_PLAY_PUBLIC_ORIGIN that is not https (loopback http
  excepted), carries a path, or shares or sits under the APP_PUBLIC_ORIGIN host.
- The template id pattern, bundle key prefix, withdrawn set and TOP tag predicate
  live in shared/game-contract.ts; static play, deploy/verify scripts and the
  catalog service reuse them and the shared bundle URL builder.
- Remove unused game-contract and model-catalog exports.
- Update the MCP contract, AGENTS.md, README and docs to the 24-name phase-one
  surface and document the read-only OpenGame tools and guest catalog routes.

* fix(game-static-play): make the full play-site upload resumable

Upload through the S3 SDK instead of one aws CLI process per file, skip
objects whose ETag already matches the local MD5, retry each request with
backoff, and write assets before entry pages and the manifest. Give large
bundle downloads time for a slow link. Record the provisioned bucket,
domain and remaining header rule in the runbook.

* feat(game-static-play): harden live play verification and add manual R2 publish workflow

* fix(opengame): raise prompt/remix maxLength for >4k OG-13 test and reset notes on target change

* fix(mcp): register resources/templates/list handler for Codex MCP compliance

* chore(game-catalog): register uploaded tidebreaker bundle for 274/274 R2 CDN parity

---------

Co-authored-by: heggria <bshengtao@gmail.com>
2026-11-30 23:39:22 -08:00

247 lines
12 KiB
Docker

# syntax=docker/dockerfile:1.7
# Multi-target container build for OpenMotion cloud services.
# Node version matches .github/workflows/ci.yml.
ARG NODE_VERSION=26.11.1
# -----------------------------------------------------------------------------
# Stage 1: deps-build — full devDependencies to build Studio, MCP UI & tracking
# -----------------------------------------------------------------------------
FROM node:${NODE_VERSION}-bookworm-slim AS deps-build
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --no-audit --no-fund
COPY . .
ARG STUDIO_SOURCEMAP=false
ARG SENTRY_DEBUG_IDS=
RUN STUDIO_SOURCEMAP="${STUDIO_SOURCEMAP}" \
SENTRY_DEBUG_IDS="${SENTRY_DEBUG_IDS}" \
npm run build:studio \
&& rm -rf /app/studio-prod-build /app/studio-sourcemaps \
&& cp -a /app/studio/build /app/studio-prod-build \
&& find /app/studio-prod-build -type f -name '*.map' -delete \
&& mkdir -p /app/studio-sourcemaps \
&& find /app/studio/build/editor-assets -maxdepth 1 -type f \( -name '*.js' -o -name '*.js.map' \) -exec cp -p {} /app/studio-sourcemaps/ \; \
&& npm run build:tracking \
&& npm run build:observability
# -----------------------------------------------------------------------------
# Stage 2: fonts-catalog — deterministic font catalog baked identically into
# BOTH `api` and `worker-render` so preview and export typography match 100%,
# while keeping `api` strictly free of Chromium and FFmpeg binaries.
# -----------------------------------------------------------------------------
FROM node:${NODE_VERSION}-bookworm-slim AS fonts-catalog
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
fonts-noto-core \
fonts-noto-cjk \
fonts-noto-color-emoji \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir -p /app/fonts/bundled/design-system /app/fonts/bundled/studio /app/fonts/noto /app/fonts/licenses
COPY packages/design-system/fonts/ /app/fonts/bundled/design-system/
COPY library/skills/openmotion-design-remix/vendor/fonts/ /app/fonts/bundled/studio/
RUN for dir in /usr/share/fonts/truetype/noto /usr/share/fonts/opentype/noto; do \
if [ -d "$dir" ]; then \
find "$dir" -type f \( -name '*.ttf' -o -name '*.otf' -o -name '*.ttc' \) -exec cp -p {} /app/fonts/noto/ \; ; \
fi; \
done \
&& for pkg in fonts-noto-core fonts-noto-cjk fonts-noto-color-emoji; do \
if [ -f "/usr/share/doc/${pkg}/copyright" ]; then \
cp -p "/usr/share/doc/${pkg}/copyright" "/app/fonts/licenses/${pkg}-copyright.txt"; \
fi; \
done
# -----------------------------------------------------------------------------
# Stage 3: prod-base — lean production Node runtime shared by all targets.
# Intentionally EXCLUDES library/templates/catalog/ (~87 MB) so api and worker
# images stay small and diskless.
# -----------------------------------------------------------------------------
FROM node:${NODE_VERSION}-bookworm-slim AS prod-base
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
tini \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --omit=dev --no-audit --no-fund && npm cache clean --force
# Application source, migrations, skills, design-system, and runtime helpers.
COPY src/ ./src/
COPY shared/ ./shared/
COPY gateway/ ./gateway/
COPY tracking/ ./tracking/
COPY skills/ ./skills/
COPY library/components/registry/ ./library/components/registry/
COPY library/design/ ./library/design/
COPY library/skills/ ./library/skills/
COPY docs/transcripts.md docs/install.md ./docs/
COPY packages/design-system/ ./packages/design-system/
COPY packages/edit-core/ ./packages/edit-core/
COPY packages/motion-package/ ./packages/motion-package/
COPY packages/observability/ ./packages/observability/
COPY templates/compositions/ ./templates/compositions/
COPY templates/index.html ./templates/index.html
COPY templates/game-downloads.json ./templates/game-downloads.json
COPY templates/game-kits/ ./templates/game-kits/
COPY templates/games/ ./templates/games/
COPY web/ ./web/
COPY mcp-ui/template-recommendations/manifest.json \
mcp-ui/template-recommendations/inline.fragment.html \
mcp-ui/template-recommendations/i18n.ts \
mcp-ui/template-recommendations/types.ts \
mcp-ui/template-recommendations/LICENSE \
mcp-ui/template-recommendations/NOTICE.md \
./mcp-ui/template-recommendations/
COPY mcp-ui/template-recommendations/assets/ ./mcp-ui/template-recommendations/assets/
COPY mcp-ui/template-recommendations/project-previews/ ./mcp-ui/template-recommendations/project-previews/
# Curated 4-template onboarding metadata (~320 KB total) required by
# `loadTemplatePresentation()` and `/api/onboarding/*` while keeping the ~87 MB
# full catalog excluded from the lean `api` image.
COPY library/templates/catalog/motion-664184d9-593e-4984-b473-701248b69cfe/template.json \
library/templates/catalog/motion-664184d9-593e-4984-b473-701248b69cfe/TEMPLATE.md \
./library/templates/catalog/motion-664184d9-593e-4984-b473-701248b69cfe/
COPY library/templates/catalog/motion-664184d9-593e-4984-b473-701248b69cfe/source/motion.md \
library/templates/catalog/motion-664184d9-593e-4984-b473-701248b69cfe/source/preview.html \
library/templates/catalog/motion-664184d9-593e-4984-b473-701248b69cfe/source/manifest.json \
./library/templates/catalog/motion-664184d9-593e-4984-b473-701248b69cfe/source/
COPY library/templates/catalog/motion-f6f244d1-c549-4081-8a5d-f0e1e3660044/template.json \
library/templates/catalog/motion-f6f244d1-c549-4081-8a5d-f0e1e3660044/TEMPLATE.md \
./library/templates/catalog/motion-f6f244d1-c549-4081-8a5d-f0e1e3660044/
COPY library/templates/catalog/motion-f6f244d1-c549-4081-8a5d-f0e1e3660044/source/motion.md \
library/templates/catalog/motion-f6f244d1-c549-4081-8a5d-f0e1e3660044/source/preview.html \
library/templates/catalog/motion-f6f244d1-c549-4081-8a5d-f0e1e3660044/source/manifest.json \
./library/templates/catalog/motion-f6f244d1-c549-4081-8a5d-f0e1e3660044/source/
COPY library/templates/catalog/motion-0ad92fd0-b2fb-4885-957c-b71152df15fd/template.json \
library/templates/catalog/motion-0ad92fd0-b2fb-4885-957c-b71152df15fd/TEMPLATE.md \
./library/templates/catalog/motion-0ad92fd0-b2fb-4885-957c-b71152df15fd/
COPY library/templates/catalog/motion-0ad92fd0-b2fb-4885-957c-b71152df15fd/source/motion.md \
library/templates/catalog/motion-0ad92fd0-b2fb-4885-957c-b71152df15fd/source/preview.html \
library/templates/catalog/motion-0ad92fd0-b2fb-4885-957c-b71152df15fd/source/manifest.json \
./library/templates/catalog/motion-0ad92fd0-b2fb-4885-957c-b71152df15fd/source/
COPY library/templates/catalog/motion-a28f0e5d-aa8b-45a7-87f9-9afcac65a09b/template.json \
library/templates/catalog/motion-a28f0e5d-aa8b-45a7-87f9-9afcac65a09b/TEMPLATE.md \
./library/templates/catalog/motion-a28f0e5d-aa8b-45a7-87f9-9afcac65a09b/
COPY library/templates/catalog/motion-a28f0e5d-aa8b-45a7-87f9-9afcac65a09b/source/motion.md \
library/templates/catalog/motion-a28f0e5d-aa8b-45a7-87f9-9afcac65a09b/source/preview.html \
library/templates/catalog/motion-a28f0e5d-aa8b-45a7-87f9-9afcac65a09b/source/manifest.json \
./library/templates/catalog/motion-a28f0e5d-aa8b-45a7-87f9-9afcac65a09b/source/
COPY scripts/verify-export.ts scripts/init-s3.ts scripts/lint-project.mjs scripts/zip.mjs ./scripts/
COPY hyperframes.ts server.ts template-library.ts LICENSE ./
# Built frontend (strictly stripped of `.map` files), MCP Apps card bundle, and compiled tracking/observability artifacts.
COPY --from=deps-build /app/studio-prod-build ./studio/build
COPY --from=deps-build /app/web/inline-video.html ./web/inline-video.html
COPY --from=deps-build /app/mcp-ui/template-recommendations/build ./mcp-ui/template-recommendations/build
COPY --from=deps-build /app/tracking/dist ./tracking/dist
COPY --from=deps-build /app/packages/observability/dist ./packages/observability/dist
# -----------------------------------------------------------------------------
# Target 1: api — stateless, diskless HTTP/SSE/MCP server (NO Chromium/FFmpeg)
# -----------------------------------------------------------------------------
FROM prod-base AS api
COPY --chown=node:node template-library/ ./template-library/
COPY --from=fonts-catalog --chown=node:node /app/fonts /app/fonts
ENV NODE_ENV=production \
WORKER_ROLE=api \
PORT=4173 \
BIND_HOST=0.0.0.0 \
HOME=/tmp \
TMPDIR=/tmp
USER node
EXPOSE 4173
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
CMD node -e "fetch('http://127.0.0.1:'+(process.env.PORT||'4173')+'/api/health/live').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"
ENTRYPOINT ["tini", "--"]
CMD ["node", "--experimental-strip-types", "src/entrypoints/api.ts"]
# -----------------------------------------------------------------------------
# Target 2: worker-media — media ingest, probing, thumbnails, generation, GC
# Node + FFmpeg/ffprobe ONLY (NO Chromium)
# -----------------------------------------------------------------------------
FROM prod-base AS worker-media
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ffmpeg \
&& rm -rf /var/lib/apt/lists/*
ENV NODE_ENV=production \
WORKER_ROLE=media \
MEDIA_CONCURRENCY=20 \
HYPERFRAMES_FFMPEG_PATH=/usr/bin/ffmpeg \
HYPERFRAMES_FFPROBE_PATH=/usr/bin/ffprobe \
HOME=/tmp \
TMPDIR=/tmp
USER node
ENTRYPOINT ["tini", "--"]
CMD ["node", "--experimental-strip-types", "src/entrypoints/worker.ts"]
# -----------------------------------------------------------------------------
# Target 3: worker-render — isolated headless Chromium + FFmpeg export pool
# -----------------------------------------------------------------------------
FROM prod-base AS worker-render
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
chromium \
ffmpeg \
fontconfig \
fonts-noto-core \
fonts-noto-cjk \
fonts-noto-color-emoji \
&& rm -rf /var/lib/apt/lists/*
COPY --from=fonts-catalog --chown=node:node /app/fonts /app/fonts
RUN printf '<?xml version="1.0"?>\n<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">\n<fontconfig>\n <dir>/app/fonts</dir>\n</fontconfig>\n' \
> /etc/fonts/conf.d/99-openmotion-fonts.conf \
&& fc-cache -f
ENV NODE_ENV=production \
WORKER_ROLE=render \
RENDER_CONCURRENCY=1 \
RENDER_CAPTURE_WORKERS=auto \
HYPERFRAMES_BROWSER_PATH=/usr/bin/chromium \
HYPERFRAMES_FFMPEG_PATH=/usr/bin/ffmpeg \
HYPERFRAMES_FFPROBE_PATH=/usr/bin/ffprobe \
HYPERFRAMES_FONT_CACHE_DIR=/tmp/hf-font-cache \
HOME=/tmp \
TMPDIR=/tmp \
XDG_CACHE_HOME=/tmp/.cache \
XDG_CONFIG_HOME=/tmp/.config
USER node
ENTRYPOINT ["tini", "--"]
CMD ["node", "--experimental-strip-types", "src/entrypoints/worker.ts"]
# -----------------------------------------------------------------------------
# Target 4: catalog-sync — one-shot Job image syncing built-in & repository
# template catalogs into S3 CAS (catalog/blobs/{sha256}) and PostgreSQL
# -----------------------------------------------------------------------------
FROM prod-base AS catalog-sync
COPY --chown=node:node template-library/ ./template-library/
COPY --chown=node:node library/templates/catalog/ ./library/templates/catalog/
COPY --chown=node:node scripts/sync-catalog-cas.ts ./scripts/sync-catalog-cas.ts
ENV NODE_ENV=production \
HOME=/tmp \
TMPDIR=/tmp
USER node
ENTRYPOINT ["tini", "--"]
CMD ["node", "--experimental-strip-types", "scripts/sync-catalog-cas.ts"]
# -----------------------------------------------------------------------------
# Target 5: studio-sourcemaps — scratch export stage for CI Sentry uploads.
# Build alongside `api` with `--build-arg STUDIO_SOURCEMAP=hidden` and export via
# `--target studio-sourcemaps --output type=local,dest=./dist/studio-sourcemaps`.
# -----------------------------------------------------------------------------
FROM scratch AS studio-sourcemaps
COPY --from=deps-build /app/studio-sourcemaps/ /