open-design/deploy/Dockerfile
Zihan Zhao cfcfbe0178
Inline attached file context for BYOK chats (#1730)
BYOK/API-mode chats bypass the daemon run path, so attached project
files were saved as message metadata but their readable contents were
not sent to the provider. This adds a web-side attachment context step
for API-mode requests, reusing raw text reads and existing document
preview extraction.

Constraint: Docker PDF previews require pdftotext in the runtime image
Confidence: high
Scope-risk: moderate
Tested: corepack pnpm --filter @open-design/web test -- tests/api-attachment-context.test.ts tests/components/ProjectView.api-empty-response.test.tsx
Tested: corepack pnpm --filter @open-design/web typecheck
Tested: corepack pnpm --filter @open-design/web build
Tested: corepack pnpm guard
Tested: corepack pnpm typecheck
2026-05-15 15:52:15 +08:00

97 lines
3 KiB
Docker

ARG NODE_IMAGE=docker.io/library/node:24-alpine
ARG RUNTIME_IMAGE=docker.io/library/node:24-alpine
FROM ${NODE_IMAGE} AS build
ARG HTTP_PROXY
ARG HTTPS_PROXY
ARG http_proxy
ARG https_proxy
ARG no_proxy
ARG NO_PROXY
ENV HTTP_PROXY=${HTTP_PROXY}
ENV HTTPS_PROXY=${HTTPS_PROXY}
ENV http_proxy=${http_proxy}
ENV https_proxy=${https_proxy}
ENV no_proxy=${no_proxy}
ENV NO_PROXY=${NO_PROXY}
ENV CI=true
RUN apk add --no-cache python3 make g++
WORKDIR /app
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
COPY scripts/postinstall.mjs ./scripts/postinstall.mjs
COPY packages ./packages
COPY tools ./tools
COPY apps/daemon/package.json ./apps/daemon/package.json
COPY apps/web/package.json ./apps/web/package.json
COPY e2e/package.json ./e2e/package.json
RUN corepack enable && \
corepack prepare pnpm@10.33.2 --activate && \
pnpm install --frozen-lockfile
COPY apps ./apps
RUN pnpm --filter @open-design/daemon build && \
pnpm --filter @open-design/web build && \
pnpm --filter @open-design/daemon deploy --legacy --prod /app/deploy/daemon && \
pnpm store prune && \
rm -rf \
/root/.cache \
/root/.local/share/pnpm/store \
/app/deploy/daemon/node_modules/.cache \
/app/deploy/daemon/node_modules/@types \
/app/deploy/daemon/node_modules/.pnpm/@types+* \
/app/deploy/daemon/node_modules/.pnpm/better-sqlite3@*/node_modules/better-sqlite3/deps \
/app/deploy/daemon/node_modules/.pnpm/better-sqlite3@*/node_modules/better-sqlite3/src && \
find /app/deploy/daemon/node_modules -type d \( \
-name test -o \
-name tests -o \
-name "__tests__" -o \
-name docs -o \
-name doc -o \
-name example -o \
-name examples -o \
-name ".github" \
\) -prune -exec rm -rf '{}' + && \
find /app/deploy/daemon/node_modules -type f \( \
-name "*.md" -o \
-name "*.markdown" -o \
-name "*.d.ts" -o \
-name "*.d.cts" -o \
-name "*.d.mts" -o \
-name "*.map" -o \
-name "*.tsbuildinfo" -o \
-name "binding.gyp" \
\) -delete
FROM ${RUNTIME_IMAGE}
RUN apk add --no-cache tini poppler-utils && \
addgroup -S -g 1001 open-design && \
adduser -S -D -H -u 1001 -G open-design open-design
WORKDIR /app
COPY --from=build --chown=open-design:open-design /app/deploy/daemon ./apps/daemon
COPY --from=build --chown=open-design:open-design /app/apps/web/out ./apps/web/out
COPY --chown=open-design:open-design skills ./skills
COPY --chown=open-design:open-design design-systems ./design-systems
COPY --chown=open-design:open-design craft ./craft
COPY --chown=open-design:open-design prompt-templates ./prompt-templates
COPY --chown=open-design:open-design assets/frames ./assets/frames
COPY --chown=open-design:open-design assets/community-pets ./assets/community-pets
RUN mkdir -p /app/.od && \
chown -R open-design:open-design /app
ENV NODE_ENV=production
ENV NODE_OPTIONS=--max-old-space-size=192
ENV OD_BIND_HOST=0.0.0.0
ENV OD_PORT=7456
EXPOSE 7456
USER open-design
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["node", "apps/daemon/dist/cli.js", "--no-open"]