diff --git a/kubelet-to-gcm/Dockerfile b/kubelet-to-gcm/Dockerfile index 243833268..b9cc9cd58 100644 --- a/kubelet-to-gcm/Dockerfile +++ b/kubelet-to-gcm/Dockerfile @@ -11,10 +11,16 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +FROM --platform=$BUILDPLATFORM golang:1.24 AS builder +ARG TARGETOS +ARG TARGETARCH +WORKDIR /workspace/ +COPY . /workspace/ +RUN GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 go build -mod=vendor -a -o /output/monitor monitor/main/daemon.go -FROM --platform=$TARGETPLATFORM gcr.io/distroless/static:latest +FROM gcr.io/distroless/static:latest -COPY build/monitor / +COPY --from=builder /output/monitor / # nobody:nobody USER 65534:65534 diff --git a/kubelet-to-gcm/Makefile b/kubelet-to-gcm/Makefile index 0d025ee35..fde1ffb3a 100644 --- a/kubelet-to-gcm/Makefile +++ b/kubelet-to-gcm/Makefile @@ -65,9 +65,6 @@ push-multiarch: $(addprefix .sub-push-,$(ALL_ARCH)) clean: rm -rf monitor -build: go docker-setup - docker build --pull -t ${PREFIX}/kubelet-to-gcm:$(TAG) . - coverage: rm -f coverage.out go test -coverpkg=./... -coverprofile=coverage.out ./...