forked from ory/oathkeeper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
84 lines (70 loc) · 2.52 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
SHELL=/bin/bash -o pipefail
export GO111MODULE := on
export PATH := .bin:${PATH}
export PWD := $(shell pwd)
GO_DEPENDENCIES = github.com/ory/go-acc \
golang.org/x/tools/cmd/goimports \
github.com/go-swagger/go-swagger/cmd/swagger \
github.com/ory/cli \
github.com/gobuffalo/packr/v2/packr2 \
github.com/go-bindata/go-bindata/go-bindata
define make-go-dependency
# go install is responsible for not re-building when the code hasn't changed
.bin/$(notdir $1): go.sum go.mod
GOBIN=$(PWD)/.bin/ go install $1
endef
$(foreach dep, $(GO_DEPENDENCIES), $(eval $(call make-go-dependency, $(dep))))
node_modules: package.json package-lock.json
npm i
docs/node_modules: docs/package.json docs/package-lock.json
cd docs; npm i
.bin/clidoc: go.mod
go build -o .bin/clidoc ./cmd/clidoc/.
# Formats the code
.PHONY: format
format: .bin/goimports node_modules docs/node_modules
goimports -w --local github.com/ory .
npm run format
cd docs; npm run format
.PHONY: gen
gen:
mocks sdk
.bin/ory: Makefile
bash <(curl https://raw.githubusercontent.com/ory/cli/master/install.sh) -b .bin v0.0.53
touch -a -m .bin/ory
# Generates the SDKs
.PHONY: sdk
sdk: .bin/packr2 .bin/swagger .bin/ory
swagger generate spec -m -o ./spec/api.json -x internal/httpclient
ory dev swagger sanitize ./spec/api.json
swagger flatten --with-flatten=remove-unused -o ./spec/api.json ./spec/api.json
swagger validate ./spec/api.json
rm -rf internal/httpclient
mkdir -p internal/httpclient
swagger generate client -f ./spec/api.json -t internal/httpclient -A Ory_Oathkeeper
make format
.PHONY: install-stable
install-stable: .bin/packr2
OATHKEEPER_LATEST=$$(git describe --abbrev=0 --tags)
git checkout $$OATHKEEPER_LATEST
packr2
GO111MODULE=on go install \
-ldflags "-X github.com/ory/oathkeeper/x.Version=$$OATHKEEPER_LATEST -X github.com/ory/oathkeeper/x.Date=`TZ=UTC date -u '+%Y-%m-%dT%H:%M:%SZ'` -X github.com/ory/oathkeeper/x.Commit=`git rev-parse HEAD`" \
.
packr2 clean
git checkout master
.PHONY: install
install: .bin/packr2
packr2 || (GO111MODULE=on go install github.com/gobuffalo/packr/v2/packr2 && packr2)
GO111MODULE=on go install .
packr2 clean
.PHONY: docker
docker: .bin/packr2
packr2 || (GO111MODULE=on go install github.com/gobuffalo/packr/v2/packr2 && packr2)
CGO_ENABLED=0 GO111MODULE=on GOOS=linux GOARCH=amd64 go build
packr2 clean
docker build -t oryd/oathkeeper:dev .
docker build -t oryd/oathkeeper:dev-alpine -f Dockerfile-alpine .
rm oathkeeper
docs/cli: .bin/clidoc
clidoc .