|
| 1 | +FROM golang:1.24.4-alpine AS build |
1 | 2 | ARG VERSION="dev" |
2 | 3 |
|
3 | | -FROM golang:1.24.2 AS build |
4 | | -# allow this step access to build arg |
5 | | -ARG VERSION |
6 | 4 | # Set the working directory |
7 | 5 | WORKDIR /build |
8 | 6 |
|
9 | | -RUN go env -w GOMODCACHE=/root/.cache/go-build |
| 7 | +# Install git |
| 8 | +RUN --mount=type=cache,target=/var/cache/apk \ |
| 9 | + apk add git |
10 | 10 |
|
11 | | -# Install dependencies |
12 | | -COPY go.mod go.sum ./ |
13 | | -RUN --mount=type=cache,target=/root/.cache/go-build go mod download |
14 | | - |
15 | | -COPY . ./ |
16 | 11 | # Build the server |
17 | | -RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 go build -ldflags="-s -w -X main.version=${VERSION} -X main.commit=$(git rev-parse HEAD) -X main.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \ |
18 | | - -o github-mcp-server cmd/github-mcp-server/main.go |
| 12 | +# go build automatically download required module dependencies to /go/pkg/mod |
| 13 | +RUN --mount=type=cache,target=/go/pkg/mod \ |
| 14 | + --mount=type=cache,target=/root/.cache/go-build \ |
| 15 | + --mount=type=bind,target=. \ |
| 16 | + CGO_ENABLED=0 go build -ldflags="-s -w -X main.version=${VERSION} -X main.commit=$(git rev-parse HEAD) -X main.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \ |
| 17 | + -o /bin/github-mcp-server cmd/github-mcp-server/main.go |
19 | 18 |
|
20 | 19 | # Make a stage to run the app |
21 | 20 | FROM gcr.io/distroless/base-debian12 |
22 | 21 | # Set the working directory |
23 | 22 | WORKDIR /server |
24 | 23 | # Copy the binary from the build stage |
25 | | -COPY --from=build /build/github-mcp-server . |
26 | | -# Command to run the server |
27 | | -CMD ["./github-mcp-server", "stdio"] |
| 24 | +COPY --from=build /bin/github-mcp-server . |
| 25 | +# Set the entrypoint to the server binary |
| 26 | +ENTRYPOINT ["/server/github-mcp-server"] |
| 27 | +# Default arguments for ENTRYPOINT |
| 28 | +CMD ["stdio"] |
0 commit comments