-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
62 lines (46 loc) · 1.67 KB
/
Dockerfile
File metadata and controls
62 lines (46 loc) · 1.67 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
# MCP Skeleton Server
# Production Dockerfile for AKS deployment
FROM python:3.12-slim
# Set build arguments
ARG POETRY_VERSION=1.7.1
# Install system dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
curl \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user for security
RUN useradd --uid 10001 -md /home/mcpuser mcpuser
# Install poetry
RUN pip install --upgrade pip && \
pip install poetry==${POETRY_VERSION}
# Configure poetry to not create virtual env (using container isolation)
RUN poetry config virtualenvs.create false
# Set working directory
WORKDIR /app
# Copy dependency files
COPY --chown=mcpuser:mcpuser pyproject.toml poetry.lock* ./
# Install dependencies as root (for system packages)
RUN poetry install --no-root --only main --no-interaction --no-ansi
# Copy application code with folder structure
COPY --chown=mcpuser:mcpuser mcp_server.py /app/
COPY --chown=mcpuser:mcpuser tools/ /app/tools/
COPY --chown=mcpuser:mcpuser utilities/ /app/utilities/
COPY --chown=mcpuser:mcpuser README.md /app/
COPY --chown=mcpuser:mcpuser .env.example /app/.env
# Copy and set permissions for entrypoint script
COPY --chown=mcpuser:mcpuser entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
# Switch to non-root user
USER mcpuser
# Expose HTTP port for MCP server
EXPOSE 8000
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONPATH=/app
# Health check endpoint
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
CMD curl -f http://localhost:8000/sse || exit 1
# Run the MCP server using entrypoint script
CMD ["/app/entrypoint.sh"]