diff --git a/docker-compose.yml b/docker-compose.yml
index 6d13657923fa27f5defd728c67910b121ecebcbc..b8b0105b4f0e96f2c2fc12be85d78edb2e66cd46 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -70,7 +70,7 @@ services:
AGENT_NAME: ssi-abstraction-agent
AGENT_WALLET_ID: ssi-wallet-id
AGENT_WALLET_KEY: ssi-wallet-key
- AGENT_HOST: http://host.docker.internal
+ AGENT_HOST: ${SSI_AGENT_HOST:-http://host.docker.internal}
AGENT_INBOUND_PORT: ${SSI_AGENT_PORT:-4005}
AGENT_LEDGER_ID: BCOVRIN_TEST
AGENT_INDY_DID_SEED: 6b8b882e2618fa5d45ee7229ca000000
@@ -91,6 +91,9 @@ services:
- nats
- init-s3
- postgres
+ networks:
+ - default
+ - ocm-network
schema-manager:
build:
@@ -195,3 +198,8 @@ services:
volumes:
postgresql-data:
+
+networks:
+ ocm-network:
+ external: true
+ driver: bridge
diff --git a/scripts/start_instance.sh b/scripts/start_instance.sh
index fba397f366bf761eaca5abf0414fbbd775b66da0..bafa67dd94fdc7483d91c0ce8f23dfac5398a33c 100755
--- a/scripts/start_instance.sh
+++ b/scripts/start_instance.sh
@@ -27,6 +27,13 @@ while [[ "$#" -gt 0 ]]; do
shift
done
+# Step 0: Create a Docker network if it doesn't exist yet
+network_name="ocm-network"
+if ! docker network inspect $network_name >/dev/null 2>&1; then
+ echo "Creating Docker network: $network_name"
+ docker network create $network_name >/dev/null
+fi
+
# Step 1: Get all running Docker Compose instances and extract the project numbers
running_instances=$(docker compose ls --format json | jq -r '.[].Name')
max_number=0
@@ -45,6 +52,9 @@ new_number=$((max_number + 1))
# Calculate new port numbers based on new_number
increment=$((new_number * 100))
+# Set the project name
+project_name="ocm-$new_number"
+
# Export the new port numbers
export SCHEMA_MANAGER_PORT=$((base_SCHEMA_MANAGER_PORT + increment))
export CONNECTION_MANAGER_PORT=$((base_CONNECTION_MANAGER_PORT + increment))
@@ -53,6 +63,7 @@ export PROOF_MANAGER_PORT=$((base_PROOF_MANAGER_PORT + increment))
export DID_MANAGER_PORT=$((base_DID_MANAGER_PORT + increment))
export TENANT_MANAGER_PORT=$((base_TENANT_MANAGER_PORT + increment))
export SSI_PORT=$((base_SSI_PORT + increment))
+export SSI_AGENT_HOST="http://${project_name}-ssi-abstraction-1"
export SSI_AGENT_PORT=$((base_SSI_AGENT_PORT + increment))
export NATS_PORT=$((base_NATS_PORT + increment))
export NATS_MONITORING_PORT=$((base_NATS_MONITORING_PORT + increment))
@@ -61,11 +72,11 @@ export S3_CONSOLE_PORT=$((base_S3_CONSOLE_PORT + increment))
export POSTGRES_PORT=$((base_POSTGRES_PORT + increment))
# Proceed with starting the instance
-docker compose -p "ocm-$new_number" up -d $docker_compose_options
+docker compose -p $project_name up -d $docker_compose_options
# Output the ports in a tabular view after the instance has started
echo
-echo "Port Assignments for ocm-$new_number:"
+echo "Port Assignments for $project_name:"
echo
printf "%-25s %-10s\n" "VARIABLE" "PORT"
printf '%-25s %-10s\n' '-------------------------' '----------'
diff --git a/scripts/stop_instance.sh b/scripts/stop_instance.sh
index 70b5268b1b43a607da43af5c05030b5ffec248f3..83e4474273f003710b511aa94c2c18f35cba6322 100755
--- a/scripts/stop_instance.sh
+++ b/scripts/stop_instance.sh
@@ -1,5 +1,7 @@
#!/usr/bin/env bash
+network_name="ocm-network"
+
# Function to stop a Docker Compose project
stop_docker_compose_project() {
local project_name=$1
@@ -80,3 +82,19 @@ else
;;
esac
fi
+
+# Get all running Docker Compose instances
+running_instances=$(docker compose ls --format json | jq -r '.[].Name')
+running_projects=()
+
+for name in $running_instances; do
+ if [[ $name =~ ocm-([0-9]+) ]]; then
+ running_projects+=("$name")
+ fi
+done
+
+if [ ${#running_projects[@]} -eq 0 ]; then
+ # Remove the network if there are no running instances
+ echo "Removing Docker network: $network_name"
+ docker network rm $network_name &>/dev/null
+fi