File size: 1,638 Bytes
466436b
 
 
 
 
be5c8a6
65d4295
466436b
 
 
 
 
 
 
 
 
be5c8a6
466436b
be5c8a6
 
2fb00d9
466436b
31ac8d2
00765bc
31ac8d2
 
 
be5c8a6
31ac8d2
be5c8a6
466436b
 
 
077b914
be5c8a6
466436b
00765bc
 
466436b
be5c8a6
2fb00d9
 
466436b
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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"]