-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
144 lines (119 loc) · 4.55 KB
/
Makefile
File metadata and controls
144 lines (119 loc) · 4.55 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# GO_VERSION:=$(shell go version)
# .PHONY: all clean bench bench-all profile lint test contributors update install
.PHONY: deps test coverage
ROOTDIR = $(eval ROOTDIR := $(shell git rev-parse --show-toplevel))$(ROOTDIR)
GITHUB_ACCESS_TOKEN = $(eval GITHUB_ACCESS_TOKEN := $(shell pass github.api.ro.token))$(GITHUB_ACCESS_TOKEN)
GITHUB_SHA = $(eval GITHUB_SHA := $(shell git rev-parse HEAD))$(GITHUB_SHA)
GITHUB_URL = https://github.com/AthenZ/authorization-proxy
EMAIL = cncf-athenz-maintainers@lists.cncf.io
DOCKERFILE = $(ROOTDIR)/Dockerfile
DOCKER_EXTRA_OPTS = ""
DOCKER_BUILDER_NAME = "athenz-builder"
DOCKER_BUILDER_DRIVER = "docker-container"
DOCKER_BUILDER_PLATFORM = "linux/amd64"
DOCKER_IMAGE_REPO = AthenZ
DOCKER_IMAGE_NAME = authorization-proxy
VERSION = latest
GOPATH := $(eval GOPATH := $(shell go env GOPATH))$(GOPATH)
GOLINES_MAX_WIDTH ?= 200
# all: clean install lint test bench
# clean:
# go clean -modcache
# rm -rf ./*.log
# rm -rf ./*.svg
# rm -rf ./go.mod
# rm -rf ./go.sum
# rm -rf bench
# rm -rf pprof
# rm -rf vendor
# cp go.mod.default go.mod
# bench: clean init
# go test -count=5 -run=NONE -bench . -benchmem
# init:
# GO111MODULE=on go mod init
# GO111MODULE=on go mod vendor
# sleep 3
deps:
rm -f ./go.sum
cp ./go.mod.default ./go.mod
GO111MODULE=on go mod tidy
# lint:
# gometalinter --enable-all . | rg -v comment
test:
go test -v -race ./...
coverage:
go test -v -race -covermode=atomic -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
rm -f coverage.out
# contributors:
# git log --format='%aN <%aE>' | sort -fu > CONTRIBUTORS
# docker-push:
# sudo docker build --pull=true --file=Dockerfile -t docker.io/athenz/authorization-proxy:latest .
# sudo docker push docker.io/athenz/authorization-proxy:latest
check-license-header:
# go install github.com/apache/skywalking-eyes/cmd/license-eye@latest
license-eye -c .licenserc.yaml header check
# license-eye -c .licenserc.yaml header fix
docker_build:
@make DOCKER_BUILDER_NAME=$(DOCKER_BUILDER_NAME) create_buildx
$(eval TMP_DIR := $(shell mktemp -d))
@echo $(GITHUB_ACCESS_TOKEN) > $(TMP_DIR)/gat
@chmod 600 $(TMP_DIR)/gat
DOCKER_BUILDKIT=1 docker buildx build \
--allow "network.host" \
--build-arg BUILDKIT_MULTI_PLATFORM=1 \
--build-arg EMAIL="$(EMAIL)" \
--builder "$(DOCKER_BUILDER_NAME)" \
--label org.opencontainers.image.revision="$(GITHUB_SHA)" \
--label org.opencontainers.image.source="$(GITHUB_URL)" \
--label org.opencontainers.image.title="$(DOCKER_IMAGE_REPO)/$(DOCKER_IMAGE_NAME)" \
--label org.opencontainers.image.url="$(GITHUB_URL)" \
--label org.opencontainers.image.version="$(VERSION)" \
--memory 32G \
--memory-swap 32G \
--network=host \
--output type=registry,oci-mediatypes=true,compression=zstd,compression-level=5,force-compression=true,push=true \
--platform $(DOCKER_BUILDER_PLATFORM) \
--attest type=sbom,generator=docker/buildkit-syft-scanner:edge \
--provenance=mode=max \
-t "$(DOCKER_IMAGE_REPO)/$(DOCKER_IMAGE_NAME):$(VERSION)" \
-f $(DOCKERFILE) .
docker buildx rm --force "$(DOCKER_BUILDER_NAME)"
@rm -rf $(TMP_DIR)
init_buildx:
docker run \
--network=host \
--privileged \
--rm tonistiigi/binfmt:master \
--install $(DOCKER_BUILDER_PLATFORM)
create_buildx:
-docker buildx rm --force $(DOCKER_BUILDER_NAME)
docker buildx create --use \
--name $(DOCKER_BUILDER_NAME) \
--driver $(DOCKER_BUILDER_DRIVER) \
--driver-opt=image=moby/buildkit:master \
--driver-opt=network=host \
--buildkitd-flags="--oci-worker-gc=false --oci-worker-snapshotter=stargz" \
--platform $(DOCKER_BUILDER_PLATFORM) \
--bootstrap
# make add_nodes
docker buildx ls
docker buildx inspect --bootstrap $(DOCKER_BUILDER_NAME)
sudo chown -R $(USER):$(GROUP_ID) "$(HOME)/.docker"
remove_buildx:
-docker buildx rm --force --all-inactive
sudo rm -rf $(HOME)/.docker/buildx
docker buildx ls
do_build:
@make DOCKERFILE="$(ROOTDIR)/Dockerfile" NAME="$(NAME)" DOCKER_BUILDER_NAME="$(DOCKER_BUILDER_NAME)-$(NAME)" docker_build
build: \
remove_buildx \
init_buildx \
create_buildx
@make NAME="authorization-proxy" do_build
@make remove_buildx
format:
find ./ -type d -name .git -prune -o -type f -regex '.*[^\.pb]\.go' -print | xargs $(GOPATH)/bin/golines -w -m $(GOLINES_MAX_WIDTH)
find ./ -type d -name .git -prune -o -type f -regex '.*[^\.pb]\.go' -print | xargs $(GOPATH)/bin/gofumpt -w
find ./ -type d -name .git -prune -o -type f -regex '.*[^\.pb]\.go' -print | xargs $(GOPATH)/bin/strictgoimports -w
find ./ -type d -name .git -prune -o -type f -regex '.*\.go' -print | xargs $(GOPATH)/bin/goimports -w