-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
57 lines (43 loc) · 1.49 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
# virtual-kubelet-saladcloud
# Standard Development Targets
# build - build the project, binaries go into ./bin
# build-image - build a Docker image with the virtual-kubelet binary
# clean - clean up built binaries and cached Go artifacts
# lint - run golangci-lint (set args in LINT_ARGS)
# tidy - "go mod tidy"
IMAGE_TAG ?= latest
CMDS := bin/virtual-kubelet
# The conventional BUILD_VERSION is not very useful at the moment since we are not tagging the repo
# Use the sha for the build as a version for now.
# BUILD_VERSION ?= $(shell git describe --tags --always --dirty="-dev")
BUILD_VERSION ?= $(shell git rev-parse --short HEAD)
# It seems more useful to have the commit date than the build date for ordering versions
# since commit shas have no order
# BUILD_DATE ?= $(shell date -u '+%Y-%m-%d-%H:%M UTC')
BUILD_DATE ?= $(shell git log -1 --format=%cd --date=format:"%Y%m%d")
VERSION_FLAGS := -ldflags='-X "main.buildVersion=$(BUILD_VERSION)" -X "main.buildTime=$(BUILD_DATE)"'
.PHONY: build
build: $(CMDS)
.PHONY: build-image
build-image:
docker build \
--tag ghcr.io/saladtechnologies/virtual-kubelet-saladcloud:$(IMAGE_TAG) \
--file docker/Dockerfile \
--build-arg VERSION_FLAGS=$(VERSION_FLAGS) \
.
.PHONY: clean
clean:
rm $(CMDS)
go clean
.PHONY: lint
lint:
golangci-lint run ./... $(LINT_ARGS)
.PHONY: test
test:
go test -v ./...
tidy:
go mod tidy
bin/virtual-kubelet:
bin/%: CGO_ENABLED=0
bin/%:
go build -ldflags '-extldflags "-static"' -o bin/$(*) $(VERSION_FLAGS) ./cmd/$(*)