-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
76 lines (57 loc) · 2.29 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
71
72
73
74
75
#Dockerfile vars
#vars
IMAGENAME=mesos-m3s
TAG=$(shell git describe)
BUILDDATE=$(shell date -u +%Y%m%d)
IMAGEFULLNAME=avhost/${IMAGENAME}
BRANCH=$(shell git symbolic-ref --short HEAD | xargs basename)
BRANCHSHORT=$(shell echo ${BRANCH} | awk -F. '{ print $1"."$2 }')
VERSION_URL=https://raw.githubusercontent.com/AVENTER-UG/mesos-m3s/${BRANCH}/.version.json
LASTCOMMIT=$(shell git log -1 --pretty=short | tail -n 1 | tr -d " " | tr -d "UPDATE:")
.PHONY: help build bootstrap all docs publish push version
.DEFAULT_GOAL := all
ifeq (${BRANCH}, master)
BRANCH=latest
BRANCHSHORT=latest
endif
build:
@echo ">>>> Build docker image branch:" ${BRANCH}
@docker build --build-arg TAG=${TAG} --build-arg BUILDDATE=${BUILDDATE} --build-arg VERSION_URL=${VERSION_URL} -t ${IMAGEFULLNAME}:${BRANCH} .
build-bin:
@echo ">>>> Build binary"
@CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags "-X main.BuildVersion=${BUILDDATE} -X main.GitVersion=${TAG} -X main.VersionURL=${VERSION_URL} -extldflags \"-static\"" .
controller-bin:
@echo ">>>> Build controller"
$(MAKE) -C controller_bin/
@cp controller_bin/controller.amd64 bootstrap/
push:
@echo ">>>> Publish docker image" ${BRANCH}
@docker buildx create --use --name buildkit
@docker buildx build --sbom=true --provenance=true --platform linux/arm64,linux/amd64 --push --build-arg TAG=${TAG} --build-arg BUILDDATE=${BUILDDATE} --build-arg VERSION_URL=${VERSION_URL} -t ${IMAGEFULLNAME}:${BRANCH} .
@docker buildx build --sbom=true --provenance=true --platform linux/arm64,linux/amd64 --push --build-arg TAG=${TAG} --build-arg BUILDDATE=${BUILDDATE} --build-arg VERSION_URL=${VERSION_URL} -t ${IMAGEFULLNAME}:${BRANCHSHORT} .
@docker buildx rm buildkit
docs:
@echo ">>>> Build docs"
$(MAKE) -C $@
plugin:
@echo ">>> Build plugins"
cd plugins; $(MAKE)
update-gomod:
go get -u
go mod tidy
seccheck:
grype --add-cpes-if-none .
sboom:
syft dir:. > sbom.txt
syft dir:. -o json > sbom.json
imagecheck: build
trivy image ${IMAGEFULLNAME}:${BRANCH}
go-fmt:
@gofmt -w .
version:
@echo ">>>> Generate version file"
@echo "{\"m3sVersion\": { \"gitVersion\": \"${TAG}\", \"buildDate\": \"${BUILDDATE}\"}}" > .version.json
@cat .version.json
@echo "Saved under .version.json"
check: go-fmt sboom seccheck imagecheck
all: check version controller-bin build