-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
70 lines (54 loc) · 2.16 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
################################################################################
## VERSION PARAMS ##
################################################################################
## Docker Build Versions
DOCKER_BUILD_IMAGE = golang:1.17.3
DOCKER_BASE_IMAGE = alpine:3.14
################################################################################
GO ?= $(shell command -v go 2> /dev/null)
CLOUD_BLACKBOX_TARGET_DISCOVERY_IMAGE ?= mattermost/cloud-blackbox-target-discovery:test
MACHINE = $(shell uname -m)
GOFLAGS ?= $(GOFLAGS:)
BUILD_TIME := $(shell date -u +%Y%m%d.%H%M%S)
BUILD_HASH := $(shell git rev-parse HEAD)
################################################################################
LOGRUS_URL := github.com/sirupsen/logrus
LOGRUS_VERSION := $(shell find go.mod -type f -exec cat {} + | grep ${LOGRUS_URL} | awk '{print $$NF}')
LOGRUS_PATH := $(GOPATH)/pkg/mod/${LOGRUS_URL}\@${LOGRUS_VERSION}
export GO111MODULE=on
all: check-style dist
## Runs govet and gofmt against all packages.
.PHONY: check-style
check-style: govet lint
@echo Checking for style guide compliance
## Runs lint against all packages.
.PHONY: lint
lint:
@echo Running lint
env GO111MODULE=off $(GO) get -u golang.org/x/lint/golint
golint -set_exit_status ./...
@echo lint success
## Runs govet against all packages.
.PHONY: vet
govet:
@echo Running govet
$(GO) vet ./...
@echo Govet success
## Builds and thats all :)
.PHONY: dist
dist: build
.PHONY: build
build: ## Build the cloud-blackbox-target-discovery
@echo Building Cloud-Blackbox-Target-Discovery
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 $(GO) build -gcflags all=-trimpath=$(PWD) -asmflags all=-trimpath=$(PWD) -a -installsuffix cgo -o build/_output/bin/main ./
.PHONY: build-image
build-image: ## Build the docker image for cloud-blackbox-target-discovery
@echo Building Cloud-Blackbox-Target-Discovery Docker Image
docker build \
--build-arg DOCKER_BUILD_IMAGE=$(DOCKER_BUILD_IMAGE) \
--build-arg DOCKER_BASE_IMAGE=$(DOCKER_BASE_IMAGE) \
. -f build/Dockerfile -t $(CLOUD_BLACKBOX_TARGET_DISCOVERY_IMAGE) \
--no-cache
.PHONY: install
install: build
go install ./...