diff --git a/Dockerfile b/Dockerfile index 47fb715..dbf7338 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,10 @@ +FROM golang:1.23-bookworm AS build + +WORKDIR /go/src/app +RUN --mount=target=. make build + FROM quay.io/prometheus/busybox:latest -ADD prometheus-example-app /bin/prometheus-example-app +COPY --from=build /tmp/prometheus-example-app /bin/prometheus-example-app ENTRYPOINT ["/bin/prometheus-example-app"] diff --git a/Makefile b/Makefile index 63bbcd3..e2970a9 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,11 @@ VERSION:=$(shell cat VERSION) LDFLAGS="-X main.appVersion=$(VERSION)" -all: - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags=$(LDFLAGS) -o prometheus-example-app --installsuffix cgo main.go +build: + CGO_ENABLED=0 go build -ldflags=$(LDFLAGS) -o /tmp/prometheus-example-app --installsuffix cgo main.go + +all: build docker build -t quay.io/brancz/prometheus-example-app:$(VERSION) . + +multi: build + docker buildx build --push --platform linux/arm/v7,linux/arm64/v8,linux/amd64 -t quay.io/brancz/prometheus-example-app:$(VERSION) .