Files
Memoh/docker/Dockerfile.mcp
T
斬風千雪 a5b11dddc2 fix(mcp): adapt tool list checker to underscore name format (#113)
* fix(mcp): adapt tool list checker to underscore name format

---------

Co-authored-by: Ran <16112591+chen-ran@users.noreply.github.com>
2026-02-24 17:00:41 +08:00

42 lines
1.5 KiB
Docker

# syntax=docker/dockerfile:1
FROM scratch AS gomodcache
FROM --platform=$BUILDPLATFORM golang:1.25-alpine AS build
WORKDIR /src
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=bind,from=gomodcache,target=/tmp/gomodcache \
set -eux; \
if [ -d /tmp/gomodcache/cache/download ]; then \
cp -a /tmp/gomodcache/. /go/pkg/mod/; \
fi; \
go mod download
COPY . .
ARG TARGETARCH
ARG COMMIT_HASH=unknown
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH:-amd64} \
go build -trimpath -ldflags "-s -w -X github.com/memohai/memoh/internal/version.CommitHash=${COMMIT_HASH}" -o /out/mcp ./cmd/mcp
FROM alpine:latest
# Base utilities
RUN apk add --no-cache grep curl bash
# Node.js + npm (provides npx for JS/TS MCP servers)
RUN apk add --no-cache nodejs npm
# Python 3 + uv (provides uvx for Python MCP servers)
RUN apk add --no-cache python3 && \
curl -LsSf https://astral.sh/uv/install.sh | sh && \
ln -sf /root/.local/bin/uv /usr/local/bin/uv && \
ln -sf /root/.local/bin/uvx /usr/local/bin/uvx
WORKDIR /app
COPY --from=build /out/mcp /opt/mcp
COPY cmd/mcp/template /opt/mcp-template
ENTRYPOINT ["/bin/sh","-lc","bootstrap(){ [ -e /app/mcp ] || { mkdir -p /app; [ -f /opt/mcp ] && cp -a /opt/mcp /app/mcp 2>/dev/null || true; }; }; bootstrap; if [ -x /app/mcp ]; then exec /app/mcp \"$@\"; fi; exec /opt/mcp \"$@\"","--"]