Spaces:
Paused
Paused
| # Hugging Face Spaces Production Dockerfile | |
| # Stage 1: Build & Compile (Builder) | |
| FROM node:20-slim AS builder | |
| # Install build dependencies | |
| # Install build dependencies including GitHub CLI | |
| RUN apt-get update && apt-get install -y git python3 curl && \ | |
| curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \ | |
| && chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \ | |
| && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \ | |
| && apt-get update \ | |
| && apt-get install -y gh \ | |
| && rm -rf /var/lib/apt/lists/* | |
| WORKDIR /app | |
| # Download pre-built tree-sitter WASM parsers from a reliable mirror | |
| RUN mkdir -p parsers && \ | |
| BASE_URL="https://unpkg.com/tree-sitter-wasms@latest/out" && \ | |
| echo "Downloading tree-sitter parsers..." && \ | |
| for lang in javascript typescript python go cpp rust java c tsx; do \ | |
| echo "Downloading tree-sitter-$lang.wasm..." && \ | |
| curl -fsSL "$BASE_URL/tree-sitter-$lang.wasm" -o "parsers/tree-sitter-$lang.wasm" || \ | |
| echo "WARNING: Failed to download tree-sitter-$lang.wasm - some language parsing may be unavailable"; \ | |
| done && \ | |
| ls -la parsers/ && \ | |
| echo "Parser download complete" | |
| # Copy dependency manifests | |
| COPY package*.json ./ | |
| # Install all dependencies | |
| ENV npm_config_loglevel=notice | |
| RUN npm ci --ignore-scripts && npm cache clean --force | |
| # Copy project source | |
| COPY . . | |
| # Compile TypeScript to JavaScript | |
| RUN npm run build | |
| # Remove development dependencies to reduce image size | |
| RUN npm prune --production && npm cache clean --force | |
| # Stage 2: Production Runtime (Final) | |
| FROM node:20-slim | |
| # Install runtime dependencies | |
| # Install runtime dependencies including GitHub CLI | |
| RUN apt-get update && apt-get install -y git python3 curl && \ | |
| curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \ | |
| && chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \ | |
| && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \ | |
| && apt-get update \ | |
| && apt-get install -y gh \ | |
| && rm -rf /var/lib/apt/lists/* | |
| WORKDIR /app | |
| # Copy parsers, node_modules, and lib from the builder stage | |
| COPY --from=builder /app/parsers ./parsers | |
| COPY --from=builder /app/node_modules ./node_modules | |
| COPY --from=builder /app/lib ./lib | |
| COPY --from=builder /app/package*.json ./ | |
| # Copy README for HF Spaces | |
| COPY README.md ./ | |
| # Copy HF Spaces entrypoint script | |
| COPY hf-start.js ./ | |
| # HF Spaces uses PORT env var, defaulting to 7860 | |
| ENV PORT=${PORT:-7860} | |
| ENV HOST=0.0.0.0 | |
| ENV PARSER_DIR=/app/parsers | |
| # Health check for HF Spaces | |
| HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \ | |
| CMD node -e "require('./lib/index.js'); console.log('Health check passed')" || exit 1 | |
| # Start Probot server with HF Spaces entrypoint | |
| CMD ["node", "hf-start.js"] |