PRIX / Dockerfile
Rachit-Tw's picture
feat: implement autonomous Auto-PR and optimize Docker image
5cb7295
Raw
History Blame Contribute Delete
2.3 kB
# Stage 1: Base System Dependencies (Shared)
FROM node:20-slim AS deps
# Install runtime and build dependencies once
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/*
# Stage 2: Parser Downloader (Separated to optimize cache)
FROM deps AS parsers
WORKDIR /app/parsers
RUN BASE_URL="https://unpkg.com/tree-sitter-wasms@latest/out" && \
for lang in javascript typescript python go cpp rust java c tsx; do \
curl -fsSL "$BASE_URL/tree-sitter-$lang.wasm" -o "tree-sitter-$lang.wasm" || \
echo "WARNING: Failed to download tree-sitter-$lang.wasm"; \
done
# Stage 3: Build & Compile (Builder)
FROM deps AS builder
WORKDIR /app
# Copy dependency manifests first for better caching
COPY package*.json ./
# Install all dependencies including devDeps for build
RUN npm ci --ignore-scripts && npm cache clean --force
# Copy project source
COPY . .
# Compile TypeScript and then prune devDependencies
RUN npm run build && \
npm prune --production && \
npm cache clean --force
# Stage 4: Production Runtime (Final)
FROM deps AS runtime
WORKDIR /app
# Copy artifacts from previous stages
COPY --from=parsers /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.md hf-start.js ./
# Standard Environment Variables
ENV PORT=7860 \
HOST=0.0.0.0 \
PARSER_DIR=/app/parsers \
NODE_ENV=production
# 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"]