Skip to content

Conversation

aaronsb
Copy link

@aaronsb aaronsb commented Mar 26, 2025

Add Multi-Architecture Docker Build Support

Overview

This pull request adds support for building Docker images for multiple CPU architectures (amd64 and arm64) both locally and via GitHub Actions. This enhancement improves compatibility across different platforms and deployment environments. When users want to use the Glean MCP server, many different possible MCP capable tool hosts are able to use dockerized images. This prevents errors and difficulties with deploying the MCP server, and sets the roadway for more enhancements to this MCP server.

Changes

GitHub Actions Workflow

  • Added a new GitHub Actions workflow for Docker builds (docker-build.yml)
  • Configured the workflow to build and push multi-architecture images to GitHub Container Registry
  • Set up automated cleanup of old container versions
  • Implemented proper tagging strategy for releases and branches

Local Build Improvements

  • Enhanced build scripts to support multi-architecture builds
  • Added QEMU support for cross-platform builds
  • Updated Docker configuration for better compatibility with different architectures
  • Improved Docker build process with proper caching and optimization

Docker Configuration

  • Updated Dockerfile for multi-architecture compatibility
  • Configured proper build arguments and environment variables
  • Ensured consistent behavior across different platforms

Benefits

  • Improved Compatibility: Support for both amd64 (x86_64) and arm64 (Apple Silicon, AWS Graviton, etc.) architectures
  • Simplified Deployment: Single image manifest that works across different CPU architectures
  • Better Developer Experience: Consistent build process regardless of local development environment
  • Reduced Resource Usage: Optimized build process with proper caching
  • Automated Workflows: Streamlined CI/CD process for Docker image builds
  • Simplified MCP Server Usage: Docker images provide a far simpler way to run Glean MCP on agent hosts that can use MCP servers, eliminating complex setup procedures and dependency management

Testing

  • Verified local multi-architecture builds on different platforms
  • Tested GitHub Actions workflow for proper image building and pushing
  • Confirmed compatibility with both amd64 and arm64 environments
  • Validated Docker image functionality across different architectures

Notes for Reviewers

  • The GitHub Actions workflow is configured to push to the GitHub Container Registry (ghcr.io)
  • The workflow runs on pushes to main, tags starting with 'v', and pull requests to main
  • Local build scripts can be used for testing without pushing to a registry

Deployment Examples

Running the MCP Server with Docker

# Pull the multi-architecture image (automatically selects the right architecture)
docker pull ghcr.io/gleanwork/mcp-server:latest

# Run the MCP server
docker run -p 3000:3000 ghcr.io/gleanwork/mcp-server:latest

Using in Agent Configurations

{
  "mcpServers": {
    "glean": {
      "command": "docker",
      "args": ["run", "--rm", "-i", "ghcr.io/gleanwork/mcp-server:latest"],
      "env": {
        "API_KEY": "your-api-key"
      }
    }
  }
}

This containerized approach significantly simplifies deployment across different environments and architectures without requiring manual setup of Node.js, dependencies, or build tools on the host system.

@steve-calvert-glean steve-calvert-glean self-requested a review March 30, 2025 19:41
@steve-calvert-glean steve-calvert-glean added the enhancement New feature or request label Mar 30, 2025
@steve-calvert-glean
Copy link
Collaborator

Thanks for this change, @aaronsb! It looks like CI is failing. I'll try to take a peek at this and resolve unless you have a chance before me.

@steve-calvert-glean
Copy link
Collaborator

@aaronsb I've fixed the CI issue (was the result of pnpm@10 restricting builds on package installs). This branch just needs a rebase (and the merge conflict needs fixing, likely due to my running npx sort-package-json).

@aaronsb
Copy link
Author

aaronsb commented Mar 31, 2025

Cool - I made sure it would build on my fork but I've probably got different rules set up. Let me know if you have any other questions on rebase or ci.

@ffluk3
Copy link

ffluk3 commented Jul 14, 2025

Hey! Are there any updates on this changeset? This update would be very helpful for my team, I'd be happy to help contribute if needed as well!

@sholsapp
Copy link

@aaronsb looks like there's more conflicts in the README.md and package.json related to pnpm switch. Are you able to still look? @ffluk3 or I can help. :) We don't want to roll our own.

@aaronsb
Copy link
Author

aaronsb commented Jul 20, 2025

@aaronsb looks like there's more conflicts in the README.md and package.json related to pnpm switch. Are you able to still look? @ffluk3 or I can help. :) We don't want to roll our own.

Hey, it's been months and I would imagine the glean mcp has changed quite a bit! I would almost rather you guys decline the PR and I'll go through and re-do it again. I found for me, that using a docker image of the STDIO MCP server was most helpful for abstract environments.

If there's not a lot of need for it, then we should not include it.

@aaronsb aaronsb force-pushed the feature/multi-arch-docker-build branch from a015771 to 0812d73 Compare July 20, 2025 02:16
@aaronsb aaronsb requested a review from a team as a code owner July 20, 2025 02:16
@aaronsb
Copy link
Author

aaronsb commented Jul 20, 2025

Hey - I decided to spend a little more time checking out what changed and went ahead and validated this approach. Turns out the monorepo structure actually makes this more useful.

What I updated:

  • Completely rebuilt for the pnpm workspace structure
  • Fixed the Dockerfile to properly handle all packages (local-mcp-server, configure-mcp-server, etc.)
  • Added proper build scripts with clean output
  • Updated the GitHub Actions workflow for buildx + pnpm
  • Tested it end-to-end with a real Glean instance - works great as an MCP server

The Docker STDIO pattern works really well - I'm running it in Claude Code right now and it's handling search/chat requests perfectly. The containerized approach eliminates all the dependency setup headaches.

Testing Results:

  • Built successfully: 313MB optimized image
  • Tested with production Glean instance (cprime-aws-be.glean.com)
  • MCP protocol working: proper JSON-RPC initialization and tool discovery
  • Live data access: successfully searching company Confluence, Google Drive, Slack content
  • Both deployment methods validated:
    • Local: npx @gleanwork/local-mcp-server
    • Docker: docker run --rm -i -e GLEAN_BASE_URL=... glean-mcp-server:latest

The Docker approach is particularly nice for environments where you don't want to manage Node.js dependencies directly. Ready for review if you think it's useful - happy to iterate on anything that needs tweaking.

- Update Dockerfile for pnpm monorepo with proper workspace handling
- Add smart build script with clean output and logging
- Fix user permissions and directory structure for MCP server
- Update GitHub Actions workflow for modern buildx and pnpm
- Add proper entrypoint supporting both local-mcp-server and configure-mcp-server
- Tested and verified working with production Glean instance
- Supports both development (npm) and production (Docker) deployment

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@aaronsb aaronsb force-pushed the feature/multi-arch-docker-build branch from 0812d73 to e313474 Compare July 20, 2025 02:33
@sholsapp
Copy link

Awesome! 🔥 This week I'll plan on trying our your branch locally as well. Hope we can get a review on this from a maintainer! ❤️

@sholsapp
Copy link

@aaronsb I checked out the PR locally and tried this out just now.

$ ./scripts/build-local.sh                         
Building Glean MCP Server
Target: glean-mcp-server:local
<snip>
Build complete! Image tagged as glean-mcp-server:local
Image size: 301.9 MB
<snip>

Great, it builds! I tried running docker run -it glean-mcp-server:local configure-mcp-server --client goose --instance <my instance>. After going through my OAuth flow, it places the credential at the following path.

[2025-07-25 17:12:32] Starting Glean MCP Server (Docker Hash: unknown)
[2025-07-25 17:12:32] Starting configure MCP server...
Configuring Glean MCP for Goose...
Authorizing Glean MCP-server.  Please log in to Glean.
! First copy your one-time code: <snip>
Press Enter to open the following URL where the code is needed:
<snip>
Created new configuration file at: /home/mcp/.config/goose/config.yaml
Goose MCP configuration has been configured to: /home/mcp/.config/goose/config.yaml

To use it:
1. Restart Goose

Which I cannot access on Docker Desktop for Mac. Is the intent for that configuration to be made available locally?

Looking great. 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants