k-l-lambda Claude commited on
Commit
90ad400
·
1 Parent(s): 4f0cc53

Revert to building in Docker instead of using pre-built files

Browse files

This avoids LFS issues by only copying source files.
ONNX files will need to be handled separately.

Co-Authored-By: Claude <noreply@anthropic.com>

Files changed (1) hide show
  1. Dockerfile +32 -34
Dockerfile CHANGED
@@ -3,55 +3,53 @@ FROM node:20-slim
3
  # Set noninteractive installation
4
  ENV DEBIAN_FRONTEND=noninteractive
5
 
6
- # Build timestamp to force cache invalidation: 2026-01-12T21:20
7
 
8
- # Install build dependencies including git-lfs
9
  RUN apt-get update && apt-get install -y \
10
  curl \
11
  git \
12
- git-lfs \
13
  && rm -rf /var/lib/apt/lists/*
14
 
15
- # Initialize git lfs
16
- RUN git lfs install
17
-
18
  # Create app directory
19
  WORKDIR /app
20
 
21
- # Clone the repo directly into temp, pull LFS, then move files
22
- RUN git clone https://huggingface.co/spaces/k-l-lambda/trigo /tmp/repo && \
23
- cd /tmp/repo && \
24
- git lfs pull && \
25
- echo "=== Contents of repo ===" && \
26
- ls -la && \
27
- echo "=== Contents of trigo-web ===" && \
28
- ls -la trigo-web/ && \
29
- echo "=== Contents of trigo-web/app ===" && \
30
- ls -la trigo-web/app/ && \
31
- echo "=== Contents of trigo-web/app/dist ===" && \
32
- ls -la trigo-web/app/dist/ && \
33
- mv trigo-web/* /app/ && \
34
- rm -rf /tmp/repo
35
-
36
- # Install build tools globally (still needed for some scripts)
37
- RUN npm install -g tsx jison typescript
 
 
 
38
 
39
  # Install dependencies
40
- # Root: production only (skip onnxruntime-node which requires native compilation)
41
- # App & Backend: runtime deps only
42
  RUN npm install --omit=dev && \
43
- cd app && npm install --omit=dev && \
44
- cd ../backend && npm install --omit=dev && \
45
  cd ..
46
 
47
- # All build steps are pre-built:
48
- # - Frontend: app/dist/ (includes onnx files)
49
- # - Backend: backend/dist/backend/src/server.js
50
- # - Parser: public/lib/tgnParser.cjs
 
 
51
 
52
- # Verify dist files exist (will fail if LFS files weren't pulled)
53
- RUN test -f app/dist/index.html || (echo "ERROR: app/dist/index.html not found" && exit 1)
54
- RUN test -f backend/dist/backend/src/server.js || (echo "ERROR: backend/dist/backend/src/server.js not found" && exit 1)
55
 
56
  # Set environment variables for Hugging Face Spaces
57
  ENV PORT=7860
 
3
  # Set noninteractive installation
4
  ENV DEBIAN_FRONTEND=noninteractive
5
 
6
+ # Build timestamp to force cache invalidation: 2026-01-12T21:35
7
 
8
+ # Install build dependencies
9
  RUN apt-get update && apt-get install -y \
10
  curl \
11
  git \
 
12
  && rm -rf /var/lib/apt/lists/*
13
 
 
 
 
14
  # Create app directory
15
  WORKDIR /app
16
 
17
+ # Copy only the source files (not pre-built dist)
18
+ COPY trigo-web/package*.json ./
19
+ COPY trigo-web/app/package*.json ./app/
20
+ COPY trigo-web/backend/package*.json ./backend/
21
+ COPY trigo-web/inc/ ./inc/
22
+ COPY trigo-web/public/ ./public/
23
+ COPY trigo-web/app/src/ ./app/src/
24
+ COPY trigo-web/app/index.html ./app/
25
+ COPY trigo-web/app/vite.config.ts ./app/
26
+ COPY trigo-web/app/tsconfig*.json ./app/
27
+ COPY trigo-web/backend/src/ ./backend/src/
28
+ COPY trigo-web/backend/tsconfig.json ./backend/
29
+
30
+ # Copy .env files
31
+ COPY trigo-web/.env* ./
32
+ COPY trigo-web/app/.env* ./app/
33
+ COPY trigo-web/backend/.env* ./backend/
34
+
35
+ # Install build tools globally
36
+ RUN npm install -g tsx jison typescript esbuild
37
 
38
  # Install dependencies
 
 
39
  RUN npm install --omit=dev && \
40
+ cd app && npm install && \
41
+ cd ../backend && npm install && \
42
  cd ..
43
 
44
+ # Build frontend with vite
45
+ RUN cd app && npm run build:prod
46
+
47
+ # Build backend with esbuild
48
+ RUN mkdir -p backend/dist/backend/src && \
49
+ esbuild backend/src/server.ts --bundle --platform=node --target=node20 --format=esm --outfile=backend/dist/backend/src/server.js --external:express --external:socket.io --external:cors --external:dotenv --external:uuid
50
 
51
+ # Copy the pre-built parser
52
+ COPY trigo-web/public/lib/tgnParser.cjs ./public/lib/
 
53
 
54
  # Set environment variables for Hugging Face Spaces
55
  ENV PORT=7860