Skip to content

Commit 73862d9

Browse files
committed
Multitenancy demo
Signed-off-by: Ian Costanzo <ian@anon-solutions.ca>
1 parent a0621a0 commit 73862d9

5 files changed

Lines changed: 144 additions & 4 deletions

File tree

demo/docker-agent/Dockerfile.acapy

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,3 @@ COPY ngrok-wait.sh ngrok-wait.sh
88
RUN chmod +x ./ngrok-wait.sh
99

1010
USER $user
11-
12-
# temporary until this PR gets merged/released
13-
RUN pip uninstall -y aries-cloudagent
14-
RUN pip install aries-cloudagent[indy,bbs,askar]@git+https://github.com/ianco/aries-cloudagent-python@endorser-write-did

demo/multi-demo/Dockerfile.acapy

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM bcgovimages/aries-cloudagent:py36-1.16-1_1.0.0-rc0
2+
3+
USER root
4+
5+
ADD https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 ./jq
6+
RUN chmod +x ./jq
7+
COPY ngrok-wait.sh ngrok-wait.sh
8+
RUN chmod +x ./ngrok-wait.sh
9+
10+
USER $user

demo/multi-demo/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Running an Aca-Py Agent in Multitenant Mode
2+
3+
This directory contains scripts to run an aca-py agent in multitenancy mode.
4+
5+
## Running the Agent
6+
7+
The docker-compose script runs ngrok to expose the agent's port publicly, and stores wallet data in a postgres database.
8+
9+
To run the agent in this repo, open a command shell in this directory and run:
10+
11+
- to build the containers:
12+
13+
```bash
14+
docker-compose build
15+
```
16+
17+
- to run the agent:
18+
19+
```bash
20+
docker-compose up
21+
```
22+
23+
You can connect to the [agent's api service here](http://localhost:8010).
24+
25+
Note that all the configuration settings are hard-coded in the docker-compose file and ngrok-wait.sh script, so if you change any configs you need to rebuild the docker images.
26+
27+
- to shut down the agent:
28+
29+
```bash
30+
docker-compose stop
31+
docker-compose rm -f
32+
```
33+
34+
This will leave the agent's wallet data, so if you restart the agent it will maintain any created data.
35+
36+
- to remove the agent's wallet:
37+
38+
```bash
39+
docker volume rm docker-agent_wallet-db-data
40+
```

demo/multi-demo/docker-compose.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Sample docker-compose to start a local aca-py multitenancy agent
2+
# To start aca-py and the postgres database, just run `docker-compose up`
3+
# To shut down the services run `docker-compose rm` - this will retain the postgres database, so you can change aca-py startup parameters
4+
# and restart the docker containers without losing your wallet data
5+
# If you want to delete your wallet data just run `docker volume ls -q | xargs docker volume rm`
6+
version: "3"
7+
services:
8+
ngrok-agent:
9+
image: wernight/ngrok
10+
ports:
11+
- 4067:4040
12+
command: ngrok http multi-agent:8001 --log stdout
13+
14+
multi-agent:
15+
build:
16+
context: .
17+
dockerfile: Dockerfile.acapy
18+
environment:
19+
- NGROK_NAME=ngrok-agent
20+
ports:
21+
- 8010:8010
22+
- 8001:8001
23+
depends_on:
24+
- wallet-db
25+
entrypoint: /bin/bash
26+
command: [
27+
"-c",
28+
"sleep 5; \
29+
./ngrok-wait.sh"
30+
]
31+
volumes:
32+
- ./ngrok-wait.sh:/home/indy/ngrok-wait.sh
33+
34+
wallet-db:
35+
image: vcr-postgresql
36+
environment:
37+
- POSTGRESQL_USER=DB_USER
38+
- POSTGRESQL_PASSWORD=DB_PASSWORD
39+
- POSTGRESQL_DATABASE=DB_USER
40+
- POSTGRESQL_ADMIN_PASSWORD=mysecretpassword
41+
ports:
42+
- 5433:5432
43+
volumes:
44+
- wallet-db-data:/var/lib/pgsql/data
45+
46+
volumes:
47+
wallet-db-data:

demo/multi-demo/ngrok-wait.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
3+
# based on code developed by Sovrin: https://github.com/hyperledger/aries-acapy-plugin-toolbox
4+
5+
echo "using ngrok end point [$NGROK_NAME]"
6+
7+
NGROK_ENDPOINT=null
8+
while [ -z "$NGROK_ENDPOINT" ] || [ "$NGROK_ENDPOINT" = "null" ]
9+
do
10+
echo "Fetching end point from ngrok service"
11+
NGROK_ENDPOINT=$(curl --silent $NGROK_NAME:4040/api/tunnels | ./jq -r '.tunnels[] | select(.proto=="https") | .public_url')
12+
13+
if [ -z "$NGROK_ENDPOINT" ] || [ "$NGROK_ENDPOINT" = "null" ]; then
14+
echo "ngrok not ready, sleeping 5 seconds...."
15+
sleep 5
16+
fi
17+
done
18+
19+
export ACAPY_ENDPOINT=$NGROK_ENDPOINT
20+
21+
echo "Starting aca-py agent with endpoint [$ACAPY_ENDPOINT]"
22+
23+
# ... if you want to echo the aca-py startup command ...
24+
set -x
25+
26+
exec aca-py start \
27+
--auto-provision \
28+
--inbound-transport http '0.0.0.0' 8001 \
29+
--outbound-transport http \
30+
--genesis-url "http://test.bcovrin.vonx.io/genesis" \
31+
--endpoint "${ACAPY_ENDPOINT}" \
32+
--auto-ping-connection \
33+
--monitor-ping \
34+
--public-invites \
35+
--wallet-type "askar" \
36+
--wallet-name "test_multi" \
37+
--wallet-key "secret_key" \
38+
--wallet-storage-type "postgres_storage" \
39+
--wallet-storage-config "{\"url\":\"wallet-db:5432\",\"max_connections\":5,\"scheme\":\"MultiWalletSingleTable\"}" \
40+
--wallet-storage-creds "{\"account\":\"DB_USER\",\"password\":\"DB_PASSWORD\",\"admin_account\":\"postgres\",\"admin_password\":\"mysecretpassword\"}" \
41+
--admin '0.0.0.0' 8010 \
42+
--label "test_multi" \
43+
--admin-insecure-mode \
44+
--multitenant \
45+
--multitenant-admin \
46+
--jwt-secret "very_secret_secret" \
47+
--log-level "error"

0 commit comments

Comments
 (0)