-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
42 lines (30 loc) · 1.18 KB
/
Copy pathDockerfile
File metadata and controls
42 lines (30 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
FROM python:3.13-slim AS builder
WORKDIR /app
# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
# Enable bytecode compilation and copy mode for mounted caches
ENV UV_COMPILE_BYTECODE=1 \
UV_LINK_MODE=copy
# Install dependencies first (layer caching)
COPY pyproject.toml uv.lock ./
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-install-project --no-dev --no-editable
# Install the project itself
COPY . .
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev --no-editable
# --- Runtime stage ---
FROM python:3.13-slim
# Install nmap and libcap for raw sockets
RUN apt-get update && \
apt-get install -y --no-install-recommends nmap procps libcap2-bin && \
rm -rf /var/lib/apt/lists/*
# Copy the virtual environment from the builder
COPY --from=builder /app/.venv /app/.venv
ENV PATH="/app/.venv/bin:$PATH" \
PYTHONUNBUFFERED=1
# Run as root - nmap needs root for SYN scans, UDP scans, OS detection, etc.
# Container isolation provides the security boundary.
HEALTHCHECK --interval=60s --timeout=10s --start-period=10s --retries=3 \
CMD pgrep -f "nmap-mcp" > /dev/null || exit 1
ENTRYPOINT ["nmap-mcp"]