-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
83 lines (67 loc) · 3.65 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
codeSHELL=/bin/bash -o pipefail
export VERSION=2.5.1
.PHONY: all
all: trivy
.DEFAULT_GOAL := help
#TRIVY := $(shell curl --silent https://api.github.com/repos/aquasecurity/trivy/releases/latest | jq -r .name | cut -d "v" -f2)
TRIVY := 0.36.1
BENCH := $(shell curl --silent https://api.github.com/repos/aquasecurity/kube-bench/releases/latest | jq -r .name | cut -d "v" -f2)
#help: @ List available tasks on this project
help:
@grep -E '[a-zA-Z\.\-]+:.*?@ .*$$' $(MAKEFILE_LIST)| tr -d '#' | awk 'BEGIN {FS = ":.*?@ "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
#bins: @ download binaris
bins:
@if [ ! -f /tmp/trivy ]; then \
echo "Get Trivy Version:"; \
echo $(TRIVY); \
wget -q -O /tmp/trivy.tar.gz https://github.com/aquasecurity/trivy/releases/download/v$(TRIVY)/trivy_"$(TRIVY)"_Linux-64bit.tar.gz; \
echo "Extract Trivy"; \
tar -C /tmp -xf /tmp/trivy.tar.gz; \
fi
@if [ ! -f /tmp/kube-bench ]; then \
echo "Get kube-bench Version"; \
echo $(BENCH); \
wget -q -O /tmp/kube-bench.tar.gz https://github.com/aquasecurity/kube-bench/releases/download/v$(BENCH)/kube-bench_"$(BENCH)"_linux_amd64.tar.gz; \
tar -C /tmp -xf /tmp/kube-bench.tar.gz; \
fi
rm -f docker/trivy-operator/trivy docker/kube-bench-scnner/kube-bench
cp /tmp/trivy docker/trivy-operator/trivy
cp /tmp/kube-bench docker/kube-bench-scnner/kube-bench
#to-devel: @ Build local trivy-operator devel image with nerdctl
to-devel:
cp trivy-operator.py docker/trivy-operator/trivy-operator.py
nerdctl --namespace k8s.io build --tag devopstales/trivy-operator:$(VERSION)-devel docker/trivy-operator
rm -f docker/trivy-operator/trivy-operator.py
#to-devel-delete: @ Delete local trivy-operator dev image with nerdctl
to-devel-delete:
#nerdctl --namespace k8s.io image ls | grep devopstales | grep trivy-operator | grep $(VERSION)-devel | awk '{print "nerdctl --namespace k8s.io rmi "$$3}' | bash
nerdctl --namespace k8s.io rmi devopstales/trivy-operator:$(VERSION)-devel
#kbs-devel: @ Build local kube-bench-scnner devel image with nerdctl
kbs-devel:
cp kube-bench-scnner.py docker/kube-bench-scnner/kube-bench-scnner.py
nerdctl --namespace k8s.io build --tag devopstales/kube-bench-scnner:$(VERSION)-devel docker/kube-bench-scnner
rm -f docker/kube-bench-scnner/kube-bench-scnner.py
#kbs-devel-delete: @ Delete local kube-bench-scnner dev image with nerdctl
kbs-devel-delete:
#nerdctl --namespace k8s.io image ls | grep devopstales | grep kube-bench-scnner | grep $(VERSION)-devel | awk '{print "nerdctl --namespace k8s.io rmi "$$3}' | bash
nerdctl --namespace k8s.io rmi devopstales/kube-bench-scnner:$(VERSION)-devel
version:
cp trivy-operator.py docker/trivy-operator.py
docker build -t devopstales/trivy-operator:$(VERSION)-amd64 --build-arg ARCH=amd64/ docker/
docker build -t devopstales/trivy-operator:$(VERSION)-arm64v8 --build-arg ARCH=arm64v8/ docker/
rm -f docker/trivy-operator.py
# docker build -t devopstales/trivy-operator:$(VERSION)-arm32v7 --build-arg ARCH=arm32v7/ docker/
push-version:
docker push devopstales/trivy-operator:$(VERSION)-amd64
docker push devopstales/trivy-operator:$(VERSION)-arm64v8
docker manifest create devopstales/trivy-operator:$(VERSION) \
--amend devopstales/trivy-operator:$(VERSION)-amd64 \
--amend devopstales/trivy-operator:$(VERSION)-arm64v8
docker manifest push devopstales/trivy-operator:$(VERSION)
# docker push devopstales/trivy-operator:$(VERSION)-arm32v7
push-latest:
docker manifest create devopstales/trivy-operator:latest \
--amend devopstales/trivy-operator:$(VERSION)-amd64 \
--amend devopstales/trivy-operator:$(VERSION)-arm64v8
docker manifest push devopstales/trivy-operator:latest
# --amend devopstales/trivy-operator:$(VERSION)-arm32v7 \