Skip to content

Commit

Permalink
Update Shell Scripts to use Docker Compose V2 (#115)
Browse files Browse the repository at this point in the history
* Updated to handle statusing of containers built with Docker Compose V1 and V2.

* docker compose updates.

* updated to remove versioning check and introduce container status timeout.
  • Loading branch information
palyca authored Jun 22, 2023
1 parent a7a07b4 commit 54ca948
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 10 deletions.
8 changes: 4 additions & 4 deletions build/dev/run_locally.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

set -eo pipefail

# This script will deploy a standalone DSS instance with docker-compose using
# This script will deploy a standalone DSS instance with docker compose using
# images from Docker Hub.

if [[ -z $(command -v docker-compose) ]]; then
echo "docker-compose is required but not installed. Visit https://docs.docker.com/compose/install/ to install."
if [[ -z $(command -v docker) ]]; then
echo "docker is required but not installed. Visit https://docs.docker.com/install/ to install."
exit 1
fi

Expand All @@ -33,4 +33,4 @@ elif [[ "$DC_COMMAND" == "debug" ]]; then
fi

# shellcheck disable=SC2086
docker-compose -f docker-compose_dss.yaml -p dss_sandbox $DC_COMMAND $DC_OPTIONS
docker compose -f docker-compose_dss.yaml -p dss_sandbox $DC_COMMAND $DC_OPTIONS
4 changes: 2 additions & 2 deletions build/dev/startup/core_service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if [ "$DEBUG_ON" = "1" ]; then
-log_format console \
-dump_requests \
-addr :8082 \
-accepted_jwt_audiences localhost,host.docker.internal,local-dss-core-service,dss_sandbox_local-dss-core-service_1,core-service \
-accepted_jwt_audiences localhost,host.docker.internal,local-dss-core-service,dss_sandbox-local-dss-core-service-1,core-service \
-enable_scd \
-enable_http
else
Expand All @@ -28,7 +28,7 @@ else
-log_format console \
-dump_requests \
-addr :8082 \
-accepted_jwt_audiences localhost,host.docker.internal,local-dss-core-service,dss_sandbox_local-dss-core-service_1,core-service \
-accepted_jwt_audiences localhost,host.docker.internal,local-dss-core-service,dss_sandbox-local-dss-core-service-1,core-service \
-enable_scd \
-enable_http
fi
Expand Down
27 changes: 25 additions & 2 deletions build/dev/wait_for_local_dss.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
#!/bin/bash

OAUTH_CONTAINER="dss_sandbox_local-dss-dummy-oauth_1"
CORE_SERVICE_CONTAINER="dss_sandbox_local-dss-core-service_1"
# Docker Compose V2
OAUTH_CONTAINER="dss_sandbox-local-dss-dummy-oauth-1"
CORE_SERVICE_CONTAINER="dss_sandbox-local-dss-core-service-1"

declare -a localhost_containers=("$OAUTH_CONTAINER" "$CORE_SERVICE_CONTAINER")

# 2 minute timer to prevent infinite looping if a docker issue is present.
timeout_duration=120

# check to see if 2 minutes has elapsed which indicates a problem with the container(s)
check_timeout() {
local start_time="$1"
local error_message="$2"
current_time=$(date +%s)
elapsed_time=$((current_time-start_time))
if ((elapsed_time >= timeout_duration)); then
echo "$error_message"
exit 1
fi
}

# start the timer
start_time=$(date +%s)
for container_name in "${localhost_containers[@]}"; do
last_message=""
while true; do
Expand All @@ -17,13 +36,16 @@ for container_name in "${localhost_containers[@]}"; do
printf '%s' "${new_message}"
last_message="${new_message}"
fi
check_timeout "$start_time" "Timeout reached. Container failed to start. Exiting."
sleep 3
done
if [ -n "${last_message}" ]; then
echo ""
fi
done

# reset the timer
start_time=$(date +%s)
last_message=""
while true; do
health_status="$( docker container inspect -f '{{.State.Health.Status}}' "${CORE_SERVICE_CONTAINER}" )"
Expand All @@ -37,6 +59,7 @@ while true; do
printf '%s' "${new_message}"
last_message="${new_message}"
fi
check_timeout "$start_time" "Timeout reached. Container failed to become available. Exiting."
sleep 3
fi
done
Expand Down
4 changes: 2 additions & 2 deletions monitoring/prober/run_locally.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ else
fi
cd "${BASEDIR}/../.." || exit 1

CORE_SERVICE_CONTAINER="dss_sandbox_local-dss-core-service_1"
OAUTH_CONTAINER="dss_sandbox_local-dss-dummy-oauth_1"
CORE_SERVICE_CONTAINER="dss_sandbox-local-dss-core-service-1"
OAUTH_CONTAINER="dss_sandbox-local-dss-dummy-oauth-1"
declare -a localhost_containers=("$CORE_SERVICE_CONTAINER" "$OAUTH_CONTAINER")

for container_name in "${localhost_containers[@]}"; do
Expand Down

0 comments on commit 54ca948

Please sign in to comment.