-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
82 lines (70 loc) · 2.21 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
TARGET := k3se
SOURCES := $(shell find . -name "*.go")
PLATFORM ?= $(shell go version | cut -d " " -f 4)
GOOS := $(shell echo $(PLATFORM) | cut -d "/" -f 1)
GOARCH := $(shell echo $(PLATFORM) | cut -d "/" -f 2)
SUFFIX := $(GOOS)-$(GOARCH)
VERSION ?= $(shell git describe --always --tags --dirty)
BUILD_FLAGS := -ldflags="-s -w -X github.com/nicklasfrahm/$(TARGET)/cmd.version=$(VERSION)"
# Adjust the binary name on Windows.
ifeq ($(GOOS),windows)
SUFFIX = $(GOOS)-$(GOARCH).exe
endif
build: bin/$(TARGET)-$(SUFFIX)
bin/$(TARGET)-$(SUFFIX): $(SOURCES)
@mkdir -p $(@D)
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build $(BUILD_FLAGS) -o $@ main.go
ifdef UPX
upx -qq $(UPX) $@
endif
.PHONY: vagrant-up
vagrant-up:
cd deploy/vagrant; vagrant up
.PHONY: vagrant-down
vagrant-down:
cd deploy/vagrant; vagrant destroy -f
/usr/local/bin/$(TARGET): bin/$(TARGET)-$(SUFFIX)
@sudo cp $^ $@
@sudo chmod 755 $@
.PHONY: install
install: /usr/local/bin/$(TARGET)
.PHONY: uninstall
uninstall:
@sudo rm -f /usr/local/bin/$(TARGET)
.PHONY: docker
docker:
@docker build \
-t $(TARGET):latest \
-t $(TARGET):$(VERSION) \
--build-arg VERSION=$(VERSION) \
-f build/package/Dockerfile .
@if command -v trivy >/dev/null; then trivy image $(TARGET); fi
.PHONY: clean
clean:
@rm -rvf bin
.PHONY: demo-up
demo-up: install
@echo -n "\e[35m==>\e[0m "
k3se up deploy/demo/k3se.yaml
@echo -n "\e[35m==>\e[0m "
kubectx [email protected]
@echo -n "\e[35m==>\e[0m "
kubectl create ns traefik --dry-run=client -o yaml | kubectl apply -f -
@echo -n "\e[35m==>\e[0m "
helm dependency update deploy/demo/traefik
@echo -n "\e[35m==>\e[0m "
helm upgrade --install traefik deploy/demo/traefik --namespace traefik
@echo -n "\e[35m==>\e[0m "
kubectl create ns cert-manager --dry-run=client -o yaml | kubectl apply -f -
@echo -n "\e[35m==>\e[0m "
helm dependency update deploy/demo/cert-manager
@echo -n "\e[35m==>\e[0m "
helm upgrade --install cert-manager deploy/demo/cert-manager --namespace cert-manager
@echo -n "\e[35m==>\e[0m "
kubectl apply -f deploy/demo/clusterissuers
@echo -n "\e[35m==>\e[0m "
kubectl apply -f deploy/demo/app
.PHONY: demo-down
demo-down:
@echo -n "\e[35m==>\e[0m "
k3se down deploy/demo/k3se.yaml