Spaces:
Running
Running
| FROM node:20-slim | |
| # Set noninteractive installation | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| # Build timestamp to force cache invalidation: 2026-01-12T19:50 | |
| # Install build dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| curl \ | |
| git \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Create app directory | |
| WORKDIR /app | |
| # Copy trigo-web project (includes pre-built app/dist) | |
| COPY trigo-web/ ./ | |
| # Remove large ONNX files from public (already in dist) | |
| RUN rm -rf public/onnx | |
| # Install build tools globally | |
| RUN npm install -g tsx jison typescript esbuild | |
| # Install dependencies | |
| # Root: production only (skip onnxruntime-node which requires native compilation) | |
| # App & Backend: all deps needed for runtime | |
| RUN npm install --omit=dev && \ | |
| cd app && npm install --omit=dev && \ | |
| cd ../backend && npm install && \ | |
| cd .. | |
| # Skip jison parser build - pre-built tgnParser.cjs is already in public/lib/ | |
| # Skip vite build - pre-built dist is already included | |
| # Build backend with esbuild (handles ESM imports without .js extensions) | |
| RUN esbuild backend/src/server.ts --bundle --platform=node --target=node20 --format=esm --outfile=backend/dist/server.js --external:express --external:socket.io --external:cors --external:dotenv --external:uuid | |
| # Copy ONNX files to dist (they don't need to be in public anymore) | |
| COPY trigo-web/public/onnx/ ./app/dist/onnx/ | |
| # Set environment variables for Hugging Face Spaces | |
| ENV PORT=7860 | |
| ENV HOST=0.0.0.0 | |
| ENV NODE_ENV=production | |
| # Expose port 7860 (required by Hugging Face Spaces) | |
| EXPOSE 7860 | |
| # Start backend server (which will also serve frontend static files) | |
| CMD ["npm", "run", "start:prod"] | |