Skip to content

Commit df34f83

Browse files
committed
update tests
1 parent 51e0c8f commit df34f83

11 files changed

Lines changed: 72 additions & 8 deletions

auth_platform/docker-compose.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ services:
1919
- mcp-server
2020

2121
mcp-server:
22-
build: ../mcp_server
22+
build:
23+
context: ../mcp_server
24+
target: development
2325
ports:
2426
- "8001:8001"
2527
volumes:
26-
- ../mcp_server:/app
28+
- ../mcp_server:/workspace/mcp_server
2729
environment:
2830
- MCP_PORT=8001
2931
- LOG_LEVEL=INFO
@@ -34,3 +36,16 @@ services:
3436
- BAML_ENABLED=false
3537
- ALERT_CONSOLIDATION_WINDOW_MINUTES=5
3638
- MAX_EVENTS_PER_ALERT=10
39+
40+
# Test service for running unit tests
41+
mcp-server-tests:
42+
build:
43+
context: ../mcp_server
44+
target: test
45+
volumes:
46+
- ../mcp_server:/workspace/mcp_server
47+
environment:
48+
- PYTHONPATH=/workspace
49+
profiles:
50+
- test
51+
command: ["python", "-m", "pytest", "mcp_server/tests/unit/", "-v"]

mcp_server/Dockerfile

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,67 @@
1-
# Use Python 3.11 slim image as base
2-
FROM python:3.11-slim
1+
# Multi-stage Dockerfile for MCP Server
2+
FROM python:3.11-slim as base
33

4-
# Set working directory to parent directory
4+
# Install system dependencies
5+
RUN apt-get update && apt-get install -y \
6+
curl \
7+
&& rm -rf /var/lib/apt/lists/*
8+
9+
# Set working directory
510
WORKDIR /workspace
611

12+
# Copy pyproject.toml first for better caching
13+
COPY pyproject.toml ./mcp_server/
14+
15+
# Development stage - includes test dependencies
16+
FROM base as development
17+
18+
# Install the package with all dependencies (including test and dev dependencies)
19+
RUN cd mcp_server && pip install --no-cache-dir -e .[test,dev]
20+
721
# Copy the entire mcp_server directory
822
COPY . ./mcp_server/
923

10-
# Install dependencies
11-
RUN pip install --no-cache-dir fastapi==0.104.1 uvicorn==0.24.0 httpx==0.25.1 sqlalchemy==2.0.23 pydantic==2.8.2 pydantic-settings==2.4.0 python-dotenv==1.0.0
24+
# Set PYTHONPATH to ensure imports work correctly
25+
ENV PYTHONPATH=/workspace
1226

1327
# Expose port 8001
1428
EXPOSE 8001
1529

16-
# Set PYTHONPATH and run the application
30+
# Health check
31+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
32+
CMD curl -f http://localhost:8001/health || exit 1
33+
34+
# Default command to run the application
35+
CMD ["uvicorn", "mcp_server.main:app", "--host", "0.0.0.0", "--port", "8001"]
36+
37+
# Production stage - minimal dependencies
38+
FROM base as production
39+
40+
# Install only production dependencies
41+
RUN cd mcp_server && pip install --no-cache-dir -e .
42+
43+
# Copy the entire mcp_server directory
44+
COPY . ./mcp_server/
45+
46+
# Set PYTHONPATH to ensure imports work correctly
1747
ENV PYTHONPATH=/workspace
48+
49+
# Create a non-root user for security
50+
RUN useradd --create-home --shell /bin/bash app
51+
USER app
52+
53+
# Expose port 8001
54+
EXPOSE 8001
55+
56+
# Health check
57+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
58+
CMD curl -f http://localhost:8001/health || exit 1
59+
60+
# Default command to run the application
1861
CMD ["uvicorn", "mcp_server.main:app", "--host", "0.0.0.0", "--port", "8001"]
62+
63+
# Test stage - for running tests in CI
64+
FROM development as test
65+
66+
# Run tests by default
67+
CMD ["python", "-m", "pytest", "mcp_server/tests/", "-v"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)