-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.facilitator
More file actions
73 lines (68 loc) · 3.88 KB
/
Copy pathDockerfile.facilitator
File metadata and controls
73 lines (68 loc) · 3.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# syntax=docker/dockerfile:1
# Builds apps/facilitator only. Run from the repo root (build context must
# include the pnpm workspace root). apps/facilitator has a real runtime
# dependency on @periplo/bazaar (Phase 4, automatic cataloging) and
# @periplo/search (Phase 5, embeddings for hybrid search), pnpm workspace
# resolution symlinks apps/facilitator/node_modules/@periplo/* to
# ../../../packages/*, so each must be (1) built (`tsc -p`, not `-b`,
# doesn't auto-build referenced projects: its dist/ has to exist before
# @periplo/facilitator's own `tsc -p` can resolve the package's types) and
# (2) present in the runtime stage too, or the symlink dangles.
# packages/licence-check has no runtime dependency and is only here because
# pnpm workspace resolution needs every workspace package.json present to
# compute the lockfile-consistent install, even ones this image never runs.
FROM node:22-slim AS base
RUN corepack enable
WORKDIR /app
FROM base AS deps
COPY pnpm-workspace.yaml package.json pnpm-lock.yaml ./
COPY packages/licence-check/package.json packages/licence-check/package.json
COPY packages/bazaar/package.json packages/bazaar/package.json
COPY packages/search/package.json packages/search/package.json
COPY apps/facilitator/package.json apps/facilitator/package.json
# onnxruntime-node's postinstall defaults to downloading a ~340MB CUDA
# provider binary on Linux/x64, this image and the Fly deployment are both
# CPU-only, so it's pure waste (found by inspecting the installed size, see
# docs/DEFERRED.md).
ENV ONNXRUNTIME_NODE_INSTALL_CUDA=skip
RUN pnpm install --frozen-lockfile
FROM deps AS build
COPY tsconfig.json tsconfig.base.json ./
COPY packages/licence-check packages/licence-check
COPY packages/bazaar packages/bazaar
COPY packages/search packages/search
COPY apps/facilitator apps/facilitator
RUN pnpm --filter @periplo/bazaar build
RUN pnpm --filter @periplo/search build
RUN pnpm --filter @periplo/facilitator build
# demo-play.ts resolves its esbuild entry point relative to its own
# `import.meta.url`, so the compiled dist/demo-play.js needs a `browser/`
# sibling too, not just src/demo-play.ts's own. src/browser is excluded
# from the facilitator's own tsc build (it targets DOM, not Node, see
# apps/facilitator/tsconfig.json), so nothing above copies it: esbuild
# bundles these .ts files directly at request time, no pre-compilation
# needed, just presence at the same relative path dist/ expects. Missing
# this crashes GET /demo/play/client.js with ENOENT in production while
# working fine under `tsx` in dev, where src/demo-play.ts and
# src/browser/ are already real siblings on disk.
RUN cp -r apps/facilitator/src/browser apps/facilitator/dist/browser
FROM base AS runtime
ENV NODE_ENV=production
COPY --from=build /app/node_modules ./node_modules
COPY --from=build /app/packages/bazaar/dist ./packages/bazaar/dist
COPY --from=build /app/packages/bazaar/package.json ./packages/bazaar/package.json
COPY --from=build /app/packages/search/dist ./packages/search/dist
COPY --from=build /app/packages/search/package.json ./packages/search/package.json
# pnpm gives every workspace package its own node_modules/ of symlinks to
# its own declared deps, resolved from the central store: missing this for
# packages/bazaar made the first Phase 4 deploy crash-loop on
# ERR_MODULE_NOT_FOUND for a dependency that genuinely was installed, just
# not copied into this stage. Same requirement applies to packages/search's
# fastembed/onnxruntime-node dependency.
COPY --from=build /app/packages/bazaar/node_modules ./packages/bazaar/node_modules
COPY --from=build /app/packages/search/node_modules ./packages/search/node_modules
COPY --from=build /app/apps/facilitator/node_modules ./apps/facilitator/node_modules
COPY --from=build /app/apps/facilitator/dist ./apps/facilitator/dist
COPY --from=build /app/apps/facilitator/package.json ./apps/facilitator/package.json
EXPOSE 8402
CMD ["node", "apps/facilitator/dist/serve.js"]