FROM node:22-bookworm-slim AS boosapi-builder WORKDIR /app RUN echo 'Acquire::http::Proxy "false";' > /etc/apt/apt.conf.d/99no-proxy && apt-get update && apt-get install -y --no-install-recommends python3 make g++ && rm -rf /var/lib/apt/lists/* ENV PYTHON=/usr/bin/python3 COPY package.json package-lock.json ./ RUN npm ci --ignore-scripts --no-audit --no-fund RUN npm rebuild esbuild sharp better-sqlite3 --no-audit --no-fund COPY . . RUN npm run build:web RUN npx tsc -p tsconfig.json --outDir dist --rootDir src --skipLibCheck --noEmit false 2>/dev/null; true RUN ls dist/server/index.js 2>/dev/null || (echo "=== Server build still missing, trying project reference build ===" && npx tsc -p tsconfig.server.json --skipLibCheck --noEmit false 2>/dev/null; true) RUN npm prune --omit=dev --no-audit --no-fund # ---- Final image ---- FROM ubuntu:24.04 ARG HTTP_PROXY ARG HTTPS_PROXY ARG ALL_PROXY ARG NO_PROXY ENV DEBIAN_FRONTEND=noninteractive ENV NODE_ENV=production ENV COMFYUI_BASE=http://127.0.0.1:8188 ENV HTTP_PROXY=${HTTP_PROXY} ENV HTTPS_PROXY=${HTTPS_PROXY} ENV ALL_PROXY=${ALL_PROXY} ENV NO_PROXY=${NO_PROXY} # Install system deps: Node.js 22, Python 3, supervisor RUN echo 'Acquire::http::Proxy "false";' > /etc/apt/apt.conf.d/99no-proxy && apt-get update && apt-get install -y --no-install-recommends \ curl ca-certificates gnupg \ python3 python3-pip python3-venv \ supervisor git \ && curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \ && apt-get install -y --no-install-recommends nodejs \ && rm -rf /var/lib/apt/lists/* # Install RTK from pre-built binary COPY rtk /usr/local/bin/rtk RUN chmod +x /usr/local/bin/rtk # Set up ComfyUI (workflow editor frontend, calls BoosAPI API via custom nodes) # CPU PyTorch is fine — all generation goes through BoosAPI's API WORKDIR /app/comfy RUN git clone https://github.com/comfyanonymous/ComfyUI.git . \ && python3 -m venv venv \ && . venv/bin/activate \ && pip install --upgrade pip \ && pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu \ && grep -v kornia_rs requirements.txt | pip install -r /dev/stdin \ && rm -rf ~/.cache/pip ENV PATH="/app/comfy/venv/bin:${PATH}" # Copy boosapi (built) WORKDIR /app/boosapi COPY --from=boosapi-builder /app/dist ./dist COPY --from=boosapi-builder /app/node_modules ./node_modules COPY --from=boosapi-builder /app/package.json ./ COPY --from=boosapi-builder /app/drizzle ./drizzle RUN mkdir -p data # Copy BoosAPI custom nodes for ComfyUI (call local BoosAPI API) COPY --from=boosapi-builder /app/boosapi_comfy_nodes.py /app/comfy/custom_nodes/boosapi_comfy_nodes.py # Supervisor config RUN mkdir -p /var/log/supervisor COPY <<'SUPERVISOR' /etc/supervisor/conf.d/all.conf [supervisord] nodaemon=true user=root logfile=/var/log/supervisor/supervisord.log pidfile=/tmp/supervisord.pid [program:boosapi] command=sh -c "node dist/server/db/migrate.js && node dist/server/index.js" directory=/app/boosapi autorestart=true stdout_logfile=/var/log/supervisor/boosapi.log stderr_logfile=/var/log/supervisor/boosapi.err [program:comfyui] command=python3 main.py --listen 0.0.0.0 --port 8188 --cpu directory=/app/comfy autorestart=true startretries=3 stdout_logfile=/var/log/supervisor/comfyui.log stderr_logfile=/var/log/supervisor/comfyui.err SUPERVISOR EXPOSE 4000 8188 CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/all.conf"]