-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathDockerfile
More file actions
152 lines (126 loc) · 4.27 KB
/
Dockerfile
File metadata and controls
152 lines (126 loc) · 4.27 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# MCP Filesystem Server with Python & Node.js Runtime
#
# This unified container provides:
# - MCP Filesystem Server
# - Python 3.12 with data science libraries
# - Node.js 20 with serve for frontend preview
#
# Build: docker build -t mcp-filesystem .
# Run: docker run -p 18089:18089 -v ./user_data:/user_data mcp-filesystem
FROM python:3.12-slim
LABEL maintainer="MCP Filesystem Team"
LABEL description="MCP Filesystem Server with Python 3.12 and Node.js 20"
LABEL version="1.0.0"
# ============================================
# Environment Variables
# ============================================
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONIOENCODING=utf-8
ENV LANG=C.UTF-8
ENV LC_ALL=C.UTF-8
# Node.js version
ENV NODE_VERSION=20
# MCP Server default settings (can be overridden by docker-compose environment)
# FASTMCP_* are the actual variables used by the server
ENV FASTMCP_HOST=0.0.0.0
ENV FASTMCP_PORT=18089
ENV MCP_WORKSPACES_DIR=/user_data
# Matplotlib backend for headless operation
ENV MPLBACKEND=Agg
# ============================================
# System Dependencies
# ============================================
RUN apt-get update && apt-get install -y --no-install-recommends \
# Basic tools
curl \
wget \
git \
unzip \
# Build tools (needed for some Python packages)
build-essential \
# OCR support
tesseract-ocr \
tesseract-ocr-chi-sim \
tesseract-ocr-chi-tra \
tesseract-ocr-eng \
# Image processing dependencies
libgl1 \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender-dev \
libgomp1 \
# Fonts
fonts-liberation \
fonts-noto-cjk \
# Process utilities
procps \
# Clean up
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# ============================================
# Node.js 20
# ============================================
RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash - \
&& apt-get install -y nodejs \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Verify Node.js installation
RUN node --version && npm --version
# ============================================
# Node.js Global Packages
# ============================================
# Only install serve for frontend preview (keep it minimal)
RUN npm install -g serve \
&& npm cache clean --force
# ============================================
# Python Dependencies
# ============================================
WORKDIR /app
# Copy requirements first for better caching
COPY requirements.txt /app/
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
# Install Playwright Chromium (crawl4ai 依赖浏览器)
RUN python -m playwright install --with-deps chromium
# ============================================
# MCP Server Application
# ============================================
# Copy application code
COPY pyproject.toml README.md /app/
COPY mcp_filesystem/ /app/mcp_filesystem/
# Install the MCP server package
RUN pip install --no-cache-dir -e .
# Copy configuration (if exists)
COPY config.example.json /app/config.json
# ============================================
# User Data Directory
# ============================================
RUN mkdir -p /user_data \
&& chmod 755 /user_data
# ============================================
# Security: Create non-root user for command execution
# ============================================
RUN useradd -m -s /bin/bash -u 1000 sandbox \
&& chown -R sandbox:sandbox /user_data
# ============================================
# Health Check
# ============================================
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:${FASTMCP_PORT}/ || exit 1
# ============================================
# Expose Ports
# ============================================
# MCP Server
EXPOSE 18089
# Frontend Preview (range)
EXPOSE 7000-7100
# ============================================
# Startup
# ============================================
WORKDIR /app
# Run as root to allow resource limit setting for child processes
# Command execution uses the sandbox user when needed
# Host/port configured via FASTMCP_HOST and FASTMCP_PORT environment variables
CMD ["python", "-m", "mcp_filesystem"]