prometheus-docker-labels-di.../Makefile

61 lines
1.6 KiB
Makefile
Raw Normal View History

2021-02-02 21:21:12 +01:00
2021-09-13 15:24:52 +02:00
VERSION=v1.0.2
2021-02-02 21:21:12 +01:00
GOOS=linux
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOLINT=golangci-lint run
2021-09-13 15:24:52 +02:00
BUILD_PLATFORM=linux/amd64
PACKAGE_PLATFORM=$(BUILD_PLATFORM),linux/arm64,linux/arm/v7
2021-02-02 21:21:12 +01:00
VERSION_MAJOR=$(shell echo $(VERSION) | cut -f1 -d.)
VERSION_MINOR=$(shell echo $(VERSION) | cut -f2 -d.)
BINARY_NAME=prometheus-docker-labels-discovery
GO_PACKAGE=sqooba/prometheus-docker-labels-discovery
DOCKER_REGISTRY=
GIT_COMMIT=$(shell git rev-parse HEAD)
GIT_DIRTY=$(shell test -n "`git status --porcelain`" && echo "+CHANGES" || true)
BUILD_DATE=$(shell date '+%Y-%m-%d-%H:%M:%S')
ensure:
GOOS=${GOOS} $(GOCMD) mod vendor
clean:
$(GOCLEAN)
lint:
$(GOLINT) ...
build:
GOOS=${GOOS} $(GOBUILD) \
-ldflags "-X version.GitCommit=${GIT_COMMIT}${GIT_DIRTY} \
2021-09-13 15:24:52 +02:00
-X github.com/sqooba/go-common/version.BuildDate=${BUILD_DATE} \
-X github.com/sqooba/go-common/version.Version=${VERSION}" \
2021-02-02 21:21:12 +01:00
-o ${BINARY_NAME} .
2021-09-13 15:24:52 +02:00
2021-02-02 21:21:12 +01:00
package:
2021-09-13 15:24:52 +02:00
docker buildx build -f Dockerfile \
--platform $(BUILD_PLATFORM) \
--build-arg VERSION=$(VERSION) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
-t ${DOCKER_REGISTRY}${GO_PACKAGE}:$(VERSION) \
-t ${DOCKER_REGISTRY}${GO_PACKAGE}:$(VERSION_MAJOR).$(VERSION_MINOR) \
-t ${DOCKER_REGISTRY}${GO_PACKAGE}:$(VERSION_MAJOR) \
--load --no-cache \
.
2021-02-02 21:21:12 +01:00
test:
go test ./...
release:
2021-09-13 15:24:52 +02:00
docker buildx build -f Dockerfile \
--platform $(PACKAGE_PLATFORM) \
--build-arg VERSION=$(VERSION) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
-t ${DOCKER_REGISTRY}${GO_PACKAGE}:$(VERSION) \
-t ${DOCKER_REGISTRY}${GO_PACKAGE}:$(VERSION_MAJOR).$(VERSION_MINOR) \
-t ${DOCKER_REGISTRY}${GO_PACKAGE}:$(VERSION_MAJOR) \
--push \
.