317c44cea5
The CGO-enabled binary was dynamically linked against musl libc from Alpine, but the distroless runtime image uses glibc. This caused 'no such file or directory' at runtime because the dynamic linker couldn't be found. Fix by passing -linkmode external -extldflags '-static' to produce a fully static binary.
35 lines
1.2 KiB
Docker
35 lines
1.2 KiB
Docker
FROM golang:1.25.6-alpine AS build
|
|
ARG VERSION="dev"
|
|
|
|
# Set the working directory
|
|
WORKDIR /build
|
|
|
|
# Install git and C compiler for CGO (tree-sitter)
|
|
RUN --mount=type=cache,target=/var/cache/apk \
|
|
apk add git gcc musl-dev
|
|
|
|
# Build the server
|
|
# go build automatically download required module dependencies to /go/pkg/mod
|
|
RUN --mount=type=cache,target=/go/pkg/mod \
|
|
--mount=type=cache,target=/root/.cache/go-build \
|
|
--mount=type=bind,target=. \
|
|
CGO_ENABLED=1 go build -ldflags="-s -w -linkmode external -extldflags '-static' -X main.version=${VERSION} -X main.commit=$(git rev-parse HEAD) -X main.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
|
|
-o /bin/github-mcp-server ./cmd/github-mcp-server
|
|
|
|
# Make a stage to run the app
|
|
FROM gcr.io/distroless/base-debian12
|
|
|
|
# Add required MCP server annotation
|
|
LABEL io.modelcontextprotocol.server.name="io.github.github/github-mcp-server"
|
|
|
|
# Set the working directory
|
|
WORKDIR /server
|
|
# Copy the binary from the build stage
|
|
COPY --from=build /bin/github-mcp-server .
|
|
# Expose the default port
|
|
EXPOSE 8082
|
|
# Set the entrypoint to the server binary
|
|
ENTRYPOINT ["/server/github-mcp-server"]
|
|
# Default arguments for ENTRYPOINT
|
|
CMD ["stdio"]
|