|
| 1 | +# Stage 1: Build the TypeScript worker |
| 2 | +FROM node:22-slim AS builder |
| 3 | + |
| 4 | +RUN corepack enable && corepack prepare pnpm@9.15.0 --activate |
| 5 | + |
| 6 | +WORKDIR /app |
| 7 | + |
| 8 | +# Copy workspace config |
| 9 | +COPY package.json pnpm-workspace.yaml pnpm-lock.yaml* turbo.json tsconfig.base.json ./ |
| 10 | + |
| 11 | +# Copy package manifests for dependency resolution |
| 12 | +COPY packages/shared/package.json packages/shared/ |
| 13 | +COPY apps/worker/package.json apps/worker/ |
| 14 | + |
| 15 | +# Install dependencies |
| 16 | +RUN pnpm install --frozen-lockfile || pnpm install |
| 17 | + |
| 18 | +# Copy source |
| 19 | +COPY packages/shared/ packages/shared/ |
| 20 | +COPY apps/worker/ apps/worker/ |
| 21 | + |
| 22 | +# Build shared package first, then worker |
| 23 | +RUN pnpm --filter @wright/shared build && pnpm --filter @wright/worker build |
| 24 | + |
| 25 | +# Stage 2: Runtime with Node.js + Python (for running target repo tests) |
| 26 | +FROM node:22-slim AS runtime |
| 27 | + |
| 28 | +RUN corepack enable && corepack prepare pnpm@9.15.0 --activate |
| 29 | + |
| 30 | +# Install Python 3.12 and uv for running target repo tests (pytest, etc.) |
| 31 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 32 | + python3 \ |
| 33 | + python3-pip \ |
| 34 | + python3-venv \ |
| 35 | + git \ |
| 36 | + curl \ |
| 37 | + ca-certificates \ |
| 38 | + && rm -rf /var/lib/apt/lists/* |
| 39 | + |
| 40 | +# Install uv (fast Python package manager) |
| 41 | +RUN curl -LsSf https://astral.sh/uv/install.sh | sh |
| 42 | +ENV PATH="/root/.local/bin:$PATH" |
| 43 | + |
| 44 | +# Install additional language runtimes/tools as needed |
| 45 | +# Go, Rust, etc. can be added here for broader test runner support |
| 46 | + |
| 47 | +WORKDIR /app |
| 48 | + |
| 49 | +# Copy workspace config |
| 50 | +COPY package.json pnpm-workspace.yaml pnpm-lock.yaml* ./ |
| 51 | + |
| 52 | +# Copy built artifacts and production dependencies |
| 53 | +COPY --from=builder /app/packages/shared/package.json packages/shared/ |
| 54 | +COPY --from=builder /app/packages/shared/dist/ packages/shared/dist/ |
| 55 | +COPY --from=builder /app/apps/worker/package.json apps/worker/ |
| 56 | +COPY --from=builder /app/apps/worker/dist/ apps/worker/dist/ |
| 57 | + |
| 58 | +# Install production dependencies only |
| 59 | +RUN pnpm install --prod --frozen-lockfile || pnpm install --prod |
| 60 | + |
| 61 | +# Working directory for cloned repos |
| 62 | +RUN mkdir -p /workspace |
| 63 | +ENV WORKSPACE_DIR="/workspace" |
| 64 | + |
| 65 | +WORKDIR /app/apps/worker |
| 66 | + |
| 67 | +CMD ["node", "dist/index.js"] |
0 commit comments