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

OZ-627: Add dynamic project name suffix for Ozone in Docker Compose #107

Merged
merged 4 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@ if [ "$DEMO" == "true" ]; then
echo "→ NUMBER_OF_DEMO_PATIENTS=$NUMBER_OF_DEMO_PATIENTS"
fi

# Check if ozone-info.json exists and read project name
ozoneInfo="../$DISTRO_PATH/ozone-info.json"
if [ -f "$ozoneInfo" ]; then
projectName=$(grep -o '"name":\s*"[^\"]*"' "$ozoneInfo" | cut -d'"' -f4)
else
projectName="ozone"
fi

suffix=0
while isOzoneRunning "$projectName"; do
suffix=$((suffix + 1))
corneliouzbett marked this conversation as resolved.
Show resolved Hide resolved
projectName="$projectName-$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 +56,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 +73,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 +85,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