FROM node:20-slim # ── System deps ────────────────────────────────────────────────────────────── RUN apt-get update && apt-get install -y --no-install-recommends \ make g++ python3 curl wget ca-certificates \ && rm -rf /var/lib/apt/lists/* # ── CPU Performance ────────────────────────────────────────────────────────── ENV NODE_OPTIONS="--max-old-space-size=6144" ENV UV_THREADPOOL_SIZE=16 WORKDIR /app # ── Install deps ───────────────────────────────────────────────────────────── COPY package.json ./ RUN npm install --production 2>&1 | tail -5 || \ npm install --legacy-peer-deps 2>&1 | tail -5 || true # ── Copy app ───────────────────────────────────────────────────────────────── COPY . . # ── Model cache dir ────────────────────────────────────────────────────────── RUN mkdir -p /app/models /tmp/worker-cache ENV PORT=7860 ENV NODE_ENV=production ENV MODEL_DIR=/app/models EXPOSE 7860 HEALTHCHECK --interval=30s --timeout=10s --start-period=180s --retries=5 \ CMD curl -f http://localhost:7860/health || exit 1 CMD ["node", "server.js"]