-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
68 lines (49 loc) · 1.76 KB
/
Copy pathDockerfile
File metadata and controls
68 lines (49 loc) · 1.76 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Multi-stage Docker build for SecureCodeGraph MCP server
# Builder stage: Install dependencies
# Runtime stage: Minimal production image with non-root user
FROM python:3.11-slim as builder
WORKDIR /build
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
git \
&& rm -rf /var/lib/apt/lists/*
# Copy project files
COPY . .
# Create virtual environment
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Upgrade pip and install dependencies
RUN pip install --upgrade pip setuptools wheel && \
pip install -e .
# Runtime stage: Minimal production image
FROM python:3.11-slim
WORKDIR /app
# Install only runtime dependencies (no build tools)
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
&& rm -rf /var/lib/apt/lists/*
# Copy virtual environment from builder
COPY --from=builder /opt/venv /opt/venv
# Create non-root user for security
RUN groupadd -r scg && useradd -r -g scg scg
# Set environment variables
ENV PATH="/opt/venv/bin:$PATH" \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
SCG_DB_PATH=/home/scg/.secure-code-graph/graph.db
# Create data directory with proper permissions
RUN mkdir -p /home/scg/.secure-code-graph && \
chown -R scg:scg /home/scg
# Switch to non-root user
USER scg
# Copy project (will be at /app after builder copy)
COPY --chown=scg:scg --from=builder /build /app
# Expose port for HTTP transport
EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import requests; requests.get('http://127.0.0.1:8000/health', timeout=5)" || exit 1
# Default command: start MCP server in stdio mode
ENTRYPOINT ["python", "-m", "secure_code_graph"]
CMD ["server"]