Skip to content
Snippets Groups Projects
Commit 045b3ba3 authored by Valerii Kalashnikov's avatar Valerii Kalashnikov
Browse files

Merge branch 'chore/fix-docker' into 'main'

chore: fix docker for inter-container comms

See merge request eclipse/xfsc/ocm/ocm-engine!63
parents c006266d 0fdcc718
Branches main
No related tags found
No related merge requests found
Pipeline #43894 failed
......@@ -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
......@@ -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' '-------------------------' '----------'
......
#!/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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment