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>
2 unmodified lines3456789101112131415161718192021222324252627287 unmodified lines36373839404142434445464748495051525354555657582 unmodified lines# Set noninteractive installationENV DEBIAN_FRONTEND=noninteractive# Build timestamp to force cache invalidation: 2026-01-12T22:15# Install build dependenciesRUN apt-get update && apt-get install -y \curl \git \&& rm -rf /var/lib/apt/lists/*# Create app directoryWORKDIR /app# Copy package files first for better cachingCOPY trigo-web/package*.json ./COPY trigo-web/app/package*.json ./app/COPY trigo-web/backend/package*.json ./backend/# Copy .env filesCOPY trigo-web/.env* ./COPY trigo-web/app/.env* ./app/COPY trigo-web/backend/.env* ./backend/# Install build tools globallyRUN npm install -g tsx jison typescript esbuild7 unmodified lines# Install backend dependenciesRUN cd backend && npm install# Copy pre-built frontend dist folder (includes ONNX models and WASM files via LFS)COPY trigo-web/app/dist/ ./app/dist/# Copy public folderCOPY trigo-web/public/ ./public/# Copy inc folder (shared types)COPY trigo-web/inc/ ./inc/# Copy backend source and build with esbuildCOPY trigo-web/backend/src/ ./backend/src/COPY trigo-web/backend/tsconfig.json ./backend/RUN mkdir -p backend/dist/backend/src && \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# Copy the pre-built parserCOPY trigo-web/public/lib/tgnParser.cjs ./public/lib/# Set environment variables for Hugging Face SpacesENV PORT=78602 unmodified lines34567891011121314151617181920212223242526272829303132333435363738397 unmodified lines4748495051525354555657585960616263646566676869707172732 unmodified lines# Set noninteractive installationENV DEBIAN_FRONTEND=noninteractive# Build timestamp to force cache invalidation: 2026-01-12T22:25# Install build dependencies including git-lfsRUN apt-get update && apt-get install -y \curl \git \git-lfs \&& rm -rf /var/lib/apt/lists/*# Initialize git-lfsRUN git lfs install# Create app directoryWORKDIR /app# Clone the repo with LFS filesARG REPO_URL=https://huggingface.co/spaces/k-l-lambda/trigoRUN git clone --depth 1 ${REPO_URL} /tmp/repo && \cd /tmp/repo && \git lfs pull# Copy files from cloned repoRUN mkdir -p app backend && \cp -r /tmp/repo/trigo-web/package*.json ./ && \cp -r /tmp/repo/trigo-web/app/package*.json ./app/ && \cp -r /tmp/repo/trigo-web/backend/package*.json ./backend/# Copy .env filesRUN cp /tmp/repo/trigo-web/.env* ./ 2>/dev/null || true && \cp /tmp/repo/trigo-web/app/.env* ./app/ 2>/dev/null || true && \cp /tmp/repo/trigo-web/backend/.env* ./backend/ 2>/dev/null || true# Install build tools globallyRUN npm install -g tsx jison typescript esbuild7 unmodified lines# Install backend dependenciesRUN cd backend && npm install# Copy pre-built frontend dist folder (with LFS files properly resolved)RUN cp -r /tmp/repo/trigo-web/app/dist/ ./app/dist/# Copy public folderRUN cp -r /tmp/repo/trigo-web/public/ ./public/# Copy inc folder (shared types)RUN cp -r /tmp/repo/trigo-web/inc/ ./inc/# Copy backend source and build with esbuildRUN cp -r /tmp/repo/trigo-web/backend/src/ ./backend/src/ && \cp /tmp/repo/trigo-web/backend/tsconfig.json ./backend/RUN mkdir -p backend/dist/backend/src && \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# Copy the pre-built parserRUN cp /tmp/repo/trigo-web/public/lib/tgnParser.cjs ./public/lib/# CleanupRUN rm -rf /tmp/repo# Set environment variables for Hugging Face SpacesENV PORT=7860
Dockerfile+31-16