diff --git a/build/deployments/custom-container.mdx b/build/deployments/custom-container.mdx index 37d8b87..ee2e955 100644 --- a/build/deployments/custom-container.mdx +++ b/build/deployments/custom-container.mdx @@ -106,6 +106,43 @@ RUN npm run build CMD ["node", "dist/index.js"] ``` +```dockerfile Node.js/TypeScript (Monorepo with Turbo) +FROM node:22-slim + +ARG TURBO_TEAM +ENV TURBO_TEAM=$TURBO_TEAM + +ARG TURBO_TOKEN +ENV TURBO_TOKEN=$TURBO_TOKEN + +# Set working directory +WORKDIR /app + +# Copy root package.json and lockfile +COPY package*.json ./ + +# Copy turbo.json for build configuration +COPY turbo.json ./ + +# Copy shared packages (adjust paths as needed) +COPY packages/ ./packages/ + +# Copy the specific app +COPY apps/my-mcp-server/ ./apps/my-mcp-server/ + +# Install dependencies from monorepo root +RUN npm ci + +# Build using Turborepo (builds dependencies in correct order) +RUN npx turbo build --filter=my-mcp-server + +# Expose the port your app runs on +EXPOSE 8080 + +# Start the application from root directory to maintain module resolution +CMD ["node", "apps/my-mcp-server/dist/index.cjs"] +``` + ```dockerfile Python FROM python:3.11-slim @@ -129,6 +166,38 @@ CMD ["uv", "run", "python", "main.py"] +## Monorepo Considerations + +If you're working with a monorepo (using tools like Turbo, Lerna, or Nx), you'll need to adjust your configuration: + +### smithery.yaml for Monorepo + +For monorepos, you may need to specify a custom Docker build path that includes the entire repository context: + +```yaml +runtime: "container" +build: + dockerfile: "apps/my-mcp-server/Dockerfile" # Path to your Dockerfile + dockerBuildPath: "../../" # Build from repository root +startCommand: + type: "http" +``` + +### Dockerfile Patterns + +The monorepo Dockerfile example above shows the key patterns: + +- **Copy the entire monorepo structure**: Include `packages/`, `apps/`, and root configuration files +- **Use Turbo build arguments**: Pass `TURBO_TEAM` and `TURBO_TOKEN` if using Turbo Cloud +- **Build with dependency awareness**: Use `npx turbo build --filter=your-app` to build only your app and its dependencies +- **Maintain module resolution**: Start the application from the root directory to preserve workspace module resolution + +### Common Monorepo Issues + +- **Build context**: Ensure your `dockerBuildPath` includes all necessary workspace dependencies +- **File copying**: Copy shared packages and configuration files before building +- **Module resolution**: Start your application from the correct working directory to maintain import paths + ## Deploy 1. Push your code (including `smithery.yaml` and `Dockerfile`) to GitHub @@ -157,6 +226,7 @@ Common deployment failures and solutions: - **Docker build fails**: Check your Dockerfile syntax and ensure all files are copied correctly - **Dependencies not found**: Make sure your package files are copied before installing dependencies +- **Monorepo build issues**: Ensure your `dockerBuildPath` includes the entire repository context and all workspace dependencies are copied correctly ### Why don't my server's capabilities get listed?