|
| 1 | +FROM golang:1.23.7-alpine AS build |
1 | 2 | ARG VERSION="dev"
|
2 | 3 |
|
3 |
| -FROM golang:1.23.7 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 | 11 | # Install dependencies
|
12 |
| -COPY go.mod go.sum ./ |
13 |
| -RUN --mount=type=cache,target=/root/.cache/go-build go mod download |
| 12 | +RUN --mount=type=cache,target=/go/pkg/mod \ |
| 13 | + --mount=type=bind,source=go.mod,target=go.mod \ |
| 14 | + --mount=type=bind,source=go.sum,target=go.sum \ |
| 15 | + go mod download |
14 | 16 |
|
15 |
| -COPY . ./ |
16 | 17 | # 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 |
| 18 | +RUN --mount=type=cache,target=/go/pkg/mod \ |
| 19 | + --mount=type=cache,target=/root/.cache/go-build \ |
| 20 | + --mount=type=bind,target=. \ |
| 21 | + 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)" \ |
| 22 | + -o /bin/github-mcp-server cmd/github-mcp-server/main.go |
19 | 23 |
|
20 | 24 | # Make a stage to run the app
|
21 | 25 | FROM gcr.io/distroless/base-debian12
|
22 | 26 | # Set the working directory
|
23 | 27 | WORKDIR /server
|
24 | 28 | # Copy the binary from the build stage
|
25 |
| -COPY --from=build /build/github-mcp-server . |
| 29 | +COPY --from=build /bin/github-mcp-server . |
26 | 30 | # Command to run the server
|
27 | 31 | CMD ["./github-mcp-server", "stdio"]
|
0 commit comments