# 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 COPY cmd/mcp/entrypoint.sh /opt/entrypoint.sh RUN chmod +x /opt/entrypoint.sh ENTRYPOINT ["/opt/entrypoint.sh"]