Skip to content

Commit

Permalink
Merge branch 'main' into issue_cred_2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
shaangill025 authored Feb 2, 2023
2 parents 5ba2689 + 35d6369 commit 32bb419
Show file tree
Hide file tree
Showing 8 changed files with 153 additions and 16 deletions.
4 changes: 0 additions & 4 deletions demo/docker-agent/Dockerfile.acapy
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,3 @@ COPY ngrok-wait.sh ngrok-wait.sh
RUN chmod +x ./ngrok-wait.sh

USER $user

# temporary until this PR gets merged/released
RUN pip uninstall -y aries-cloudagent
RUN pip install aries-cloudagent[indy,bbs,askar]@git+https://github.com/ianco/aries-cloudagent-python@endorser-write-did
8 changes: 3 additions & 5 deletions demo/docker-agent/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@ services:
- ./ngrok-wait.sh:/home/indy/ngrok-wait.sh

wallet-db:
image: vcr-postgresql
image: postgres:12
environment:
- POSTGRESQL_USER=DB_USER
- POSTGRESQL_PASSWORD=DB_PASSWORD
- POSTGRESQL_DATABASE=DB_USER
- POSTGRESQL_ADMIN_PASSWORD=mysecretpassword
- POSTGRES_USER=DB_USER
- POSTGRES_PASSWORD=DB_PASSWORD
ports:
- 5433:5432
volumes:
Expand Down
2 changes: 1 addition & 1 deletion demo/docker-agent/ngrok-wait.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ exec aca-py start \
--wallet-key "secret_key" \
--wallet-storage-type "postgres_storage" \
--wallet-storage-config "{\"url\":\"wallet-db:5432\",\"max_connections\":5}" \
--wallet-storage-creds "{\"account\":\"DB_USER\",\"password\":\"DB_PASSWORD\",\"admin_account\":\"postgres\",\"admin_password\":\"mysecretpassword\"}" \
--wallet-storage-creds "{\"account\":\"DB_USER\",\"password\":\"DB_PASSWORD\",\"admin_account\":\"DB_USER\",\"admin_password\":\"DB_PASSWORD\"}" \
--admin '0.0.0.0' 8010 \
--label "test_author" \
--admin-insecure-mode \
Expand Down
13 changes: 7 additions & 6 deletions demo/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# To shut down the services run `docker-compose rm` - this will retain the postgres database, so you can change aca-py startup parameters
# and restart the docker containers without losing your wallet data
# If you want to delete your wallet data just run `docker volume ls -q | xargs docker volume rm`

# Note this requires von-network (https://github.com/bcgov/von-network) and indy-tails-server (https://github.com/bcgov/indy-tails-server) are already running

version: "3"
services:
vcr-agent:
Expand Down Expand Up @@ -41,7 +44,7 @@ services:
--wallet-key 'key' \
--wallet-storage-type 'postgres_storage' \
--wallet-storage-config '{\"url\":\"wallet-db:5432\",\"max_connections\":5}' \
--wallet-storage-creds '{\"account\":\"DB_USER\",\"password\":\"DB_PASSWORD\",\"admin_account\":\"postgres\",\"admin_password\":\"mysecretpassword\"}' \
--wallet-storage-creds '{\"account\":\"DB_USER\",\"password\":\"DB_PASSWORD\",\"admin_account\":\"DB_USER\",\"admin_password\":\"DB_PASSWORD\"}' \
--admin '0.0.0.0' 8010 \
--admin-insecure-mode \
--label 'tester_agent' \
Expand All @@ -58,12 +61,10 @@ services:
# --genesis-transactions-list 'ledgers.yaml' \

wallet-db:
image: vcr-postgresql
image: postgres:12
environment:
- POSTGRESQL_USER=DB_USER
- POSTGRESQL_PASSWORD=DB_PASSWORD
- POSTGRESQL_DATABASE=DB_USER
- POSTGRESQL_ADMIN_PASSWORD=mysecretpassword
- POSTGRES_USER=DB_USER
- POSTGRES_PASSWORD=DB_PASSWORD
ports:
- 5433:5432
volumes:
Expand Down
10 changes: 10 additions & 0 deletions demo/multi-demo/Dockerfile.acapy
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM bcgovimages/aries-cloudagent:py36-1.16-1_1.0.0-rc0

USER root

ADD https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 ./jq
RUN chmod +x ./jq
COPY ngrok-wait.sh ngrok-wait.sh
RUN chmod +x ./ngrok-wait.sh

USER $user
40 changes: 40 additions & 0 deletions demo/multi-demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Running an Aca-Py Agent in Multitenant Mode

This directory contains scripts to run an aca-py agent in multitenancy mode.

## Running the Agent

The docker-compose script runs ngrok to expose the agent's port publicly, and stores wallet data in a postgres database.

To run the agent in this repo, open a command shell in this directory and run:

- to build the containers:

```bash
docker-compose build
```

- to run the agent:

```bash
docker-compose up
```

You can connect to the [agent's api service here](http://localhost:8010).

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.

- to shut down the agent:

```bash
docker-compose stop
docker-compose rm -f
```

This will leave the agent's wallet data, so if you restart the agent it will maintain any created data.

- to remove the agent's wallet:

```bash
docker volume rm multi-demo_wallet-db-data
```
45 changes: 45 additions & 0 deletions demo/multi-demo/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Sample docker-compose to start a local aca-py multitenancy agent
# To start aca-py and the postgres database, just run `docker-compose up`
# To shut down the services run `docker-compose rm` - this will retain the postgres database, so you can change aca-py startup parameters
# and restart the docker containers without losing your wallet data
# If you want to delete your wallet data just run `docker volume ls -q | xargs docker volume rm`
version: "3"
services:
ngrok-agent:
image: wernight/ngrok
ports:
- 4067:4040
command: ngrok http multi-agent:8001 --log stdout

multi-agent:
build:
context: .
dockerfile: Dockerfile.acapy
environment:
- NGROK_NAME=ngrok-agent
ports:
- 8010:8010
- 8001:8001
depends_on:
- wallet-db
entrypoint: /bin/bash
command: [
"-c",
"sleep 5; \
./ngrok-wait.sh"
]
volumes:
- ./ngrok-wait.sh:/home/indy/ngrok-wait.sh

wallet-db:
image: postgres:12
environment:
- POSTGRES_USER=DB_USER
- POSTGRES_PASSWORD=DB_PASSWORD
ports:
- 5433:5432
volumes:
- wallet-db-data:/var/lib/pgsql/data

volumes:
wallet-db-data:
47 changes: 47 additions & 0 deletions demo/multi-demo/ngrok-wait.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

# based on code developed by Sovrin: https://github.com/hyperledger/aries-acapy-plugin-toolbox

echo "using ngrok end point [$NGROK_NAME]"

NGROK_ENDPOINT=null
while [ -z "$NGROK_ENDPOINT" ] || [ "$NGROK_ENDPOINT" = "null" ]
do
echo "Fetching end point from ngrok service"
NGROK_ENDPOINT=$(curl --silent $NGROK_NAME:4040/api/tunnels | ./jq -r '.tunnels[] | select(.proto=="https") | .public_url')

if [ -z "$NGROK_ENDPOINT" ] || [ "$NGROK_ENDPOINT" = "null" ]; then
echo "ngrok not ready, sleeping 5 seconds...."
sleep 5
fi
done

export ACAPY_ENDPOINT=$NGROK_ENDPOINT

echo "Starting aca-py agent with endpoint [$ACAPY_ENDPOINT]"

# ... if you want to echo the aca-py startup command ...
set -x

exec aca-py start \
--auto-provision \
--inbound-transport http '0.0.0.0' 8001 \
--outbound-transport http \
--genesis-url "http://test.bcovrin.vonx.io/genesis" \
--endpoint "${ACAPY_ENDPOINT}" \
--auto-ping-connection \
--monitor-ping \
--public-invites \
--wallet-type "askar" \
--wallet-name "test_multi" \
--wallet-key "secret_key" \
--wallet-storage-type "postgres_storage" \
--wallet-storage-config "{\"url\":\"wallet-db:5432\",\"max_connections\":5,\"scheme\":\"MultiWalletSingleTable\"}" \
--wallet-storage-creds "{\"account\":\"DB_USER\",\"password\":\"DB_PASSWORD\",\"admin_account\":\"DB_USER\",\"admin_password\":\"DB_PASSWORD\"}" \
--admin '0.0.0.0' 8010 \
--label "test_multi" \
--admin-insecure-mode \
--multitenant \
--multitenant-admin \
--jwt-secret "very_secret_secret" \
--log-level "error"

0 comments on commit 32bb419

Please sign in to comment.