forked from AVENTER-UG/mesos-compose
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
70 lines (54 loc) · 2.06 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
#Dockerfile vars
#vars
IMAGENAME=mesos-compose
REPO=avhost
TAG=$(shell git describe --tags --abbrev=0)
BRANCH=$(shell git symbolic-ref --short HEAD | xargs basename)
BRANCHSHORT=$(shell echo ${BRANCH} | awk -F. '{ print $$1"."$$2 }')
BUILDDATE=$(shell date -u +%Y%m%d)
IMAGEFULLNAME=${REPO}/${IMAGENAME}
LASTCOMMIT=$(shell git log -1 --pretty=short | tail -n 1 | tr -d " " | tr -d "UPDATE:")
.PHONY: help build all docs
.DEFAULT_GOAL := all
ifeq (${BRANCH}, master)
BRANCH=latest
BRANCHSHORT=latest
endif
build:
@echo ">>>> Build Docker: latest"
@docker build --build-arg TAG=${TAG} --build-arg BUILDDATE=${BUILDDATE} -t ${IMAGEFULLNAME}:latest .
build-bin:
@echo ">>>> Build binary"
@CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags "-X main.BuildVersion=${BUILDDATE} -X main.GitVersion=${TAG} -extldflags \"-static\"" .
push:
@echo ">>>> Publish docker image: " ${BRANCH}
@docker buildx create --use --name buildkit
@docker buildx build --sbom=true --provenance=true --platform linux/amd64,linux/arm64 --push --build-arg TAG=${BRANCH} --build-arg BUILDDATE=${BUILDDATE} -t ${IMAGEFULLNAME}:${BRANCH} .
@docker buildx build --sbom=true --provenance=true --platform linux/amd64,linux/arm64 --push --build-arg TAG=${BRANCH} --build-arg BUILDDATE=${BUILDDATE} -t ${IMAGEFULLNAME}:${BRANCHSHORT} .
@docker buildx build --sbom=true --provenance=true --platform linux/amd64,linux/arm64 --push --build-arg TAG=${BRANCH} --build-arg BUILDDATE=${BUILDDATE} -t ${IMAGEFULLNAME}:latest .
@docker buildx rm buildkit
update-gomod:
go get -u
go mod tidy
plugin:
@echo ">>> Build plugins"
cd plugins; $(MAKE)
docs:
@echo ">>>> Build docs"
$(MAKE) -C $@
sboom:
syft dir:. > sbom.txt
syft dir:. -o json > sbom.json
seccheck:
grype --add-cpes-if-none .
imagecheck:
trivy image ${IMAGEFULLNAME}:latest
go-fmt:
@gofmt -w .
version:
@echo ">>>> Generate version file"
@echo "[{ \"version\":\"${TAG}\", \"builddate\":\"${BUILDDATE}\" }]" > .version.json
@cat .version.json
@echo "Saved under .version.json"
check: go-fmt sboom seccheck
all: check build imagecheck version