-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
74 lines (57 loc) · 2.27 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
VERSION := v0.2.5
REPOSITORY := getupcloud
IMAGE_NAME := tiny-controllers
GIT_COMMIT := $(shell git log -n1 --oneline)
GIT_COMMIT_ID := $(shell git log -n 1 --pretty=format:%h)
BUILD_DATE := $(shell LC_ALL=C date -u)
KUBECTL_VERSION := 1.25.0
all: docker-build-release help
help:
@echo Available targets:
@echo " " docker-build-release, docker-tag-latest
@echo " " docker-push-release, docker-push-latest
@echo " " git-tag-release, git-push-main, git-push-release
@echo " " dev, dev-run, test
release: check-dirty docker-build-release docker-tag-latest git-tag-release git-push-main git-push-release docker-push-release docker-push-latest
check-dirty: DIFF_STATUS := $(shell git diff --stat)
check-dirty:
@if [ -n "$(DIFF_STATUS)" ]; then \
echo "--> Refusing to build release on a dirty tree"; \
echo "--> Commit and try again."; \
exit 2; \
fi
docker-build-release:
docker build . -t $(REPOSITORY)/$(IMAGE_NAME):$(VERSION) \
--build-arg VERSION="$(VERSION)" \
--build-arg BUILD_DATE="$(BUILD_DATE)" \
--build-arg GIT_COMMIT="$(GIT_COMMIT)" \
--build-arg GIT_COMMIT_ID="$(GIT_COMMIT_ID)" \
--build-arg KUBECTL_VERSION="$(KUBECTL_VERSION)"
docker-tag-latest:
docker tag $(REPOSITORY)/$(IMAGE_NAME):$(VERSION) $(REPOSITORY)/$(IMAGE_NAME):latest
git-tag-release:
git tag $(VERSION)
git-push-main:
git push origin main
git-push-release:
git push origin $(VERSION)
docker-push-release:
docker push $(REPOSITORY)/$(IMAGE_NAME):$(VERSION)
docker-push-latest:
docker push $(REPOSITORY)/$(IMAGE_NAME):latest
## LOCAL DEV
docker-build-dev:
docker build . -t $(REPOSITORY)/$(IMAGE_NAME):$(VERSION) \
--build-arg VERSION="dev" \
--build-arg KUBECTL_VERSION="$(KUBECTL_VERSION)"
dev: VERSION := $(VERSION)-dev
dev: tls/tls.crt docker-build-dev dev-run
tls/tls.crt:
mkdir -p tls
[ -e tls/tls.crt -a -e tls/tls.key ] || openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -subj /CN=dev/ -keyout tls/tls.key -out tls/tls.crt
chmod -R a+r tls
dev-run: VERSION := $(VERSION)-dev
dev-run: tls
docker run -it --rm --name $(IMAGE_NAME)-$(VERSION) --network=host -u root -e KUBECONFIG=/.kube/config -v $(PWD)/dev-kubeconfig:/.kube/config -v $(PWD)/tls:/etc/tls/ $(REPOSITORY)/$(IMAGE_NAME):$(VERSION) $(RECONCILER)
test:
make -C tests