1- # Use a multi-stage build to reduce the final image size.
2-
3- # --- Builder Stage: Install Dependencies and Package the Application ---
1+ # Multi-stage build — keeps final image lean
2+ # Stage 1: Builder — installs all deps into a venv
43FROM python:3.11-slim-bookworm AS builder
54
6- # Set the working directory
75WORKDIR /app
86
9- # Copy the pyproject.toml and poetry.lock files
7+ # Install uv (fast Python package manager)
8+ RUN pip install --no-cache-dir uv
9+
10+ # Copy only the dependency manifest first (cache-friendly layer)
1011COPY pyproject.toml .
11- COPY uv.lock .
1212
13- # Install uv and use it to install project dependencies
14- RUN pip install uv
15- RUN uv pip install --no-cache-dir --no-index --find-links=. .
13+ # Install project deps into a proper venv using uv
14+ RUN uv venv /app/.venv && \
15+ . /app/.venv/bin/activate && \
16+ uv pip install --no-cache-dir -e .
1617
17- # Copy the application code
18+ # Copy source code
1819COPY devguardian /app/devguardian
1920COPY README.md .
2021
21- # --- Final Stage: Create the Production Image ---
22+ # ──────────────────────────────────────────────
23+ # Stage 2: Runtime — lean final image
2224FROM python:3.11-slim-bookworm
2325
24- # Set the working directory
2526WORKDIR /app
2627
27- # Copy the dependencies from the builder stage
28- COPY --from=builder /app/.venv . /.venv
28+ # Copy the venv and application from builder
29+ COPY --from=builder /app/.venv /app /.venv
2930COPY --from=builder /app/devguardian /app/devguardian
30- COPY --from=builder /app/README.md /app/README.md
31+ COPY --from=builder /app/pyproject.toml /app/pyproject.toml
3132
32- # Make . venv executable
33+ # Put venv on PATH so `devguardian` command is found
3334ENV PATH="/app/.venv/bin:${PATH}"
34-
35- # Set environment variables (optional, but good practice)
3635ENV PYTHONUNBUFFERED=1
3736
38- # Expose the port (if necessary - determine from server.py)
37+ # DevGuardian reads from stdio (MCP protocol) — no port needed
38+ # EXPOSE 8000 is kept for reference if HTTP mode is added later
3939EXPOSE 8000
4040
41- # Command to run the application
41+ # Run the MCP server
4242CMD ["devguardian" ]
0 commit comments