-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
112 lines (89 loc) · 3.62 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# Where to install the CLI tool binaries to
PREFIX ?= /usr/local
GOPATH = $(shell go env GOPATH)
GOGEN = go generate .
GET_SEMVERSION = awk '{match($$0,/const\s+SemVersion\s+=\s+"(.*)"/,m);if (m[1]!="") print m[1]}' defs_version.go
export GOTOOLCHAIN=local
# Go version to use when building the test containers; see README.md for
# supported versions strategy.
goversion = 1.22 1.21
tools := dumpns lsallns lspidns lsuns nscaps pidtree lxkns
# To suckessfully run the tests, we need CRAP_SYS_ADMIN capabilities.
testcontaineropts := \
--pid host \
--cap-drop ALL \
--cap-add CAP_SYS_ADMIN \
--cap-add CAP_SYS_CHROOT \
--cap-add CAP_SYS_PTRACE \
--cap-add CAP_DAC_READ_SEARCH \
--cap-add CAP_DAC_OVERRIDE \
--cap-add CAP_SETUID \
--cap-add CAP_SETGID \
--security-opt systempaths=unconfined \
--security-opt apparmor=unconfined \
--security-opt seccomp=unconfined \
-v /sys/fs/cgroup:/sys/fs/cgroup:rw
.PHONY: clean vuln coverage deploy undeploy help install test report manual pkgsite buildapp startapp scan dist grype yarnsetup
help: ## list available targets
@# Shamelessly stolen from Gomega's Makefile
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-16s\033[0m %s\n", $$1, $$2}'
clean: ## cleans up build and testing artefacts
rm -f $(tools)
rm -f coverage.html coverage.out coverage-root.out
rm -f coverage.txt coverage-root.txt
coverage: ## gathers coverage and updates README badge
@scripts/cov.sh
manual: ## start docsify server for manual
@scripts/docsify.sh ./docs
pkgsite: ## serves Go documentation on port 6060
@echo "navigate to: http://localhost:6060/github.com/thediveo/lxkns"
@scripts/pkgsite.sh
dist: ## build multi-arch image (amd64, arm64) and push to local running registry on port 5000.
$(GOGEN)
$(eval GIT_VERSION := $(shell $(GET_SEMVERSION)))
scripts/multiarch-builder.sh \
--build-arg REACT_APP_GIT_VERSION=$(GIT_VERSION) \
--build-context webappsrc=./web/lxkns
deploy: ## deploys lxkns service on host port 5010
$(GOGEN)
$(eval GIT_VERSION := $(shell $(GET_SEMVERSION)))
scripts/docker-build.sh deployments/lxkns/Dockerfile \
-t lxkns \
--build-arg REACT_APP_GIT_VERSION=$(GIT_VERSION) \
--build-context webappsrc=./web/lxkns
docker compose -p lxkns -f deployments/lxkns/docker-compose.yaml up
undeploy: ## removes any deployed lxkns service
docker compose -p lxkns -f deployments/lxkns/docker-compose.yaml down
install: ## installs lxkns commands
$(GOGEN)
go install -v ./cmd/... ./examples/lsallns
install -t $(PREFIX)/bin $(addprefix $(GOPATH)/bin/,$(tools))
test: ## runs all tests
go test -v -p=1 -count=1 -exec sudo ./... && go test -v -p=1 -count=1 ./...
report: ## runs goreportcard
@scripts/goreportcard.sh
buildapp: ## builds web UI app
$(GOGEN)
$(eval GIT_VERSION := $(shell $(GET_SEMVERSION)))
@echo "building version" $(GIT_VERSION)
@cd web/lxkns && sed -i "s/^VITE_REACT_APP_GIT_VERSION=.*/VITE_REACT_APP_GIT_VERSION=$$GIT_VERSION/" .env && yarn build
startapp: ## starts web UI app for development
$(GOGEN)
$(eval GIT_VERSION := $(shell $(GET_SEMVERSION)))
@echo "starting version" $(GIT_VERSION)
@cd web/lxkns && sed -i "s/^VITE_REACT_APP_GIT_VERSION=.*/VITE_REACT_APP_GIT_VERSION=$$GIT_VERSION/" .env && yarn build
scan: ## scans the repository for CVEs
@scripts/scan.sh
vuln: ## run go vulnerabilities check
@scripts/vuln.sh
grype: ## run grype vul scan on sources
@scripts/grype.sh
yarnsetup: ## set up yarn v4 correctly
cd web/lxkns && \
rm -f .yarnrc.yml && \
rm -rf .yarn/ && \
rm -rf node_modules && \
yarn set version berry && \
yarn config set nodeLinker node-modules && \
yarn install && \
yarn eslint --init