-
Notifications
You must be signed in to change notification settings - Fork 86
Multiplatform support for the docker image #144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ cmd/mcpcurl/mcpcurl | |
.vscode/ | ||
dist/ | ||
bin/* | ||
.idea/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ RUN apk add --no-cache ca-certificates | |
|
||
# devbuild compiles the binary | ||
# ----------------------------------- | ||
FROM golang:1.24.4-alpine@sha256:e5c2e59960f8636d02f77029c8f0a7a6b882f87fee8d2e4a9ce6c9ff112ed735 AS devbuild | ||
FROM golang:1.24.4-alpine AS devbuild | ||
ARG VERSION="dev" | ||
# Set the working directory | ||
WORKDIR /build | ||
|
@@ -26,7 +26,9 @@ COPY go.mod go.sum ./ | |
RUN --mount=type=cache,target=/root/.cache/go-build go mod download | ||
COPY . ./ | ||
# Build the server | ||
RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 go build -ldflags="-s -w -X terraform-mcp-server/version.GitCommit=$(shell git rev-parse HEAD) -X terraform-mcp-server/version.BuildDate=$(shell git show --no-show-signature -s --format=%cd --date=format:'%Y-%m-%dT%H:%M:%SZ' HEAD)" \ | ||
RUN --mount=type=cache,target=/root/.cache/go-build \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we need the version commit and build Date information, please put them back |
||
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \ | ||
go build -ldflags="-s -w" \ | ||
-o terraform-mcp-server ./cmd/terraform-mcp-server | ||
|
||
# dev runs the binary from devbuild | ||
|
@@ -58,7 +60,8 @@ ARG PRODUCT_VERSION | |
ARG PRODUCT_REVISION | ||
ARG PRODUCT_NAME=$BIN_NAME | ||
# TARGETARCH and TARGETOS are set automatically when --platform is provided. | ||
ARG TARGETOS TARGETARCH | ||
ARG TARGETOS | ||
ARG TARGETARCH | ||
LABEL version=$PRODUCT_VERSION | ||
LABEL revision=$PRODUCT_REVISION | ||
COPY dist/$TARGETOS/$TARGETARCH/$BIN_NAME /bin/terraform-mcp-server | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,9 +47,12 @@ clean: | |
deps: | ||
$(GO) mod download | ||
|
||
# Build docker image | ||
# Build multi-platform docker image | ||
docker-build: | ||
$(DOCKER) build --build-arg VERSION=$(VERSION) -t $(BINARY_NAME):$(VERSION) . | ||
$(DOCKER) buildx build --platform linux/amd64,linux/arm64 \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is meant for local deployment only, which is satisfactory unless you think otherwise? When we actually deploy the container image we do it for most arch (armv6, arm64, amd64, 386 )--> https://hub.docker.com/r/hashicorp/terraform-mcp-server/tags |
||
--build-arg VERSION=$(VERSION) \ | ||
-t $(BINARY_NAME):$(VERSION) . \ | ||
--output type=docker | ||
|
||
# Run HTTP server locally | ||
run-http: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we make sure this is pinned to a SHA instead of alpine in general?