-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathDockerfile.mcp
More file actions
84 lines (70 loc) · 2.83 KB
/
Dockerfile.mcp
File metadata and controls
84 lines (70 loc) · 2.83 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
FROM python:3.12-slim
# System dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
git curl ca-certificates gnupg socat \
&& rm -rf /var/lib/apt/lists/*
# Install Node.js 20.x
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y --no-install-recommends nodejs \
&& rm -rf /var/lib/apt/lists/*
# Install MCP server Node dependencies
WORKDIR /opt/mcp-server
COPY mcp-server/package.json ./
RUN npm install --omit=dev && npm cache clean --force
# Copy MCP server code and pytest plugin
COPY mcp-server/server.mjs ./
COPY mcp-server/pytest_capture.py ./
# Install Python dependencies (cached layer - deps rarely change)
COPY dev-requirements.txt /tmp/dev-requirements.txt
# Install all deps from dev-requirements.txt except the editable install line
RUN grep -v '^\-e' /tmp/dev-requirements.txt | pip install --no-cache-dir -r /dev/stdin
# Install ruff (managed by pre-commit, not in dev-requirements.txt)
RUN pip install --no-cache-dir ruff
# Pre-warm pre-commit hook environments so the first run is fast
COPY .pre-commit-config.yaml pyproject.toml /tmp/pre-commit-warmup/
RUN cd /tmp/pre-commit-warmup \
&& git init \
&& git add . \
&& pre-commit install-hooks \
&& rm -rf /tmp/pre-commit-warmup
# Install core install_requires + framework extras directly
# (avoids fragile stub-based setup.py install)
RUN pip install --no-cache-dir \
"Deprecated<1.3.0" \
"PyJWT[crypto]>=2.5.0,<3.0.0" \
"aiosmtplib>=1.1.6,<4.0.0" \
"asgiref>=3.4.1,<4" \
"httpx>=0.15.0,<1.0.0" \
"packaging>=25.0,<26.0" \
"phonenumbers<9" \
"pkce<1.1.0" \
"pycryptodome<3.21.0" \
"pydantic>=2.10.6,<3.0.0" \
"pyotp<3" \
"python-dateutil<3" \
"sniffio>=1.1,<2.0.0" \
"tldextract<6.0.0" \
"twilio<10" \
"typing_extensions>=4.1.1,<5.0.0"
# Create workspace and results directories
RUN mkdir -p /workspace /workspace/test-results /workspace/test-output
# Entrypoint: editable install, port forward for test compat, then start server
COPY <<'ENTRY' /opt/mcp-server/entrypoint.sh
#!/bin/bash
set -e
cd /workspace
pip install --no-deps -e . 2>/dev/null || echo "[mcp] Warning: editable install failed"
# Forward localhost:<core-port> → <core-host>:<core-port> so tests that use
# respx pass_through(host="localhost") keep working inside Docker.
CORE_HOST="${SUPERTOKENS_CORE_HOST:-localhost}"
CORE_PORT="${SUPERTOKENS_CORE_PORT:-3567}"
if [ "$CORE_HOST" != "localhost" ] && [ "$CORE_HOST" != "127.0.0.1" ]; then
echo "[mcp] Forwarding localhost:${CORE_PORT} → ${CORE_HOST}:${CORE_PORT}"
socat TCP-LISTEN:${CORE_PORT},fork,reuseaddr TCP:${CORE_HOST}:${CORE_PORT} &
export SUPERTOKENS_CORE_HOST=localhost
fi
exec node /opt/mcp-server/server.mjs
ENTRY
RUN chmod +x /opt/mcp-server/entrypoint.sh
EXPOSE 3000
ENTRYPOINT ["/opt/mcp-server/entrypoint.sh"]