Skip to content

Commit

Permalink
fix: decouple quickstart scenarios (#336)
Browse files Browse the repository at this point in the history
Creates several docker compose examples which include various
scenarios of the quickstart.

The regular quickstart guide now works without ORY Oathkeeper
and uses the standalone mode of the example app instead.

Additionally, the Makefile was improved and now automatically pulls
required dependencies in the appropriate version.

Closes #262
  • Loading branch information
aeneasr authored Apr 12, 2020
1 parent 515714f commit 17363b3
Show file tree
Hide file tree
Showing 15 changed files with 587 additions and 130 deletions.
2 changes: 2 additions & 0 deletions .bin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
.lock
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ database.yaml
contrib/quickstart
contrib/swagutil
node_modules/
./quickstart.yml
./quickstart-*.yml
67 changes: 33 additions & 34 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
SHELL=/bin/bash -o pipefail

all:
ifeq (, $(shell which golangci-lint))
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.23.2
EXECUTABLES = docker-compose docker node npm go
K := $(foreach exec,$(EXECUTABLES),\
$(if $(shell which $(exec)),some string,$(error "No $(exec) in PATH")))

export GO111MODULE := on
export PATH := .bin:${PATH}

deps:
ifneq ("v0",$(shell cat .bin/.lock))
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b .bin/ v1.24.0
go build -o .bin/go-acc github.com/ory/go-acc
go build -o .bin/goreturns github.com/sqs/goreturns
go build -o .bin/listx github.com/ory/x/tools/listx
go build -o .bin/mockgen github.com/golang/mock/mockgen
go build -o .bin/swagger github.com/go-swagger/go-swagger/cmd/swagger
go build -o .bin/goimports golang.org/x/tools/cmd/goimports
go build -o .bin/swagutil github.com/ory/sdk/swagutil
go build -o .bin/packr2 github.com/gobuffalo/packr/v2/packr2
echo "v0" > .bin/.lock
endif

.PHONY: tools
tools:
go install github.com/ory/go-acc github.com/ory/x/tools/listx github.com/go-swagger/go-swagger/cmd/swagger github.com/go-bindata/go-bindata/go-bindata github.com/sqs/goreturns github.com/ory/sdk/swagutil

.PHONY: build
build:
make sqlbin
CGO_ENABLED=0 GO111MODULE=on GOOS=linux GOARCH=amd64 go build -o kratos .

.PHONY: init
init:
go install \
github.com/sqs/goreturns \
github.com/ory/x/tools/listx \
github.com/ory/go-acc \
github.com/golang/mock/mockgen \
github.com/go-swagger/go-swagger/cmd/swagger \
golang.org/x/tools/cmd/goimports
.PHONY: docs
docs:
cd docs; npm i; npm run build

.PHONY: lint
lint:
lint: deps
which golangci-lint
GO111MODULE=on golangci-lint run -v ./...

.PHONY: cover
Expand All @@ -34,20 +36,15 @@ cover:
go tool cover -func=cover.out

.PHONE: mocks
mocks:
mocks: deps
mockgen -mock_names Manager=MockLoginExecutorDependencies -package internal -destination internal/hook_login_executor_dependencies.go github.com/ory/kratos/selfservice loginExecutorDependencies

.PHONY: install
install:
packr2 || (GO111MODULE=on go install github.com/gobuffalo/packr/v2/packr2 && packr2)
install: deps
packr2
GO111MODULE=on go install .
packr2 clean

# Adds sql files to the binary using go-bindata
.PHONY: sqlbin
sqlbin:
cd driver; go-bindata -o sql_migration_files.go -pkg driver ../contrib/sql/...

.PHONY: test-resetdb
test-resetdb:
docker kill kratos_test_database_mysql || true
Expand All @@ -66,7 +63,7 @@ test: test-resetdb

# Generates the SDKs
.PHONY: sdk
sdk:
sdk: deps
$$(go env GOPATH)/bin/swagger generate spec -m -o .schema/api.swagger.json -x internal/httpclient
$$(go env GOPATH)/bin/swagutil sanitize ./.schema/api.swagger.json
$$(go env GOPATH)/bin/swagger validate ./.schema/api.swagger.json
Expand All @@ -77,18 +74,20 @@ sdk:
$$(go env GOPATH)/bin/swagger generate client -f ./.schema/api.swagger.json -t internal/httpclient -A Ory_Kratos
make format

.PHONY: quickstart
quickstart:
docker pull oryd/kratos:latest-sqlite
docker pull oryd/kratos-selfservice-ui-node:latest
docker-compose -f quickstart.yml up --build --force-recreate
docker-compose -f quickstart.yml -f quickstart-standalone.yml up --build --force-recreate

.PHONY: quickstart-dev
quickstart-dev:
docker build -f .docker/Dockerfile-build -t oryd/kratos:latest-sqlite .
docker-compose -f quickstart.yml up --build --force-recreate
docker-compose -f quickstart.yml -f quickstart-standalone.yml up --build --force-recreate

# Formats the code
.PHONY: format
format:
format: deps
$$(go env GOPATH)/bin/goreturns -w -local github.com/ory $$($$(go env GOPATH)/bin/listx .)

# Runs tests in short mode, without database adapters
Expand Down
1 change: 1 addition & 0 deletions contrib/quickstart/oathkeeper/.oathkeeper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ errors:
verbose: true

access_rules:
matching_strategy: glob
repositories:
- file:///etc/config/oathkeeper/access-rules.yml

Expand Down
6 changes: 3 additions & 3 deletions contrib/quickstart/oathkeeper/access-rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
url: "http://kratos:4433"
strip_path: /.ory/kratos/public
match:
url: "http://127.0.0.1:4455/.ory/kratos/public/<.*>"
url: "http://127.0.0.1:4455/.ory/kratos/public/<**>"
methods:
- GET
- POST
Expand All @@ -26,7 +26,7 @@
preserve_host: true
url: "http://kratos-selfservice-ui-node:4435"
match:
url: "http://127.0.0.1:4455/<(error|verify|auth/login|auth/registration|(.+\\.css))(|/)>"
url: "http://127.0.0.1:4455/<{error,verify,auth/*,**.css,**.js}{/,}>"
methods:
- GET
authenticators:
Expand All @@ -44,7 +44,7 @@
preserve_host: true
url: "http://kratos-selfservice-ui-node:4435"
match:
url: "http://127.0.0.1:4455<(/debug|/|/dashboard|/settings|)(|/)>"
url: "http://127.0.0.1:4455/<{,debug,dashboard,settings}{/,}>"
methods:
- GET
authenticators:
Expand Down
5 changes: 4 additions & 1 deletion docs/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ module.exports = {
},
{
replacer: ({content, next}) => content.replace(/git checkout (v[0-9a-zA-Z\\.\\-]+)/gi, `git checkout ${next}`),
files: ['docs/docs/quickstart.mdx']
files: [
'docs/docs/guides/zero-trust-iap-proxy-identity-access-proxy.md',
'docs/docs/quickstart.mdx',
]
}
],
updateConfig: {
Expand Down
Loading

0 comments on commit 17363b3

Please sign in to comment.