Skip to content

Commit a5547a0

Browse files
committed
CHORE: Support build docker image locally with make docker-build command
Signed-off-by: LinPr <[email protected]>
1 parent 28a507e commit a5547a0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ GO_TEST_CODECOV ?=
99
BUILD_DATE ?= $(shell date +%FT%T%z)
1010
GOVERSION ?= $(shell go version | cut -d " " -f3)
1111
COMPONENT_VERSION ?= $(shell cat VERSION)
12+
IMAGE_TAG ?= $(shell cat VERSION | cut -c 2-)
1213
COMPONENT_BRANCH ?= $(shell git describe --always --contains --all)
1314
PMM_RELEASE_FULLCOMMIT ?= $(shell git rev-parse HEAD)
1415
GO_BUILD_LDFLAGS = -X main.version=${COMPONENT_VERSION} -X main.buildDate=${BUILD_DATE} -X main.commit=${PMM_RELEASE_FULLCOMMIT} -X main.Branch=${COMPONENT_BRANCH} -X main.GoVersion=${GOVERSION} -s -w
@@ -71,7 +72,10 @@ init: ## Install linters
7172
cd tools && go generate -x -tags=tools
7273

7374
build: ## Build exporter binary using plain go build.
74-
go build -ldflags="$(GO_BUILD_LDFLAGS)" -o $(PMM_RELEASE_PATH)/mongodb_exporter
75+
CGO_ENABLED=0 go build -ldflags="$(GO_BUILD_LDFLAGS)" -o $(PMM_RELEASE_PATH)/mongodb_exporter
76+
77+
docker-build: build
78+
docker build -t ${NAME}:${IMAGE_TAG} .
7579

7680
build-gssapi: ## Build exporter binary with GSSAPI support (requires CGO enabled).
7781
CGO_ENABLED=1 go build -ldflags="$(GO_BUILD_LDFLAGS)" -tags gssapi -o $(PMM_RELEASE_PATH)/mongodb_exporter

0 commit comments

Comments
 (0)