Skip to content

Add Docker support for MCP server#109

Open
apetti1920 wants to merge 2 commits intochronosphereio:mainfrom
klaviyo:ap_dockerfile_init
Open

Add Docker support for MCP server#109
apetti1920 wants to merge 2 commits intochronosphereio:mainfrom
klaviyo:ap_dockerfile_init

Conversation

@apetti1920
Copy link
Contributor

Summary

Add Docker support for building and running the Chronosphere MCP server in streamable HTTP mode with automated CI/CD integration.

Changes

  • Dockerfile: Generic multi-stage build with version injection support
  • GitHub Actions CI: Docker build testing and automated publishing workflow
  • README Documentation: Docker build and run instructions

Docker Features

  • Multi-stage build: Optimized image size with separate build and runtime stages
  • Security: Non-root user execution (UID 1001)
  • Version injection: Build args for VERSION, GIT_COMMIT, and BUILD_DATE
  • Health checks: Process monitoring with 30s intervals
  • Configuration: Volume-mountable config files for custom setups
  • HTTP transport: Streamable MCP mode on port 8081 by default

CI/CD Integration

docker-build Job (All Runs)

  • Runs on all PRs and pushes
  • Tests Docker image builds without publishing
  • Uses GitHub Actions cache for performance
  • Validates Dockerfile on every change

docker-push Job (Main Branch & Tags)

  • Publishes to GitHub Container Registry (ghcr.io)
  • Conditional: Only runs on main branch merges and version tags
  • Depends on all tests passing: [build, golangci, test, docker-build]
  • Automatic authentication via GITHUB_TOKEN

Image Tags Strategy

Version Tag (e.g., v0.3.5):

  • ghcr.io/chronosphereio/chronosphere-mcp:v0.3.5
  • ghcr.io/chronosphereio/chronosphere-mcp:0.3.5
  • ghcr.io/chronosphereio/chronosphere-mcp:0.3
  • ghcr.io/chronosphereio/chronosphere-mcp:<commit-sha>
  • ghcr.io/chronosphereio/chronosphere-mcp:latest

Main Branch Push:

  • ghcr.io/chronosphereio/chronosphere-mcp:<commit-sha>
  • ghcr.io/chronosphereio/chronosphere-mcp:latest

Usage

Build Locally

docker build \
  --build-arg VERSION=$(git describe --tags --always --dirty) \
  --build-arg GIT_COMMIT=$(git rev-parse HEAD) \
  --build-arg BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ) \
  -t chronomcp:latest .

Run Container

docker run -p 8081:8081 \
  -e CHRONOSPHERE_ORG_NAME=<your-org> \
  -e CHRONOSPHERE_API_TOKEN=<your-token> \
  chronomcp:latest

Custom Configuration

docker run -p 8081:8081 \
  -v $(pwd)/custom-config.yaml:/app/config.yaml \
  -e CHRONOSPHERE_ORG_NAME=<your-org> \
  -e CHRONOSPHERE_API_TOKEN=<your-token> \
  chronomcp:latest

Pull from GHCR (After Merge)

docker pull ghcr.io/chronosphereio/chronosphere-mcp:latest

Testing

Tested with:
- Docker build completes successfully
- Binary runs and serves MCP on port 8081
- Health check validates process running
- Config file mounting works correctly
- Non-root user execution verified

Notes

- Based on existing project patterns and Go 1.23.4 requirements
- Compatible with MCP inspector debugging workflow
- No breaking changes to existing build/run processes

@apetti1920 apetti1920 requested a review from a team as a code owner September 30, 2025 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant