forked from kube-vip/kube-vip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
84 lines (59 loc) · 2.24 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
76
77
78
79
80
81
82
83
84
SHELL := /bin/sh
# The name of the executable (default is current directory name)
TARGET := kube-vip
.DEFAULT_GOAL: $(TARGET)
# These will be provided to the target
VERSION := v0.1.7
BUILD := `git rev-parse HEAD`
# Operating System Default (LINUX)
TARGETOS=linux
# Use linker flags to provide version/build settings to the target
LDFLAGS=-ldflags "-s -w -X=main.Version=$(VERSION) -X=main.Build=$(BUILD) -extldflags -static"
# go source files, ignore vendor directory
SRC = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
DOCKERTAG ?= $(VERSION)
REPOSITORY = plndr
.PHONY: all build clean install uninstall fmt simplify check run
all: check install
$(TARGET): $(SRC)
@go build $(LDFLAGS) -o $(TARGET)
build: $(TARGET)
@true
clean:
@rm -f $(TARGET)
install:
@echo Building and Installing project
@go install $(LDFLAGS)
uninstall: clean
@rm -f $$(which ${TARGET})
fmt:
@gofmt -l -w $(SRC)
demo:
@cd demo
@docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 --push -t $(REPOSITORY)/$(TARGET):$(DOCKERTAG) .
@echo New Multi Architecture Docker image created
@cd ..
## Remote (push of images)
# This build a local docker image (x86 only) for quick testing
dockerx86:
@docker buildx build --platform linux/amd64 --push -t $(REPOSITORY)/$(TARGET):$(DOCKERTAG) .
@echo New Multi Architecture Docker image created
docker:
@docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 --push -t $(REPOSITORY)/$(TARGET):$(DOCKERTAG) .
@echo New Multi Architecture Docker image created
## Local (docker load of images)
# This will build a local docker image (x86 only), use make dockerLocal for all architectures
dockerx86Local:
@docker buildx build --platform linux/amd64 --load -t $(REPOSITORY)/$(TARGET):$(DOCKERTAG) .
@echo New Multi Architecture Docker image created
dockerLocal:
@docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 --load -t $(REPOSITORY)/$(TARGET):$(DOCKERTAG) .
@echo New Multi Architecture Docker image created
simplify:
@gofmt -s -l -w $(SRC)
check:
@test -z $(shell gofmt -l main.go | tee /dev/stderr) || echo "[WARN] Fix formatting issues with 'make fmt'"
@for d in $$(go list ./... | grep -v /vendor/); do golint $${d}; done
@go tool vet ${SRC}
run: install
@$(TARGET)