1- # Build stage
1+ # Build stage for MCP server
22FROM golang:1.24-alpine AS builder
33
44WORKDIR /app
@@ -16,6 +16,9 @@ RUN CGO_ENABLED=0 GOOS=linux go build -o opencode-mcp-server ./opencode/
1616# Final stage - use Debian instead of Alpine for glibc compatibility
1717FROM debian:bookworm-slim
1818
19+ # Copy opencode binary from the official opencode image
20+ COPY --from=ghcr.io/anomalyco/opencode:latest /usr/local/bin/opencode /usr/local/bin/opencode
21+
1922# Install required runtime dependencies
2023RUN apt-get update && apt-get install -y --no-install-recommends \
2124 ca-certificates \
@@ -37,19 +40,10 @@ RUN (type -p wget >/dev/null || (apt-get update && apt-get install wget -y)) \
3740 && apt-get install gh -y \
3841 && rm -rf /var/lib/apt/lists/*
3942
40- # Install opencode and capture the installation location
41- RUN curl -fsSL https://opencode.ai/install | bash && \
42- # Find where opencode was installed and link it to /usr/local/bin
43- if [ -f /root/.local/bin/opencode ]; then \
44- ln -s /root/.local/bin/opencode /usr/local/bin/opencode; \
45- elif [ -f /root/.opencode/bin/opencode ]; then \
46- ln -s /root/.opencode/bin/opencode /usr/local/bin/opencode; \
47- fi
48-
4943# Copy the MCP server binary
5044COPY --from=builder /app/opencode-mcp-server /usr/local/bin/opencode-mcp-server
5145
52- # Verify opencode works in final container
46+ # Verify opencode binary is properly installed
5347RUN which opencode && opencode --version || echo "Warning: opencode may not be properly installed"
5448
5549# Create session directory
0 commit comments