Files
openmotion/deploy/Dockerfile
Heggria bccb40cc97 Share one OpenDesign sign-in across all workspaces on a computer (#787)
* Share one OpenDesign sign-in across all workspaces on a computer

Each data directory used to keep its own connector credentials, so a Studio
opened on its own and an Agent host started with another MOTION_DATA_DIR,
installation or channel signed in separately. The account (credentials,
session, model catalogue and private connector) now lives in one per-user
directory; MOTION_ACCOUNT_DIR overrides it and temporary workspaces stay
isolated. An existing workspace sign-in moves there once. Cached plan and
catalogue are tied to the key and session they were read for, and the shared
connector installation runs npm once under a process lock.

* Keep connectors per workspace and never resurrect a signed-out account

Connector versions differ between channels, so each workspace keeps its own
runtime and a workspace signed in through the shared account prepares it on
first use. A legacy sign-in moves only into a shared directory that has never
held an account, under a process lock, and the same directory reached through
another spelling is recognised by device and inode. Temporary-directory checks
resolve Windows short names, and a catalogue read for an older session is not
written over a newer one.

* Bring along a workspace sign-in made after the shared account's last change

A shared directory that was signed out earlier no longer discards a newer
sign-in another workspace made with an earlier release; only sign-ins older
than the shared directory's last sign-in, cancel or sign-out are dropped.

* Make legacy account migration atomic, align storage docs, and avoid personal paths in tests

- Stage legacy account files to temporary paths with 0600 permissions before renaming them into the shared directory, rolling back any committed file on failure so the workspace keeps its only copy and no shared marker is left behind.
- Add regression tests covering copy failures on both empty shared directories and directories with an existing sign-out marker.
- Replace personal-path-shaped strings in sharedAccountDirectory tests with synthetic paths to satisfy the release source privacy scan.
- Update model-gateway, provider-settings, architecture and account skill docs to separate workspace-local account/runtime from the per-user account directory.
2026-11-21 01:48:06 -08:00

43 lines
1.7 KiB
Docker

# Node version follows scripts/runtime-lock.json and CI.
ARG NODE_VERSION=26.11.1
# Build stage: full dependencies, then the Studio bundle and generated UI.
FROM node:${NODE_VERSION}-bookworm-slim AS build
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --no-audit --no-fund
COPY . .
RUN npm run build:studio
# Runtime stage: production dependencies, system Chromium, FFmpeg and fonts.
FROM node:${NODE_VERSION}-bookworm-slim AS runtime
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates chromium ffmpeg fonts-noto-cjk fonts-noto-color-emoji 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
COPY . .
COPY --from=build /app/studio/build ./studio/build
COPY --from=build /app/web/inline-video.html ./web/inline-video.html
COPY --from=build /app/mcp-ui/template-recommendations/build ./mcp-ui/template-recommendations/build
# The server listens on every container interface so Compose can publish the
# port; Compose publishes it on the host's loopback address only.
ENV PORT=4173 \
MOTION_BIND_HOST=0.0.0.0 \
MOTION_DATA_DIR=/data \
MOTION_ACCOUNT_DIR=/data/account \
HYPERFRAMES_BROWSER_PATH=/usr/bin/chromium \
HYPERFRAMES_FFMPEG_PATH=/usr/bin/ffmpeg \
HYPERFRAMES_FFPROBE_PATH=/usr/bin/ffprobe
RUN mkdir -p /data && chown node:node /data
USER node
VOLUME /data
EXPOSE 4173
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
CMD node -e "fetch('http://127.0.0.1:'+process.env.PORT+'/api/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"
ENTRYPOINT ["tini", "--"]
CMD ["node", "--experimental-strip-types", "server.ts"]