printhive/Dockerfile
dlawler489 2796fab38c Docker: fail the build if the search model can't be fetched
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-15 12:54:03 +10:00

38 lines
1.4 KiB
Docker

# Printhive — Node app + Python/trimesh sidecar (for 3MF -> GLB conversion)
FROM node:22-bookworm-slim
# Python is needed at runtime for the 3MF->GLB / volume sidecar.
RUN apt-get update \
&& apt-get install -y --no-install-recommends python3 python3-venv \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Tell the converter where Python lives (the venv built below).
ENV PYTHON_BIN=/app/tools/venv/bin/python
# Python sidecar deps (cached unless requirements.txt changes).
COPY tools/requirements.txt ./tools/requirements.txt
RUN python3 -m venv /app/tools/venv \
&& /app/tools/venv/bin/pip install --no-cache-dir -r tools/requirements.txt
# Node deps (cached unless package files change).
COPY package.json package-lock.json ./
RUN npm ci --omit=dev \
# semantic search only needs onnxruntime's Linux binaries (saves ~130 MB)
&& rm -rf node_modules/onnxruntime-node/bin/napi-v3/darwin node_modules/onnxruntime-node/bin/napi-v3/win32
# App source.
COPY . .
# The embedding model for semantic search (~34 MB), fetched at build time so the
# server never has to download it.
ENV MODELS_DIR=/app/models
# (No process.exit: forcing an exit while onnxruntime's threads are up aborts node.)
RUN node -e "require('./lib/embeddingModel').embed(['test']).then(() => console.log('embedding model ready'), (err) => { console.error(err); process.exitCode = 1; })"
ENV NODE_ENV=production \
PORT=3000
EXPOSE 3000
CMD ["node", "server.js"]