-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile
More file actions
56 lines (42 loc) · 1.41 KB
/
Dockerfile
File metadata and controls
56 lines (42 loc) · 1.41 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
FROM python:3.12-slim
# Set working directory
WORKDIR /app
# Install system dependencies including Node.js for MCP servers
RUN apt-get update && apt-get install -y \
curl \
jq \
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y nodejs \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Copy config early for MCP preloading
COPY config/ ./config/
# Install common MCP servers based on config (as root before switching users)
COPY scripts/preload-mcps.sh .
RUN chmod +x preload-mcps.sh && ./preload-mcps.sh
# Create non-root user first for better security
RUN useradd -m -u 1000 agent && \
chown -R agent:agent /app
# Copy requirements first for better caching
COPY requirements.txt .
# Install Python dependencies with better practices
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Copy source code
COPY src/ ./src/
COPY main.py .
# Copy startup script for runtime
COPY scripts/startup.sh .
RUN chmod +x startup.sh
# Create necessary directories
RUN mkdir -p logs && \
chown -R agent:agent /app
# Switch to non-root user
USER agent
# Expose port
EXPOSE 8000
# Add healthcheck with proper timeout
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
# Use startup script as entry point for runtime checks
CMD ["./startup.sh"]