git.iko.soy/typeable/oauth2-proxy
on 4ee3f13 help sign in
111 lines 3.8 kB history raw
1GO ?= go
2GOLANGCILINT ?= golangci-lint
4BINARY := oauth2-proxy
5VERSION ?= $(shell git describe --always --dirty --tags 2>/dev/null || echo "undefined")
6# Allow to override image registry.
7REGISTRY ?= quay.io/oauth2-proxy
8.NOTPARALLEL:
10GO_MAJOR_VERSION = $(shell $(GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1)
11GO_MINOR_VERSION = $(shell $(GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2)
12MINIMUM_SUPPORTED_GO_MAJOR_VERSION = 1
13MINIMUM_SUPPORTED_GO_MINOR_VERSION = 15
14GO_VERSION_VALIDATION_ERR_MSG = Golang version is not supported, please update to at least $(MINIMUM_SUPPORTED_GO_MAJOR_VERSION).$(MINIMUM_SUPPORTED_GO_MINOR_VERSION)
16ifeq ($(COVER),true)
17TESTCOVER ?= -coverprofile c.out
18endif
20.PHONY: all
21all: lint $(BINARY)
23.PHONY: clean
24clean:
25 -rm -rf release
26 -rm -f $(BINARY)
28.PHONY: distclean
29distclean: clean
30 rm -rf vendor
32.PHONY: lint
33lint: validate-go-version
34 GO111MODULE=on $(GOLANGCILINT) run
36.PHONY: build
37build: validate-go-version clean $(BINARY)
39$(BINARY):
40 CGO_ENABLED=0 $(GO) build -a -installsuffix cgo -ldflags="-X main.VERSION=${VERSION}" -o $@ github.com/oauth2-proxy/oauth2-proxy/v7
42DOCKER_BUILD_PLATFORM ?= linux/amd64,linux/arm64,linux/arm/v6
43DOCKER_BUILDX_ARGS ?=
44DOCKER_BUILD := docker build --build-arg VERSION=${VERSION}
45DOCKER_BUILDX := docker buildx build ${DOCKER_BUILDX_ARGS} --platform ${DOCKER_BUILD_PLATFORM} --build-arg VERSION=${VERSION}
47.PHONY: docker
48docker:
49 $(DOCKER_BUILDX) -f Dockerfile -t $(REGISTRY)/oauth2-proxy:latest .
51.PHONY: docker-all
52docker-all: docker
53 $(DOCKER_BUILD) -f Dockerfile -t $(REGISTRY)/oauth2-proxy:latest-amd64 .
54 $(DOCKER_BUILD) -f Dockerfile -t $(REGISTRY)/oauth2-proxy:${VERSION} .
55 $(DOCKER_BUILD) -f Dockerfile -t $(REGISTRY)/oauth2-proxy:${VERSION}-amd64 .
56 $(DOCKER_BUILD) -f Dockerfile.arm64 -t $(REGISTRY)/oauth2-proxy:latest-arm64 .
57 $(DOCKER_BUILD) -f Dockerfile.arm64 -t $(REGISTRY)/oauth2-proxy:${VERSION}-arm64 .
58 $(DOCKER_BUILD) -f Dockerfile.armv6 -t $(REGISTRY)/oauth2-proxy:latest-armv6 .
59 $(DOCKER_BUILD) -f Dockerfile.armv6 -t $(REGISTRY)/oauth2-proxy:${VERSION}-armv6 .
61.PHONY: docker-push
62docker-push:
63 docker buildx build --push --platform ${DOCKER_BUILD_PLATFORM} -t $(REGISTRY)/oauth2-proxy:latest .
65.PHONY: docker-push-all
66docker-push-all: docker-push
67 docker push $(REGISTRY)/oauth2-proxy:latest-amd64
68 docker push $(REGISTRY)/oauth2-proxy:${VERSION}
69 docker push $(REGISTRY)/oauth2-proxy:${VERSION}-amd64
70 docker push $(REGISTRY)/oauth2-proxy:latest-arm64
71 docker push $(REGISTRY)/oauth2-proxy:${VERSION}-arm64
72 docker push $(REGISTRY)/oauth2-proxy:latest-armv6
73 docker push $(REGISTRY)/oauth2-proxy:${VERSION}-armv6
75.PHONY: generate
76generate:
77 go generate ./pkg/...
79.PHONY: verify-generate
80verify-generate: generate
81 git diff --exit-code
83.PHONY: test
84test: lint
85 GO111MODULE=on $(GO) test $(TESTCOVER) -v -race ./...
87.PHONY: release
88release: validate-go-version lint test
89 BINARY=${BINARY} VERSION=${VERSION} ./dist.sh
91.PHONY: validate-go-version
92validate-go-version:
93 @if [ $(GO_MAJOR_VERSION) -gt $(MINIMUM_SUPPORTED_GO_MAJOR_VERSION) ]; then \
94 exit 0 ;\
95 elif [ $(GO_MAJOR_VERSION) -lt $(MINIMUM_SUPPORTED_GO_MAJOR_VERSION) ]; then \
96 echo '$(GO_VERSION_VALIDATION_ERR_MSG)';\
97 exit 1; \
98 elif [ $(GO_MINOR_VERSION) -lt $(MINIMUM_SUPPORTED_GO_MINOR_VERSION) ] ; then \
99 echo '$(GO_VERSION_VALIDATION_ERR_MSG)';\
100 exit 1; \
101 fi
103# local-env can be used to interact with the local development environment
104# eg:
105# make local-env-up # Bring up a basic test environment
106# make local-env-down # Tear down the basic test environment
107# make local-env-nginx-up # Bring up an nginx based test environment
108# make local-env-nginx-down # Tead down the nginx based test environment
109.PHONY: local-env-%
110local-env-%:
111 make -C contrib/local-environment $*