Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/implementing-ngrok-startup-script #21

Merged
merged 11 commits into from
Nov 17, 2022
36 changes: 20 additions & 16 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
version: "3"
services:
alice:
image: bcgovimages/aries-cloudagent:py36-1.16-1_1.0.0-rc0
image: bcgovimages/aries-cloudagent:py36-1.16-1_0.7.5
#image: bcgovimages/aries-cloudagent:py36-1.16-1_1.0.0-rc0
# image: acapy-test-image
# build:
# context: .
Expand All @@ -11,11 +12,12 @@ services:
ports:
- "3001:3001"
volumes:
- ./acapy-endpoint.sh:/acapy-endpoint.sh:ro,z
- ./tunnel_endpoint.sh:/tunnel_endpoint.sh:ro,z
environment:
TUNNEL_ENDPOINT: http://tunnel-alice:4040
AGENT_TUNNEL_ENDPOINT: http://tunnel-alice:4040
TAILS_TUNNEL_ENDPOINT: http://tunnel-tails:4040
entrypoint: >
/bin/sh -c '/acapy-endpoint.sh aca-py "$$@"' --
/bin/sh -c '/tunnel_endpoint.sh aca-py "$$@"' --
command: >
start -it http 0.0.0.0 3000
--label Alice
Expand All @@ -26,14 +28,14 @@ services:
--log-level debug
--webhook-url http://echo:3002/webhook
--genesis-url https://raw.githubusercontent.com/Indicio-tech/indicio-network/main/genesis_files/pool_transactions_demonet_genesis
--wallet-type askar
--wallet-type indy
--wallet-name alice
--wallet-key insecure
--auto-provision
healthcheck:
test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null
start_period: 30s
interval: 3s
interval: 7s
timeout: 5s
retries: 5
depends_on:
Expand All @@ -45,7 +47,8 @@ services:
condition: service_started

bob:
image: bcgovimages/aries-cloudagent:py36-1.16-1_1.0.0-rc0
image: bcgovimages/aries-cloudagent:py36-1.16-1_0.7.5
#image: bcgovimages/aries-cloudagent:py36-1.16-1_1.0.0-rc0
# image: acapy-test-image
# build:
# context: .
Expand All @@ -55,11 +58,12 @@ services:
ports:
- "3002:3001"
volumes:
- ./acapy-endpoint.sh:/acapy-endpoint.sh:ro,z
- ./tunnel_endpoint.sh:/tunnel_endpoint.sh:ro,z
environment:
TUNNEL_ENDPOINT: http://tunnel-bob:4040
entrypoint: >
/bin/sh -c '/acapy-endpoint.sh aca-py "$$@"' --
AGENT_TUNNEL_ENDPOINT: http://tunnel-bob:4040
TAILS_TUNNEL_ENDPOINT: http://tunnel-tails:4040
entrypoint:
/bin/sh -c '/tunnel_endpoint.sh aca-py "$$@"' --
command: >
start -it http 0.0.0.0 3000
--label Bob
Expand All @@ -70,14 +74,14 @@ services:
--log-level debug
--webhook-url http://echo:3002/webhook
--genesis-url https://raw.githubusercontent.com/Indicio-tech/indicio-network/main/genesis_files/pool_transactions_demonet_genesis
--wallet-type askar
--wallet-type indy
--wallet-name bob
--wallet-key insecure
--auto-provision
healthcheck:
test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null
start_period: 30s
interval: 3s
interval: 7s
timeout: 5s
retries: 5
depends_on:
Expand All @@ -104,7 +108,7 @@ services:
healthcheck:
test: nc -z localhost 3002
start_period: 5s
interval: 1s
interval: 7s
timeout: 5s
retries: 5

Expand Down Expand Up @@ -153,8 +157,8 @@ services:
args:
install_flags: ""
environment:
- ISSUER=http://alice:3001
- HOLDER=http://bob:3001
- ALICE=http://alice:3001
- BOB=http://bob:3001
- ECHO_ENDPOINT=http://echo:3002
volumes:
- ./controller:/usr/src/app/controller:z
Expand Down
36 changes: 36 additions & 0 deletions tunnel_endpoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

AGENT_TUNNEL_ENDPOINT=${AGENT_TUNNEL_ENDPOINT:-http://localhost:4040}
TAILS_TUNNEL_ENDPOINT=${TAILS_TUNNEL_ENDPOINT:-http://localhost:4040}

WAIT_INTERVAL=${WAIT_INTERVAL:-3}
WAIT_ATTEMPTS=${WAIT_ATTEMPTS:-10}

liveliness_check () {
for CURRENT_ATTEMPT in $(seq 1 "$WAIT_ATTEMPTS"); do
if ! curl -s -o /dev/null -w '%{http_code}' "${1}/status" | grep "200" > /dev/null; then
if [[ $CURRENT_ATTEMPT -gt $WAIT_ATTEMPT ]]
then
echo "Failed while waiting for 200 status from ${1}"
exit 1
fi

echo "Waiting for tunnel..." 1>&2
sleep "$WAIT_INTERVAL" &
wait $!
else
break
fi
done
}


liveliness_check ${AGENT_TUNNEL_ENDPOINT}
liveliness_check ${TAILS_TUNNEL_ENDPOINT}

ACAPY_ENDPOINT=$(curl --silent "${AGENT_TUNNEL_ENDPOINT}/url" | python -c "import sys, json; print(json.load(sys.stdin)['url'])")
ACAPY_TAILS_SERVER_BASE_URL=$(curl --silent "${TAILS_TUNNEL_ENDPOINT}/api/tunnels" | python -c "import sys, json; print(json.load(sys.stdin)['tunnels'][0]['public_url'])")
export ACAPY_ENDPOINT=${ACAPY_ENDPOINT}
export ACAPY_TAILS_SERVER_BASE_URL=${ACAPY_TAILS_SERVER_BASE_URL}
exec "$@"