forked from imran-siddique/agent-mesh
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.server
More file actions
86 lines (70 loc) · 2.21 KB
/
Dockerfile.server
File metadata and controls
86 lines (70 loc) · 2.21 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
# AgentMesh Server Dockerfile
# Multi-stage build for production deployment
FROM python:3.11-slim as builder
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
# Create virtual environment
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Copy requirements
COPY pyproject.toml /tmp/
WORKDIR /tmp
# Install dependencies
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir \
agentmesh-platform[server] || \
pip install --no-cache-dir \
pydantic>=2.5.0 \
cryptography>=42.0.0 \
pynacl>=1.5.0 \
httpx>=0.26.0 \
aiohttp>=3.9.0 \
pyyaml>=6.0 \
structlog>=24.1.0 \
click>=8.1.0 \
rich>=13.0.0 \
fastapi>=0.109.0 \
uvicorn[standard]>=0.27.0 \
redis[asyncio]>=5.0.0 \
sqlalchemy[asyncio]>=2.0.0 \
asyncpg>=0.29.0 \
opentelemetry-api>=1.20.0 \
opentelemetry-sdk>=1.20.0 \
opentelemetry-instrumentation-fastapi>=0.41b0 \
prometheus-client>=0.19.0
# Production stage
FROM python:3.11-slim
# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
libpq5 \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Copy virtual environment from builder
COPY --from=builder /opt/venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Create non-root user
RUN useradd -m -u 1000 agentmesh && \
mkdir -p /app /data && \
chown -R agentmesh:agentmesh /app /data
USER agentmesh
WORKDIR /app
# Copy application code
COPY --chown=agentmesh:agentmesh src/ /app/src/
COPY --chown=agentmesh:agentmesh pyproject.toml /app/
# Install application
RUN pip install --no-cache-dir -e .
# Expose ports
EXPOSE 8080 9090
# Health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD python -c "import httpx; httpx.get('http://localhost:8080/health', timeout=5)" || exit 1
# Environment variables
ENV AGENTMESH_ENV=production \
AGENTMESH_LOG_LEVEL=INFO \
AGENTMESH_STORAGE_BACKEND=redis \
PYTHONUNBUFFERED=1
# Run server
CMD ["uvicorn", "agentmesh.server.main:app", "--host", "0.0.0.0", "--port", "8080", "--workers", "${AGENTMESH_WORKERS:-4}"]