Spaces:
Sleeping
Sleeping
Commit
·
850daa9
1
Parent(s):
11f07f6
Use git clone with LFS pull to properly resolve LFS files
Browse filesDocker COPY doesn't resolve LFS files, only copies pointer files.
This approach clones the repo inside Docker and runs git lfs pull
to get the actual ONNX models and WASM files.
Co-Authored-By: Claude <noreply@anthropic.com>
- Dockerfile +31 -16
Dockerfile
CHANGED
|
@@ -3,26 +3,37 @@ FROM node:20-slim
|
|
| 3 |
# Set noninteractive installation
|
| 4 |
ENV DEBIAN_FRONTEND=noninteractive
|
| 5 |
|
| 6 |
-
# Build timestamp to force cache invalidation: 2026-01-12T22:
|
| 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 |
-
#
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
# Copy .env files
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
|
| 27 |
# Install build tools globally
|
| 28 |
RUN npm install -g tsx jison typescript esbuild
|
|
@@ -36,23 +47,27 @@ RUN cd app && npm install --omit=dev
|
|
| 36 |
# Install backend dependencies
|
| 37 |
RUN cd backend && npm install
|
| 38 |
|
| 39 |
-
# Copy pre-built frontend dist folder (
|
| 40 |
-
|
| 41 |
|
| 42 |
# Copy public folder
|
| 43 |
-
|
| 44 |
|
| 45 |
# Copy inc folder (shared types)
|
| 46 |
-
|
| 47 |
|
| 48 |
# Copy backend source and build with esbuild
|
| 49 |
-
|
| 50 |
-
|
|
|
|
| 51 |
RUN mkdir -p backend/dist/backend/src && \
|
| 52 |
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
|
| 53 |
|
| 54 |
# Copy the pre-built parser
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
# Set environment variables for Hugging Face Spaces
|
| 58 |
ENV PORT=7860
|
|
|
|
| 3 |
# Set noninteractive installation
|
| 4 |
ENV DEBIAN_FRONTEND=noninteractive
|
| 5 |
|
| 6 |
+
# Build timestamp to force cache invalidation: 2026-01-12T22:25
|
| 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 with LFS files
|
| 22 |
+
ARG REPO_URL=https://huggingface.co/spaces/k-l-lambda/trigo
|
| 23 |
+
RUN git clone --depth 1 ${REPO_URL} /tmp/repo && \
|
| 24 |
+
cd /tmp/repo && \
|
| 25 |
+
git lfs pull
|
| 26 |
+
|
| 27 |
+
# Copy files from cloned repo
|
| 28 |
+
RUN mkdir -p app backend && \
|
| 29 |
+
cp -r /tmp/repo/trigo-web/package*.json ./ && \
|
| 30 |
+
cp -r /tmp/repo/trigo-web/app/package*.json ./app/ && \
|
| 31 |
+
cp -r /tmp/repo/trigo-web/backend/package*.json ./backend/
|
| 32 |
|
| 33 |
# Copy .env files
|
| 34 |
+
RUN cp /tmp/repo/trigo-web/.env* ./ 2>/dev/null || true && \
|
| 35 |
+
cp /tmp/repo/trigo-web/app/.env* ./app/ 2>/dev/null || true && \
|
| 36 |
+
cp /tmp/repo/trigo-web/backend/.env* ./backend/ 2>/dev/null || true
|
| 37 |
|
| 38 |
# Install build tools globally
|
| 39 |
RUN npm install -g tsx jison typescript esbuild
|
|
|
|
| 47 |
# Install backend dependencies
|
| 48 |
RUN cd backend && npm install
|
| 49 |
|
| 50 |
+
# Copy pre-built frontend dist folder (with LFS files properly resolved)
|
| 51 |
+
RUN cp -r /tmp/repo/trigo-web/app/dist/ ./app/dist/
|
| 52 |
|
| 53 |
# Copy public folder
|
| 54 |
+
RUN cp -r /tmp/repo/trigo-web/public/ ./public/
|
| 55 |
|
| 56 |
# Copy inc folder (shared types)
|
| 57 |
+
RUN cp -r /tmp/repo/trigo-web/inc/ ./inc/
|
| 58 |
|
| 59 |
# Copy backend source and build with esbuild
|
| 60 |
+
RUN cp -r /tmp/repo/trigo-web/backend/src/ ./backend/src/ && \
|
| 61 |
+
cp /tmp/repo/trigo-web/backend/tsconfig.json ./backend/
|
| 62 |
+
|
| 63 |
RUN mkdir -p backend/dist/backend/src && \
|
| 64 |
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
|
| 65 |
|
| 66 |
# Copy the pre-built parser
|
| 67 |
+
RUN cp /tmp/repo/trigo-web/public/lib/tgnParser.cjs ./public/lib/
|
| 68 |
+
|
| 69 |
+
# Cleanup
|
| 70 |
+
RUN rm -rf /tmp/repo
|
| 71 |
|
| 72 |
# Set environment variables for Hugging Face Spaces
|
| 73 |
ENV PORT=7860
|