Spaces:
Sleeping
Sleeping
Commit ·
c4a0a71
1
Parent(s): 8c8e029
fix(docker): download LFS files at startup instead of COPY
Browse filesDocker COPY doesn't resolve Git LFS pointers. Instead, use a startup
script to download ONNX files from HuggingFace at container start.
This ensures ONNX model files are properly available for VS AI mode.
Co-Authored-By: Claude <noreply@anthropic.com>
1 unmodified line23456789101112131415161718192021222324252627282914 unmodified lines444546474849505152531 unmodified lineENV DEBIAN_FRONTEND=noninteractive# Build timestamp: 2026-01-17T16:30WORKDIR /app# Install git and git-lfs for handling large filesRUN apt-get update && apt-get install -y git git-lfs ca-certificates && git lfs install && rm -rf /var/lib/apt/lists/*# Clone the repository with LFS files - this properly resolves LFS pointersARG REPO_URL=https://huggingface.co/spaces/k-l-lambda/trigoRUN git clone --depth 1 ${REPO_URL} /tmp/repo && \cd /tmp/repo && \git lfs pull && \cp -r trigo-web/backend/src/ /app/backend/src/ && \cp -r trigo-web/inc/ /app/inc/ && \cp -r trigo-web/app/dist/ /app/app/dist/ && \cp trigo-web/backend/package.json /app/package.json && \cp trigo-web/backend/.env /app/backend/.env && \rm -rf /tmp/repo# Install ALL deps (including dev for tsx)RUN npm install# Create a Docker-specific entry point that sets correct pathsRUN echo 'import express from "express"; \import { createServer } from "http"; \14 unmodified linesio.on("connection", (socket) => { console.log("Client connected:", socket.id); setupSocketHandlers(io, socket, gameManager); socket.on("disconnect", () => console.log("Client disconnected:", socket.id)); }); \httpServer.listen(PORT, "0.0.0.0", () => console.log("Server running on port " + PORT));' > docker-entry.tsENV PORT=7860ENV HOST=0.0.0.0ENV NODE_ENV=productionEXPOSE 7860CMD ["npx", "tsx", "docker-entry.ts"]1 unmodified line2345678910111213141516171819202122232425262728293014 unmodified lines454647484950515253545556575859606162636465666768697071727374757677787980811 unmodified lineENV DEBIAN_FRONTEND=noninteractive# Build timestamp: 2026-01-17T16:45WORKDIR /app# Install curl for downloading LFS files at startupRUN apt-get update && apt-get install -y curl ca-certificates && rm -rf /var/lib/apt/lists/*# Copy backend package.json and install ALL deps (including dev for tsx)COPY trigo-web/backend/package.json ./package.jsonRUN npm install# Copy backend sourceCOPY trigo-web/backend/src/ ./backend/src/# Copy inc folderCOPY trigo-web/inc/ ./inc/# Copy frontend dist (ONNX files will be LFS pointers, we'll download them at startup)COPY trigo-web/app/dist/ ./app/dist/# Copy env files (only .env, .env.local is for local development only)COPY trigo-web/backend/.env ./backend/.env# Create a Docker-specific entry point that sets correct pathsRUN echo 'import express from "express"; \import { createServer } from "http"; \14 unmodified linesio.on("connection", (socket) => { console.log("Client connected:", socket.id); setupSocketHandlers(io, socket, gameManager); socket.on("disconnect", () => console.log("Client disconnected:", socket.id)); }); \httpServer.listen(PORT, "0.0.0.0", () => console.log("Server running on port " + PORT));' > docker-entry.ts# Create startup script that downloads LFS files before starting serverRUN cat <<'STARTUP' > start.sh#!/bin/bashset -eHF_BASE="https://huggingface.co/spaces/k-l-lambda/trigo/resolve/main/trigo-web/app/dist"# List of ONNX files to download (relative to app/dist)ONNX_FILES=("onnx/20251230-trigo-value-llama-l6-h64-it2_251221-value0.01-pretrain/LlamaCausalLM_ep0036_evaluation.onnx""onnx/20251230-trigo-value-llama-l6-h64-it2_251221-value0.01-pretrain/LlamaCausalLM_ep0036_tree.onnx")echo "Downloading ONNX model files..."for file in "${ONNX_FILES[@]}"; dodir=$(dirname "app/dist/$file")mkdir -p "$dir"echo " Downloading $file..."curl -sL "$HF_BASE/$file" -o "app/dist/$file"doneecho "ONNX files downloaded successfully."# Start the serverexec npx tsx docker-entry.tsSTARTUPRUN chmod +x start.shENV PORT=7860ENV HOST=0.0.0.0ENV NODE_ENV=productionEXPOSE 7860CMD ["./start.sh"]
Dockerfile+46-18