Skip to content

Commit

Permalink
docs: add examples doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Pat Losoponkul committed Mar 25, 2024
1 parent 2b458aa commit fe29e35
Show file tree
Hide file tree
Showing 19 changed files with 125 additions and 466 deletions.
1 change: 0 additions & 1 deletion examples/.nickel/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ find . -name "*.ncl" | xargs -I _ nickel format _
nickel export ./root.ncl -f yaml --field st > ../st/compose.yaml
nickel export ./root.ncl -f yaml --field st-vault > ../st-vault/compose.yaml
nickel export ./root.ncl -f yaml --field st-multi > ../st-multi/compose.yaml
nickel export ./root.ncl -f yaml --field st-oidc4vc > ../st-oidc4vc/compose.yaml

nickel export ./root.ncl -f yaml --field mt > ../mt/compose.yaml
nickel export ./root.ncl -f yaml --field mt-keycloak > ../mt-keycloak/compose.yaml
Expand Down
1 change: 1 addition & 0 deletions examples/.nickel/caddy.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ in
handle_path /vault* {
reverse_proxy %{args.vault.host}:%{std.to_string args.vault.port}
}
respond 404
}
"%
}
Expand Down
2 changes: 2 additions & 0 deletions examples/.shared/hurl/simple_realm/01_init_realm.hurl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ HTTP 200

# Admin login
POST {{ keycloak_base_url }}/realms/master/protocol/openid-connect/token
[Options]
retry: 60
[FormParams]
grant_type: password
client_id: admin-cli
Expand Down
60 changes: 60 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# How to run examples

## Prerequisites

- docker-compose version >= `2.23.1`

## Running examples

Most of the examples should follow the same pattern.
Simply go to each example directory and spin up the docker-compose of each example.

```bash
cd <EXAMPLE_DIR>
docker-compose up
```

If some example requires a different command, it should be provided in its own local README.

## Examples

|example|description|
|-|-|
|`st`|single-tenant configuration without external services (except database)|
|`st-multi`|3 instances of single-tenant configuration|
|`st-vault`|single-tenant with Vault for secret storage|
|`mt`|multi-tenant configuration using built-in IAM|
|`mt-keycloak`|multi-tenant configuration using Keycloak for IAM|
|`mt-keycloak-vault`|multi-tenant configuration using Keycloak and Vault|

# Contributing

All of the docker-compose files in examples are generated using [Nickel](https://nickel-lang.org/).
They are defined in a shared `.nickel` directory and generated using the `build.sh` script.

## Prerequisites

- [Nickel](https://nickel-lang.org/) version >= `1.5` installed

## Generate example compose files

To generate the docker-compose config for all examples, run

```bash
cd .nickel
./build.sh
```

## Updating example compose files

To update the configuration, simply edit the `*.ncl` config in the `.nickel` directory and regenerate the docker-compose files.

## Adding new examples

To add a new example with docker-compose file, simply create a new configuration key in the `root.ncl` and add a new entry in the `build.sh` script.
You may need to create the target example directory if it does not already exist.

## Example with bootstrapping script

If any example requires initialize steps, it should be made part of the docker-compose `depends_on` construct.
Ideally, infrastructure bootstrapping should be automatic (database, IAM), but not necessarily application bootstrapping (tenant onboarding).
16 changes: 16 additions & 0 deletions examples/mt-keycloak-vault/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## Configuration

|Exposed Service|Description|
|-|-|
|`localhost:8080/prism-agent`|Multi-tenant Cloud Agent|
|`localhost:8080/keycloak/admin`|Keycloak|
|`localhost:8200`|Vault|

__Keycloak__

- Admin user `admin`
- Admin password `admin`

__Vault__

- Root token `admin`
1 change: 1 addition & 0 deletions examples/mt-keycloak-vault/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ configs:
handle_path /vault* {
reverse_proxy vault-default:8200
}
respond 404
}
services:
agent-default:
Expand Down
11 changes: 11 additions & 0 deletions examples/mt-keycloak/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Configuration

|Exposed Service|Description|
|-|-|
|`localhost:8080/prism-agent`|Multi-tenant Cloud Agent|
|`localhost:8080/keycloak/admin`|Keycloak|

__Keycloak__

- Admin user `admin`
- Admin password `admin`
1 change: 1 addition & 0 deletions examples/mt-keycloak/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ configs:
handle_path /vault* {
reverse_proxy vault-default:8200
}
respond 404
}
services:
agent-default:
Expand Down
5 changes: 5 additions & 0 deletions examples/mt/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Configuration

|Exposed Service|Description|
|-|-|
|`localhost:8080/prism-agent`|Multi-tenant Cloud Agent|
1 change: 1 addition & 0 deletions examples/mt/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ configs:
handle_path /vault* {
reverse_proxy vault-default:8200
}
respond 404
}
services:
agent-default:
Expand Down
7 changes: 7 additions & 0 deletions examples/st-multi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Configuration

|Exposed Service|Description|
|-|-|
|`localhost:8080/prism-agent`|Single-tenant Cloud Agent#1 (issuer)|
|`localhost:8081/prism-agent`|Single-tenant Cloud Agent#2 (holder)|
|`localhost:8082/prism-agent`|Single-tenant Cloud Agent#3 (verifier)|
3 changes: 3 additions & 0 deletions examples/st-multi/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ configs:
handle_path /vault* {
reverse_proxy vault-holder:8200
}
respond 404
}
caddyfile_issuer:
content: |-
Expand All @@ -30,6 +31,7 @@ configs:
handle_path /vault* {
reverse_proxy vault-issuer:8200
}
respond 404
}
caddyfile_verifier:
content: |-
Expand All @@ -46,6 +48,7 @@ configs:
handle_path /vault* {
reverse_proxy vault-verifier:8200
}
respond 404
}
services:
agent-holder:
Expand Down
77 changes: 0 additions & 77 deletions examples/st-oidc4vc/bootstrap/01_init_realm.hurl

This file was deleted.

Loading

0 comments on commit fe29e35

Please sign in to comment.