2020-05-09 18:07:46 +03:00
GO ?= go
GOLANGCILINT ?= golangci-lint
2020-03-29 16:54:36 +03:00
BINARY := oauth2-proxy
2019-02-08 13:10:52 +03:00
VERSION := $( shell git describe --always --dirty --tags 2>/dev/null || echo "undefined" )
2019-10-07 23:53:46 +03:00
# Allow to override image registry.
2020-03-29 16:54:36 +03:00
REGISTRY ?= quay.io/oauth2-proxy
2019-01-07 19:41:11 +03:00
.NOTPARALLEL :
2019-01-04 13:58:30 +03:00
2020-05-09 18:07:46 +03:00
GO_MAJOR_VERSION = $( shell $( GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1)
GO_MINOR_VERSION = $( shell $( GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2)
MINIMUM_SUPPORTED_GO_MAJOR_VERSION = 1
MINIMUM_SUPPORTED_GO_MINOR_VERSION = 14
GO_VERSION_VALIDATION_ERR_MSG = Golang version is not supported, please update to at least $( MINIMUM_SUPPORTED_GO_MAJOR_VERSION) .$( MINIMUM_SUPPORTED_GO_MINOR_VERSION)
2020-05-10 09:29:37 +03:00
i f e q ( $( COVER ) , t r u e )
TESTCOVER ?= -coverprofile c.out
e n d i f
2019-01-04 13:58:30 +03:00
.PHONY : all
2019-07-13 23:24:40 +03:00
all : lint $( BINARY )
2019-01-04 13:58:30 +03:00
.PHONY : clean
clean :
rm -rf release
rm -f $( BINARY)
.PHONY : distclean
distclean : clean
rm -rf vendor
.PHONY : lint
2020-05-09 18:07:46 +03:00
lint : validate -go -version
2019-07-13 23:24:40 +03:00
GO111MODULE = on $( GOLANGCILINT) run
2019-01-04 13:58:30 +03:00
.PHONY : build
2020-05-09 18:07:46 +03:00
build : validate -go -version clean $( BINARY )
2019-01-04 13:58:30 +03:00
$(BINARY) :
2020-03-29 16:54:36 +03:00
GO111MODULE = on CGO_ENABLED = 0 $( GO) build -a -installsuffix cgo -ldflags= " -X main.VERSION= ${ VERSION } " -o $@ github.com/oauth2-proxy/oauth2-proxy
2019-01-04 13:58:30 +03:00
2019-02-02 02:08:19 +03:00
.PHONY : docker
docker :
2020-03-29 16:54:36 +03:00
docker build -f Dockerfile -t $( REGISTRY) /oauth2-proxy:latest .
2019-02-02 02:08:19 +03:00
.PHONY : docker -all
2019-02-02 04:20:20 +03:00
docker-all : docker
2020-03-29 16:54:36 +03:00
docker build -f Dockerfile -t $( REGISTRY) /oauth2-proxy:latest-amd64 .
docker build -f Dockerfile -t $( REGISTRY) /oauth2-proxy:${ VERSION } .
docker build -f Dockerfile -t $( REGISTRY) /oauth2-proxy:${ VERSION } -amd64 .
docker build -f Dockerfile.arm64 -t $( REGISTRY) /oauth2-proxy:latest-arm64 .
docker build -f Dockerfile.arm64 -t $( REGISTRY) /oauth2-proxy:${ VERSION } -arm64 .
docker build -f Dockerfile.armv6 -t $( REGISTRY) /oauth2-proxy:latest-armv6 .
docker build -f Dockerfile.armv6 -t $( REGISTRY) /oauth2-proxy:${ VERSION } -armv6 .
2019-02-08 13:05:57 +03:00
.PHONY : docker -push
docker-push :
2020-03-29 16:54:36 +03:00
docker push $( REGISTRY) /oauth2-proxy:latest
2019-02-08 13:05:57 +03:00
.PHONY : docker -push -all
docker-push-all : docker -push
2020-03-29 16:54:36 +03:00
docker push $( REGISTRY) /oauth2-proxy:latest-amd64
docker push $( REGISTRY) /oauth2-proxy:${ VERSION }
docker push $( REGISTRY) /oauth2-proxy:${ VERSION } -amd64
docker push $( REGISTRY) /oauth2-proxy:latest-arm64
docker push $( REGISTRY) /oauth2-proxy:${ VERSION } -arm64
docker push $( REGISTRY) /oauth2-proxy:latest-armv6
docker push $( REGISTRY) /oauth2-proxy:${ VERSION } -armv6
2019-02-02 02:08:19 +03:00
2019-01-04 13:58:30 +03:00
.PHONY : test
2019-07-13 23:24:40 +03:00
test : lint
2020-05-10 09:29:37 +03:00
GO111MODULE = on $( GO) test $( TESTCOVER) -v -race ./...
2019-01-04 13:58:30 +03:00
.PHONY : release
2019-01-07 19:41:11 +03:00
release : lint test
2019-10-29 20:27:08 +03:00
BINARY = ${ BINARY } VERSION = ${ VERSION } ./dist.sh
2020-05-09 18:07:46 +03:00
.PHONY : validate -go -version
2020-05-03 23:05:40 +03:00
validate-go-version :
2020-05-09 18:07:46 +03:00
@if [ $( GO_MAJOR_VERSION) -gt $( MINIMUM_SUPPORTED_GO_MAJOR_VERSION) ] ; then \
exit 0 ; \
elif [ $( GO_MAJOR_VERSION) -lt $( MINIMUM_SUPPORTED_GO_MAJOR_VERSION) ] ; then \
echo '$(GO_VERSION_VALIDATION_ERR_MSG)' ; \
exit 1; \
elif [ $( GO_MINOR_VERSION) -lt $( MINIMUM_SUPPORTED_GO_MINOR_VERSION) ] ; then \
echo '$(GO_VERSION_VALIDATION_ERR_MSG)' ; \
exit 1; \
fi
2020-05-03 23:05:40 +03:00
# local-env can be used to interact with the local development environment
2020-05-08 00:59:43 +03:00
# eg:
# make local-env-up # Bring up a basic test environment
# make local-env-down # Tear down the basic test environment
# make local-env-nginx-up # Bring up an nginx based test environment
# make local-env-nginx-down # Tead down the nginx based test environment
2020-05-03 23:05:40 +03:00
.PHONY : local -env -%
local-env-% :
make -C contrib/local-environment $*