# 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

# App source.
COPY . .

ENV NODE_ENV=production \
    PORT=3000
EXPOSE 3000

CMD ["node", "server.js"]
