Skip to content

Commit

Permalink
OZ-627: Add dynamic project name suffix for Ozone in Docker Compose
Browse files Browse the repository at this point in the history
  • Loading branch information
corneliouzbett committed Jul 31, 2024
1 parent 63f2b68 commit c5ac95a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
18 changes: 14 additions & 4 deletions scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ if [ "$DEMO" == "true" ]; then
echo "→ NUMBER_OF_DEMO_PATIENTS=$NUMBER_OF_DEMO_PATIENTS"
fi

projectName="ozone"
suffix=0

while isOzoneRunning "$projectName"; do
suffix=$((suffix + 1))
projectName="ozone_$suffix"
done

echo "$INFO Starting Ozone project with name: $projectName"

INSTALLED_DOCKER_VERSION=$(docker version -f "{{.Server.Version}}")
MINIMUM_REQUIRED_DOCKER_VERSION_REGEX="^((([2-9][1-9]|[3-9][0]|[0-9]{3,}).*)|(20\.([0-9]{3,}|[1-9][1-9]|[2-9][0]).*)|(20\.10\.([0-9]{3,}|[2-9][0-9]|[1][3-9])))"
if [[ $INSTALLED_DOCKER_VERSION =~ $MINIMUM_REQUIRED_DOCKER_VERSION_REGEX ]]; then
Expand All @@ -40,10 +50,10 @@ if [[ $INSTALLED_DOCKER_VERSION =~ $MINIMUM_REQUIRED_DOCKER_VERSION_REGEX ]]; th

# Pull Ozone Docker images
echo "$INFO Pulling ${OZONE_LABEL:-Ozone FOSS} images..."
docker compose -p ozone $dockerComposeOzoneCLIOptions pull
docker compose -p $projectName $dockerComposeOzoneCLIOptions pull

# Set the Docker Compose command for Ozone
dockerComposeOzoneCommand="docker compose -p ozone $dockerComposeOzoneCLIOptions up -d --build"
dockerComposeOzoneCommand="docker compose -p $projectName $dockerComposeOzoneCLIOptions up -d --build"
echo "$INFO Running ${OZONE_LABEL:-Ozone FOSS}..."
echo ""
echo "$dockerComposeOzoneCommand"
Expand All @@ -57,7 +67,7 @@ if [[ $INSTALLED_DOCKER_VERSION =~ $MINIMUM_REQUIRED_DOCKER_VERSION_REGEX ]]; th

# Run the Nginx Proxy service, if $TRAEFIK!=true
if [ "$TRAEFIK" != "true" ]; then
dockerComposeProxyCommand="docker compose -p ozone $dockerComposeProxyCLIOptions up -d --build"
dockerComposeProxyCommand="docker compose -p $projectName $dockerComposeProxyCLIOptions up -d --build"
echo "$INFO Running Nginx proxy service (\$TRAEFIK!=true)..."
echo ""
echo "$dockerComposeProxyCommand"
Expand All @@ -69,7 +79,7 @@ if [[ $INSTALLED_DOCKER_VERSION =~ $MINIMUM_REQUIRED_DOCKER_VERSION_REGEX ]]; th

# Run the Demo service
if [ "$DEMO" == "true" ]; then
dockerComposeDemoCommand="docker compose -p ozone $dockerComposeDemoCLIOptions up -d"
dockerComposeDemoCommand="docker compose -p $projectName $dockerComposeDemoCLIOptions up -d"
echo "$INFO Running demo service..."
echo ""
echo "$dockerComposeDemoCommand"
Expand Down
10 changes: 10 additions & 0 deletions scripts/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ function setNginxHostnames {

}

function isOzoneRunning {
local projectName=$1
runningContainers=$(docker ps --filter "name=${projectName}" --format "{{.Names}}")
if [ -n "$runningContainers" ]; then
return 0 # true
else
return 1 # false
fi
}

function displayAccessURLsWithCredentials {
services=()
is_defined=()
Expand Down

0 comments on commit c5ac95a

Please sign in to comment.