git.iko.soy/typeable/oauth2-proxy
on master help sign in
chore(build): refactoring makefile for better usability and introducing a default help target (#2930)
367183dJan Larwig
.github/workflows/ci.yml+2−2
@@ -72,10 +72,10 @@ jobs:
72 - name: Docker Build
72 - name: Docker Build
73 if: (!startsWith(github.head_ref, 'release'))
73 if: (!startsWith(github.head_ref, 'release'))
74 run: |
74 run: |
75− make docker
75+ make build-docker
76
76
77 # For release testing
77 # For release testing
78 - name: Docker Build All
78 - name: Docker Build All
79 if: github.base_ref == 'master' && startsWith(github.head_ref, 'release')
79 if: github.base_ref == 'master' && startsWith(github.head_ref, 'release')
80 run: |
80 run: |
81− make docker-all
81+ make build-docker-all
.github/workflows/nightly.yml+2−2
@@ -34,8 +34,8 @@ jobs:
34
34
35 - name: Build images
35 - name: Build images
36 run: |
36 run: |
37− make docker-nightly-build
37+ make nightly-build
38
38
39 - name: Push images
39 - name: Push images
40 run: |
40 run: |
41− make docker-nightly-push
41+ make nightly-push
.github/workflows/publish-release.yml+2−2
@@ -122,8 +122,8 @@ jobs:
122
122
123 - name: Build images
123 - name: Build images
124 run: |
124 run: |
125− make docker-all
125+ make build-docker-all
126
126
127 - name: Push images
127 - name: Push images
128 run: |
128 run: |
129− make docker-push-all
129+ make push-docker-all
Makefile+80−36
@@ -1,3 +1,29 @@
1+#!/usr/bin/env bash
2+
3+#
4+# Makefile with some common workflow for dev, build and test
5+#
6+
7+##@ General
8+
9+# The help target prints out all targets with their descriptions organized
10+# beneath their categories. The categories are represented by '##@' and the
11+# target descriptions by '##'. The awk command is responsible for reading the
12+# entire set of makefiles included in this invocation, looking for lines of the
13+# file as xyz: ## something, and then pretty-format the target and help. Then,
14+# if there's a line with ##@ something, that gets pretty-printed as a category.
15+# More info on the usage of ANSI control characters for terminal formatting:
16+# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
17+# More info on the awk command:
18+# http://linuxcommand.org/lc3_adv_awk.php
19+
20+# The following help command is Licensed under the Apache License, Version 2.0 (the "License")
21+# Copyright 2023 The Kubernetes Authors.
22+.PHONY: help
23+help: ## Display this help
24+ @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
25+
26+
1GO ?= go
27GO ?= go
2GOLANGCILINT ?= golangci-lint
28GOLANGCILINT ?= golangci-lint
3
29
@@ -22,24 +48,10 @@ ifeq ($(COVER),true)
22TESTCOVER ?= -coverprofile c.out
48TESTCOVER ?= -coverprofile c.out
23endif
49endif
24
50
25−.PHONY: all
51+##@ Build
26−all: lint $(BINARY)
27−
28−.PHONY: clean
29−clean:
30− -rm -rf release
31− -rm -f $(BINARY)
32−
33−.PHONY: distclean
34−distclean: clean
35− rm -rf vendor
36−
37−.PHONY: lint
38−lint: validate-go-version
39− GO111MODULE=on $(GOLANGCILINT) run
40
52
41.PHONY: build
53.PHONY: build
42−build: validate-go-version clean $(BINARY)
54+build: validate-go-version clean $(BINARY) ## Build and create oauth2-proxy binary from current source code
43
55
44$(BINARY):
56$(BINARY):
45 CGO_ENABLED=0 $(GO) build -a -installsuffix cgo -ldflags="-X github.com/oauth2-proxy/oauth2-proxy/v7/pkg/version.VERSION=${VERSION}" -o $@ github.com/oauth2-proxy/oauth2-proxy/v7
57 CGO_ENABLED=0 $(GO) build -a -installsuffix cgo -ldflags="-X github.com/oauth2-proxy/oauth2-proxy/v7/pkg/version.VERSION=${VERSION}" -o $@ github.com/oauth2-proxy/oauth2-proxy/v7
@@ -60,60 +72,92 @@ DOCKER_BUILDX_ARGS_ALPINE ?= --build-arg RUNTIME_IMAGE=${DOCKER_BUILD
60DOCKER_BUILDX_X_PLATFORM_ALPINE := docker buildx build ${DOCKER_BUILDX_ARGS_ALPINE} --platform ${DOCKER_BUILD_PLATFORM_ALPINE}
72DOCKER_BUILDX_X_PLATFORM_ALPINE := docker buildx build ${DOCKER_BUILDX_ARGS_ALPINE} --platform ${DOCKER_BUILD_PLATFORM_ALPINE}
61DOCKER_BUILDX_PUSH_X_PLATFORM_ALPINE := $(DOCKER_BUILDX_X_PLATFORM_ALPINE) --push
73DOCKER_BUILDX_PUSH_X_PLATFORM_ALPINE := $(DOCKER_BUILDX_X_PLATFORM_ALPINE) --push
62
74
63−.PHONY: docker
75+.PHONY: build-docker
64−docker:
76+build-docker: build-distroless build-alpine ## Build multi architecture docker images in both flavours (distroless / alpine)
77+
78+.PHONY: build-distroless
79+build-distroless: ## Build multi architecture distroless based docker image
65 $(DOCKER_BUILDX_X_PLATFORM) -t $(REGISTRY)/$(REPOSITORY):latest -t $(REGISTRY)/$(REPOSITORY):${VERSION} .
80 $(DOCKER_BUILDX_X_PLATFORM) -t $(REGISTRY)/$(REPOSITORY):latest -t $(REGISTRY)/$(REPOSITORY):${VERSION} .
66− $(DOCKER_BUILDX_X_PLATFORM_ALPINE) -t $(REGISTRY)/$(REPOSITORY):latest-alpine -t $(REGISTRY)/$(REPOSITORY):${VERSION}-alpine .
67
81
68−.PHONY: docker-push
82+.PHONY: build-alpine
69−docker-push:
83+build-alpine: ## Build multi architecture alpine based docker image
70− $(DOCKER_BUILDX_PUSH_X_PLATFORM) -t $(REGISTRY)/$(REPOSITORY):latest -t $(REGISTRY)/$(REPOSITORY):${VERSION} .
71− $(DOCKER_BUILDX_PUSH_X_PLATFORM_ALPINE) -t $(REGISTRY)/$(REPOSITORY):latest-alpine -t $(REGISTRY)/$(REPOSITORY):${VERSION}-alpine .
84+ $(DOCKER_BUILDX_X_PLATFORM_ALPINE) -t $(REGISTRY)/$(REPOSITORY):latest-alpine -t $(REGISTRY)/$(REPOSITORY):${VERSION}-alpine .
72
85
73−.PHONY: docker-all
86+.PHONY: build-docker-all
74−docker-all: docker
87+build-docker-all: build-docker ## Build docker images for all supported architectures in both flavours (distroless / alpine)
75 $(DOCKER_BUILDX) --platform linux/amd64 -t $(REGISTRY)/$(REPOSITORY):latest-amd64 -t $(REGISTRY)/$(REPOSITORY):${VERSION}-amd64 .
88 $(DOCKER_BUILDX) --platform linux/amd64 -t $(REGISTRY)/$(REPOSITORY):latest-amd64 -t $(REGISTRY)/$(REPOSITORY):${VERSION}-amd64 .
76 $(DOCKER_BUILDX) --platform linux/arm64 -t $(REGISTRY)/$(REPOSITORY):latest-arm64 -t $(REGISTRY)/$(REPOSITORY):${VERSION}-arm64 .
89 $(DOCKER_BUILDX) --platform linux/arm64 -t $(REGISTRY)/$(REPOSITORY):latest-arm64 -t $(REGISTRY)/$(REPOSITORY):${VERSION}-arm64 .
77 $(DOCKER_BUILDX) --platform linux/ppc64le -t $(REGISTRY)/$(REPOSITORY):latest-ppc64le -t $(REGISTRY)/$(REPOSITORY):${VERSION}-ppc64le .
90 $(DOCKER_BUILDX) --platform linux/ppc64le -t $(REGISTRY)/$(REPOSITORY):latest-ppc64le -t $(REGISTRY)/$(REPOSITORY):${VERSION}-ppc64le .
78 $(DOCKER_BUILDX) --platform linux/arm/v7 -t $(REGISTRY)/$(REPOSITORY):latest-armv7 -t $(REGISTRY)/$(REPOSITORY):${VERSION}-armv7 .
91 $(DOCKER_BUILDX) --platform linux/arm/v7 -t $(REGISTRY)/$(REPOSITORY):latest-armv7 -t $(REGISTRY)/$(REPOSITORY):${VERSION}-armv7 .
79 $(DOCKER_BUILDX) --platform linux/s390x -t $(REGISTRY)/$(REPOSITORY):latest-s390x -t $(REGISTRY)/$(REPOSITORY):${VERSION}-s390x .
92 $(DOCKER_BUILDX) --platform linux/s390x -t $(REGISTRY)/$(REPOSITORY):latest-s390x -t $(REGISTRY)/$(REPOSITORY):${VERSION}-s390x .
80
93
94+
95+##@ Publish
96+
81−.PHONY: docker-push-all
97+.PHONY: push-docker
82−docker-push-all: docker-push
98+push-docker: push-distroless push-alpine ## Push multi architecture docker images for both flavours (distroless / alpine)
99+
100+.PHONY: push-distroless
101+push-distroless: ## Push multi architecture distroless based docker image
102+ $(DOCKER_BUILDX_PUSH_X_PLATFORM) -t $(REGISTRY)/$(REPOSITORY):latest -t $(REGISTRY)/$(REPOSITORY):${VERSION} .
103+
104+.PHONY: push-alpine
105+push-alpine: ## Push multi architecture alpine based docker image
106+ $(DOCKER_BUILDX_PUSH_X_PLATFORM_ALPINE) -t $(REGISTRY)/$(REPOSITORY):latest-alpine -t $(REGISTRY)/$(REPOSITORY):${VERSION}-alpine .
107+
108+.PHONY: push-docker-all
109+push-docker-all: push-docker ## Push docker images for all supported architectures for both flavours (distroless / alpine)
83 $(DOCKER_BUILDX_PUSH) --platform linux/amd64 -t $(REGISTRY)/$(REPOSITORY):latest-amd64 -t $(REGISTRY)/$(REPOSITORY):${VERSION}-amd64 .
110 $(DOCKER_BUILDX_PUSH) --platform linux/amd64 -t $(REGISTRY)/$(REPOSITORY):latest-amd64 -t $(REGISTRY)/$(REPOSITORY):${VERSION}-amd64 .
84 $(DOCKER_BUILDX_PUSH) --platform linux/arm64 -t $(REGISTRY)/$(REPOSITORY):latest-arm64 -t $(REGISTRY)/$(REPOSITORY):${VERSION}-arm64 .
111 $(DOCKER_BUILDX_PUSH) --platform linux/arm64 -t $(REGISTRY)/$(REPOSITORY):latest-arm64 -t $(REGISTRY)/$(REPOSITORY):${VERSION}-arm64 .
85 $(DOCKER_BUILDX_PUSH) --platform linux/ppc64le -t $(REGISTRY)/$(REPOSITORY):latest-ppc64le -t $(REGISTRY)/$(REPOSITORY):${VERSION}-ppc64le .
112 $(DOCKER_BUILDX_PUSH) --platform linux/ppc64le -t $(REGISTRY)/$(REPOSITORY):latest-ppc64le -t $(REGISTRY)/$(REPOSITORY):${VERSION}-ppc64le .
86 $(DOCKER_BUILDX_PUSH) --platform linux/arm/v7 -t $(REGISTRY)/$(REPOSITORY):latest-armv7 -t $(REGISTRY)/$(REPOSITORY):${VERSION}-armv7 .
113 $(DOCKER_BUILDX_PUSH) --platform linux/arm/v7 -t $(REGISTRY)/$(REPOSITORY):latest-armv7 -t $(REGISTRY)/$(REPOSITORY):${VERSION}-armv7 .
87 $(DOCKER_BUILDX_PUSH) --platform linux/s390x -t $(REGISTRY)/$(REPOSITORY):latest-s390x -t $(REGISTRY)/$(REPOSITORY):${VERSION}-s390x .
114 $(DOCKER_BUILDX_PUSH) --platform linux/s390x -t $(REGISTRY)/$(REPOSITORY):latest-s390x -t $(REGISTRY)/$(REPOSITORY):${VERSION}-s390x .
88
115
116+
117+##@ Nightly scheduling
118+
89−.PHONY: docker-nightly-build
119+.PHONY: nightly-build
90−docker-nightly-build:
120+nightly-build: ## Nightly build command for docker images in both flavours (distroless / alpine)
91 $(DOCKER_BUILDX_X_PLATFORM) -t $(REGISTRY)/$(REPOSITORY)-nightly:latest -t $(REGISTRY)/$(REPOSITORY)-nightly:${DATE} .
121 $(DOCKER_BUILDX_X_PLATFORM) -t $(REGISTRY)/$(REPOSITORY)-nightly:latest -t $(REGISTRY)/$(REPOSITORY)-nightly:${DATE} .
92 $(DOCKER_BUILDX_X_PLATFORM_ALPINE) -t ${REGISTRY}/$(REPOSITORY)-nightly:latest-alpine -t $(REGISTRY)/$(REPOSITORY)-nightly:${DATE}-alpine .
122 $(DOCKER_BUILDX_X_PLATFORM_ALPINE) -t ${REGISTRY}/$(REPOSITORY)-nightly:latest-alpine -t $(REGISTRY)/$(REPOSITORY)-nightly:${DATE}-alpine .
93
123
94−.PHONY: docker-nightly-push
124+.PHONY: nightly-push
95−docker-nightly-push:
125+nightly-push: ## Nightly push command for docker images in both flavours (distroless / alpine)
96 $(DOCKER_BUILDX_PUSH_X_PLATFORM) -t $(REGISTRY)/$(REPOSITORY)-nightly:latest -t $(REGISTRY)/$(REPOSITORY)-nightly:${DATE} .
126 $(DOCKER_BUILDX_PUSH_X_PLATFORM) -t $(REGISTRY)/$(REPOSITORY)-nightly:latest -t $(REGISTRY)/$(REPOSITORY)-nightly:${DATE} .
97 $(DOCKER_BUILDX_PUSH_X_PLATFORM_ALPINE) -t ${REGISTRY}/$(REPOSITORY)-nightly:latest-alpine -t $(REGISTRY)/$(REPOSITORY)-nightly:${DATE}-alpine .
127 $(DOCKER_BUILDX_PUSH_X_PLATFORM_ALPINE) -t ${REGISTRY}/$(REPOSITORY)-nightly:latest-alpine -t $(REGISTRY)/$(REPOSITORY)-nightly:${DATE}-alpine .
98
128
129+
130+##@ Docs
131+
99.PHONY: generate
132.PHONY: generate
100−generate:
133+generate: ## Generate alpha config docs from golang structs
101 go generate ./pkg/...
134 go generate ./pkg/...
102
135
103.PHONY: verify-generate
136.PHONY: verify-generate
104−verify-generate: generate
137+verify-generate: generate ## Verify command to check if alpha config docs are in line with golang struct changes
105 git diff --exit-code
138 git diff --exit-code
106
139
140+##@ Miscellaneous
141+
107.PHONY: test
142.PHONY: test
108−test: lint
143+test: lint ## Run all Go tests
109 GO111MODULE=on $(GO) test $(TESTCOVER) -v -race ./...
144 GO111MODULE=on $(GO) test $(TESTCOVER) -v -race ./...
110
145
111.PHONY: release
146.PHONY: release
112−release: validate-go-version lint test
147+release: validate-go-version lint test ## Create a full release for all architectures (binaries and checksums)
113 BINARY=${BINARY} VERSION=${VERSION} ./dist.sh
148 BINARY=${BINARY} VERSION=${VERSION} ./dist.sh
114
149
150+.PHONY: clean
151+clean: ## Cleanup release and build files
152+ -rm -rf release
153+ -rm -f $(BINARY)
154+
155+.PHONY: lint
156+lint: validate-go-version ## Lint all files using golangci-lint
157+ GO111MODULE=on $(GOLANGCILINT) run
158+
115.PHONY: validate-go-version
159.PHONY: validate-go-version
116−validate-go-version:
160+validate-go-version: ## Validate Go environment requirements
117 @if [ $(GO_MAJOR_VERSION) -gt $(MINIMUM_SUPPORTED_GO_MAJOR_VERSION) ]; then \
161 @if [ $(GO_MAJOR_VERSION) -gt $(MINIMUM_SUPPORTED_GO_MAJOR_VERSION) ]; then \
118 exit 0 ;\
162 exit 0 ;\
119 elif [ $(GO_MAJOR_VERSION) -lt $(MINIMUM_SUPPORTED_GO_MAJOR_VERSION) ]; then \
163 elif [ $(GO_MAJOR_VERSION) -lt $(MINIMUM_SUPPORTED_GO_MAJOR_VERSION) ]; then \
README.md+1−1
@@ -1,4 +1,4 @@
1−[![Continuous Integration](https://github.com/oauth2-proxy/oauth2-proxy/actions/workflows/ci.yaml/badge.svg)](https://github.com/oauth2-proxy/oauth2-proxy/actions/workflows/ci.yaml)
1+[![Continuous Integration](https://github.com/oauth2-proxy/oauth2-proxy/actions/workflows/ci.yml/badge.svg)](https://github.com/oauth2-proxy/oauth2-proxy/actions/workflows/ci.yml)
2[![Go Report Card](https://goreportcard.com/badge/github.com/oauth2-proxy/oauth2-proxy)](https://goreportcard.com/report/github.com/oauth2-proxy/oauth2-proxy)
2[![Go Report Card](https://goreportcard.com/badge/github.com/oauth2-proxy/oauth2-proxy)](https://goreportcard.com/report/github.com/oauth2-proxy/oauth2-proxy)
3[![GoDoc](https://godoc.org/github.com/oauth2-proxy/oauth2-proxy?status.svg)](https://godoc.org/github.com/oauth2-proxy/oauth2-proxy)
3[![GoDoc](https://godoc.org/github.com/oauth2-proxy/oauth2-proxy?status.svg)](https://godoc.org/github.com/oauth2-proxy/oauth2-proxy)
4[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
4[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
RELEASE.md+2−2
@@ -41,8 +41,8 @@ Note this uses `v4.1.0` as an example release number.
4110. Publish release in Github
4110. Publish release in Github
4211. Make and push docker images to Quay
4211. Make and push docker images to Quay
43 ```
43 ```
44− make docker-all
44+ make build-docker-all
45− make docker-push-all
45+ make push-docker-all
46 ```
46 ```
47 Note: Ensure the docker tags don't include `-dirty`. This means you have uncommitted changes.
47 Note: Ensure the docker tags don't include `-dirty`. This means you have uncommitted changes.
48
48
docs/docs/community/contribution.md+16−5
@@ -68,11 +68,22 @@ For starting oauth2-proxy locally open the debugging tab and create the `launch.
68
68
69Before you can start your local version of oauth2-proxy, you will have to use the provided docker compose files to start a local upstream service and identity provider. We suggest using [httpbin](https://hub.docker.com/r/kennethreitz/httpbin) as your upstream for testing as it allows for request and response introspection of all things HTTP.
69Before you can start your local version of oauth2-proxy, you will have to use the provided docker compose files to start a local upstream service and identity provider. We suggest using [httpbin](https://hub.docker.com/r/kennethreitz/httpbin) as your upstream for testing as it allows for request and response introspection of all things HTTP.
70
70
71−Open a terminal and switch to the `contrib/local-environment` directory.
71+Inside the `contrib/local-environment` directory you can use the `Makefile` for
72+starting different example setups:
72
73
73−- Dex as your IdP: `docker compose -f docker-compose.yaml up dex etcd httpbin`
74+- Dex as your IdP: `make up` or `make down`
74−- Keycloak as your IdP: `docker compose -f docker-compose-keycloak.yaml up keycloak httpbin`
75+- Dex as your IdP using the alpha-config: `make alpha-config-up`
76+- Keycloak as your IdP: `make keycloak-up`
77+- Dex as your IdP & nginx reverse proxy: `make nginx-up`
78+- and many more...
75
79
80+Check out the `Makefile` to see what is available.
81+
76−The username for both is `admin@example.com` and password is `password`.
82+The username and password for all setups is usually `admin@example.com` and `password`.
83+
84+The docker compose setups expose the services with a dynamic reverse DNS resolver: localtest.me
85+
86+- OAuth2-Proxy: http://oauth2-proxy.localtest.me:4180
87+- Upstream: http://httpbin.localtest.me:8080
88+- Dex: http://dex.localtest.me:4190
77
89
78−Start oauth2-proxy from the debug tab and open http://oauth2-proxy.localtest.me:4180/ for testing.
docs/versioned_docs/version-7.8.x/community/contribution.md+16−5
@@ -68,11 +68,22 @@ For starting oauth2-proxy locally open the debugging tab and create the `launch.
68
68
69Before you can start your local version of oauth2-proxy, you will have to use the provided docker compose files to start a local upstream service and identity provider. We suggest using [httpbin](https://hub.docker.com/r/kennethreitz/httpbin) as your upstream for testing as it allows for request and response introspection of all things HTTP.
69Before you can start your local version of oauth2-proxy, you will have to use the provided docker compose files to start a local upstream service and identity provider. We suggest using [httpbin](https://hub.docker.com/r/kennethreitz/httpbin) as your upstream for testing as it allows for request and response introspection of all things HTTP.
70
70
71−Open a terminal and switch to the `contrib/local-environment` directory.
71+Inside the `contrib/local-environment` directory you can use the `Makefile` for
72+starting different example setups:
72
73
73−- Dex as your IdP: `docker compose -f docker-compose.yaml up dex etcd httpbin`
74+- Dex as your IdP: `make up` or `make down`
74−- Keycloak as your IdP: `docker compose -f docker-compose-keycloak.yaml up keycloak httpbin`
75+- Dex as your IdP using the alpha-config: `make alpha-config-up`
76+- Keycloak as your IdP: `make keycloak-up`
77+- Dex as your IdP & nginx reverse proxy: `make nginx-up`
78+- and many more...
75
79
80+Check out the `Makefile` to see what is available.
81+
76−The username for both is `admin@example.com` and password is `password`.
82+The username and password for all setups is usually `admin@example.com` and `password`.
83+
84+The docker compose setups expose the services with a dynamic reverse DNS resolver: localtest.me
85+
86+- OAuth2-Proxy: http://oauth2-proxy.localtest.me:4180
87+- Upstream: http://httpbin.localtest.me:8080
88+- Dex: http://dex.localtest.me:4190
77
89
78−Start oauth2-proxy from the debug tab and open http://oauth2-proxy.localtest.me:4180/ for testing.