1- # Serena MCP Server Container Image
2- # Provides AI-powered code intelligence with support for Python, Java, JavaScript/ TypeScript, and Go
1+ # Serena MCP Server Container Image (Slim)
2+ # Optimized for Python, Go, and TypeScript support with minimal image size
33
4+ # Stage 1: Build gopls
5+ FROM golang:1.24-alpine AS gopls-builder
6+ # Pin to gopls v0.17.1 which is compatible with Go 1.24
7+ RUN go install golang.org/x/tools/gopls@v0.17.1
8+
9+ # Stage 2: Final image
410FROM python:3.11-slim
511
612# OCI labels for GitHub Container Registry
713LABEL org.opencontainers.image.title="Serena MCP Server"
8- LABEL org.opencontainers.image.description="A containerized MCP server with semantic code analysis for Python, Java, JavaScript/TypeScript, and Go "
14+ LABEL org.opencontainers.image.description="A containerized MCP server with semantic code analysis for Python, Go, and TypeScript "
915LABEL org.opencontainers.image.source="https://github.com/githubnext/gh-aw-mcpg/tree/main/containers/serena-mcp-server"
1016LABEL org.opencontainers.image.documentation="https://github.com/githubnext/gh-aw-mcpg/blob/main/containers/serena-mcp-server/README.md"
1117LABEL org.opencontainers.image.url="https://github.com/githubnext/gh-aw-mcpg/pkgs/container/serena-mcp-server"
@@ -14,53 +20,29 @@ LABEL org.opencontainers.image.vendor="GitHub"
1420# Set working directory
1521WORKDIR /app
1622
17- # Install system dependencies required for language servers and build tools
23+ # Install minimal system dependencies
24+ # - git: required for some Serena operations
25+ # - nodejs/npm: for TypeScript language server
26+ # - ca-certificates: for HTTPS
1827RUN apt-get update && apt-get install -y --no-install-recommends \
19- # Build essentials
20- build-essential \
2128 git \
22- curl \
23- wget \
24- # Java Development Kit (for Java language support and compilation)
25- default-jdk \
26- # Node.js (for JavaScript/TypeScript language support)
2729 nodejs \
2830 npm \
29- # Go runtime (for Go language support)
30- golang-go \
31- # Additional utilities
3231 ca-certificates \
3332 && rm -rf /var/lib/apt/lists/* \
34- && update-ca-certificates
33+ && apt-get clean
3534
36- # Set environment variables for language runtimes
37- ENV JAVA_HOME=/usr/lib/jvm/default-java
38- ENV PATH="${JAVA_HOME}/bin:${PATH}"
39- ENV GOPATH=/go
40- ENV PATH="${GOPATH}/bin:${PATH}"
35+ # Copy pre-built gopls from builder stage
36+ COPY --from=gopls-builder /go/bin/gopls /usr/local/bin/gopls
4137
42- # Install Serena MCP server from GitHub using pip
43- # Serena is a Python package, so we can install it directly
44- # Try GitHub first, then fall back to PyPI package name if available
38+ # Install Serena MCP server from GitHub
4539RUN pip install --no-cache-dir git+https://github.com/oraios/serena.git || \
4640 (echo "GitHub installation failed, trying PyPI..." && \
4741 pip install --no-cache-dir serena-agent)
4842
49- # Install common language servers that Serena may need
50- # These are installed globally to be available to Serena
51- RUN npm install -g \
52- typescript \
53- typescript-language-server \
54- && rm -rf /root/.npm
55-
56- # Install Python language server (pyright is included in Serena dependencies)
57- # Additional Python tools
58- RUN pip install --no-cache-dir \
59- python-lsp-server \
60- pylsp-mypy
61-
62- # Install gopls (Go language server)
63- RUN go install golang.org/x/tools/gopls@latest
43+ # Install TypeScript language server (minimal)
44+ RUN npm install -g typescript typescript-language-server && \
45+ rm -rf /root/.npm /tmp/*
6446
6547# Create directories for Serena configuration and caching
6648RUN mkdir -p /workspace /tmp/serena-cache /root/.serena
@@ -70,30 +52,25 @@ ENV SERENA_WORKSPACE=/workspace
7052ENV SERENA_CACHE_DIR=/tmp/serena-cache
7153
7254# Create a dummy project to pre-warm Serena's LSP cache
73- # This initializes the language servers and caches so they're ready at runtime
74- # Focus on Python, Go, and TypeScript which are the primary languages for codex context
55+ # Focus on Python, Go, and TypeScript for codex context
7556RUN mkdir -p /tmp/dummy-project && \
7657 echo 'def hello(): pass' > /tmp/dummy-project/main.py && \
7758 echo 'package main\n func main() {}' > /tmp/dummy-project/main.go && \
7859 echo 'export function hello() {}' > /tmp/dummy-project/index.ts
7960
80- # Pre-index the dummy project to warm up the LSP caches
81- # Use --language to specify languages non-interactively and --index to index after creation
82- # This ensures pyright, gopls, and typescript-language-server are initialized
61+ # Pre-index to warm up LSP caches
8362RUN serena project create /tmp/dummy-project --name dummy \
8463 --language python --language go --language typescript \
8564 --index --log-level INFO --timeout 120 || \
8665 echo "Pre-indexing completed (some warnings may be expected)"
8766
88- # Clean up the dummy project but keep the caches
67+ # Clean up
8968RUN rm -rf /tmp/dummy-project
9069
9170# Expose the workspace directory as a volume mount point
9271VOLUME ["/workspace" ]
9372
9473# Set default entrypoint to run Serena MCP server
95- # This will start the MCP server on stdio transport
9674ENTRYPOINT ["serena-mcp-server" ]
9775
98- # Default arguments (can be overridden)
9976CMD []
0 commit comments