npm ci --omit=dev alone never omitted onnxruntime-node because it's an
optionalDependency, so every build (embed on or off) shipped the ~69MB
Linux-pruned native binary even when the model weights (and therefore
the embed engine) aren't present. Pass --omit=optional too when the
build-time OPENJEV_EMBED arg is off.
Also regenerates package-lock.json: it had drifted out of sync with
package.json (missing nested @tailwindcss/oxide-wasm32-wasi deps,
stale onnxruntime-node placement), which broke `npm ci` outright on a
clean checkout independent of this fix -- found while verifying this
change actually builds.
Verified locally: `docker build --build-arg OPENJEV_EMBED=0` now
installs node_modules at 263MB vs 410MB before (-147MB, onnxruntime-node
plus other optional-only deps not needed at runtime); container boots
and GET /api/v1/health returns 200 {"status":"ok"}. `OPENJEV_EMBED=1`
build and boot verified unaffected (same health response, onnxruntime
loads as before). Box cutover is a separate owner/infra step, not done
here.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
77 lines
3.3 KiB
Docker
77 lines
3.3 KiB
Docker
# syntax=docker/dockerfile:1
|
|
|
|
###############################################################################
|
|
# openjev — Node service (typed-decision API + playground/docs UI)
|
|
#
|
|
# Builds the TanStack Start app with Nitro's `node-server` preset, producing a
|
|
# standalone server at `.output/server/index.mjs`, then runs it via the
|
|
# `openjev serve` CLI. The default `system-one` engine runs in-process
|
|
# (sentence embeddings via onnxruntime-node, ~33 MB model fetched below); the
|
|
# heavy laya-onnx model runtime is a SEPARATE sidecar container (see
|
|
# Dockerfile.laya + docker-compose.yml).
|
|
###############################################################################
|
|
|
|
# ---- build stage ------------------------------------------------------------
|
|
FROM node:22-slim AS build
|
|
WORKDIR /app
|
|
|
|
# Install dependencies against the lockfile for reproducible builds.
|
|
COPY package.json package-lock.json ./
|
|
RUN npm ci
|
|
|
|
# Build the Node-server bundle. DATABASE_URL is intentionally unset here, so the
|
|
# build-time migrate step (npm run build -> db:migrate) safely no-ops; real
|
|
# migrations run at container start against the configured DATABASE_URL.
|
|
# VITE_* values are inlined into the client bundle at build time, so the auth
|
|
# toggle must be known here (pass `--build-arg VITE_AUTH_ENABLED=true`).
|
|
ARG VITE_AUTH_ENABLED=false
|
|
ENV VITE_AUTH_ENABLED=${VITE_AUTH_ENABLED}
|
|
COPY . .
|
|
RUN NITRO_PRESET=node-server npm run build
|
|
|
|
# ---- runtime stage ----------------------------------------------------------
|
|
FROM node:22-slim AS runtime
|
|
WORKDIR /app
|
|
ENV NODE_ENV=production \
|
|
PORT=3000 \
|
|
HOST=0.0.0.0
|
|
|
|
# Bring in production node_modules only. onnxruntime-node (optional, for the
|
|
# embedding engine) ships binaries for every OS; keep only Linux. It is an
|
|
# optionalDependency, so `npm ci --omit=dev` alone does NOT drop it when
|
|
# OPENJEV_EMBED=0 (2026-11-10 finding: every build, embed on or off, was
|
|
# installing the ~69MB Linux-pruned onnxruntime-node binary for an engine
|
|
# that, without the model weights below, can never actually load). Pass
|
|
# `--omit=optional` too when the embed build arg is off.
|
|
ARG OPENJEV_EMBED=1
|
|
COPY package.json package-lock.json ./
|
|
RUN if [ "$OPENJEV_EMBED" = "1" ]; then \
|
|
npm ci --omit=dev; \
|
|
else \
|
|
npm ci --omit=dev --omit=optional; \
|
|
fi \
|
|
&& npm cache clean --force \
|
|
&& find node_modules/onnxruntime-node/bin -mindepth 2 -maxdepth 2 ! -name linux -exec rm -rf {} + 2>/dev/null || true
|
|
|
|
# Default System One engine: sentence embeddings (gte-small, int8 ONNX, ~33 MB,
|
|
# MIT). Fetched pinned + sha256-verified; build with
|
|
# `--build-arg OPENJEV_EMBED=0` to ship only the lexical engine.
|
|
COPY scripts/embed-download.sh ./scripts/embed-download.sh
|
|
RUN if [ "$OPENJEV_EMBED" = "1" ]; then \
|
|
apt-get update && apt-get install -y --no-install-recommends curl ca-certificates \
|
|
&& bash scripts/embed-download.sh \
|
|
&& apt-get purge -y curl && apt-get autoremove -y && rm -rf /var/lib/apt/lists/*; \
|
|
fi
|
|
|
|
# Built server output + the bits the CLI and migrator need at runtime.
|
|
COPY --from=build /app/.output ./.output
|
|
COPY scripts ./scripts
|
|
COPY migrations ./migrations
|
|
|
|
# Register the `openjev` bin on PATH.
|
|
RUN npm link 2>/dev/null || true
|
|
|
|
EXPOSE 3000
|
|
# Migrate (no-op without DATABASE_URL) then serve.
|
|
CMD ["sh", "-c", "node scripts/migrate.mjs; node scripts/cli.mjs serve"]
|