Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ gridappsdmysql
applications
services
.env
*.log
10 changes: 7 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ services:
# GRIDAPPSD_USER: system
# GRIDAPPSD_PASS: manager
depends_on:
- gridappsd
- gridappsd
#volumes:
# Change upto the : where you have your git repository on your
# computer. The : delinates between the host (your computer) and
# the container (inside of the container)
# the container (inside of the container)
#
# In order for the app to be registered with gridappsd a configuration
# file must be mounted or copied to /appconfig
Expand All @@ -22,12 +22,16 @@ services:
# reflected inside the container.
#
#- $HOME/git/gridappsd-sample-app/:/usr/src/gridappsd-sample

blazegraph:
image: gridappsd/blazegraph${GRIDAPPSD_TAG}
container_name: blazegraph
ports:
- 8889:8080
ulimits:
nofile:
soft: 65536
hard: 65536
Comment on lines +31 to +34
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The addition of ulimits configuration for the blazegraph service appears to be unrelated to the stated purpose of this PR (refactoring scripts to support both 'docker compose' and 'docker-compose' commands). Consider moving this infrastructure change to a separate PR for better change tracking and review focus.

Suggested change
ulimits:
nofile:
soft: 65536
hard: 65536

Copilot uses AI. Check for mistakes.

redis:
image: redis:3.2.11-alpine
Expand Down
43 changes: 35 additions & 8 deletions run.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
#!/bin/bash

# Detect docker compose command (newer 'docker compose' vs older 'docker-compose')
detect_docker_compose() {
if docker compose version &>/dev/null; then
echo "docker compose"
elif docker-compose --version &>/dev/null; then
echo "docker-compose"
else
echo ""
fi
}
Comment on lines +3 to +12
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The detect_docker_compose function is duplicated identically in both run.sh and stop.sh. Consider extracting this common functionality into a shared utility script (e.g., docker-compose-utils.sh) that can be sourced by both scripts. This would improve maintainability and ensure consistency if the detection logic needs to be updated in the future.

Example:

# In docker-compose-utils.sh
detect_docker_compose() {
  if docker compose version &>/dev/null; then
    echo "docker compose"
  elif docker-compose --version &>/dev/null; then
    echo "docker-compose"
  else
    echo ""
  fi
}

# In run.sh and stop.sh
source ./docker-compose-utils.sh
Suggested change
# Detect docker compose command (newer 'docker compose' vs older 'docker-compose')
detect_docker_compose() {
if docker compose version &>/dev/null; then
echo "docker compose"
elif docker-compose --version &>/dev/null; then
echo "docker-compose"
else
echo ""
fi
}
# Source shared docker compose utility functions
source ./docker-compose-utils.sh

Copilot uses AI. Check for mistakes.

DOCKER_COMPOSE_CMD=$(detect_docker_compose)

if [ -z "$DOCKER_COMPOSE_CMD" ]; then
echo "Error: Neither 'docker compose' nor 'docker-compose' command found"
echo "Please install Docker Compose"
exit 1
fi

echo "Using: $DOCKER_COMPOSE_CMD"

usage () {
/bin/echo "Usage: $0 [-d] [-p] [-r [ip address]] [-t tag]"
/bin/echo " -d debug"
Expand Down Expand Up @@ -75,7 +96,7 @@ debug_msg() {
pull_containers() {
echo " "
echo "Pulling updated containers"
docker-compose $compose_files pull --ignore-pull-failures
$DOCKER_COMPOSE_CMD $compose_files pull --ignore-pull-failures
}

http_status_container() {
Expand All @@ -99,7 +120,7 @@ http_status_container() {
sleep 1
count=`expr $count + 1`
done

debug_msg "tried $url $count times, max is $maxcount"
if [ $count -ge $maxcount ]; then
echo "Error contacting $url ($status)"
Expand Down Expand Up @@ -166,7 +187,7 @@ if [ ! -f "$data_dir/$mysql_file" ]; then
curl -s -o "$data_dir/$mysql_file" "https://raw.githubusercontent.com/GRIDAPPSD/Bootstrap/master/$mysql_file"
if [ -f $data_dir/$mysql_file ]; then
sed -i'.bak' -e "s/'gridappsd'@'localhost'/'gridappsd'@'%'/g" $data_dir/$mysql_file
# clean up
# clean up
rm $data_dir/${mysql_file}.bak
else
echo "Error downloading $data_dir/$mysql_file"
Expand All @@ -181,15 +202,13 @@ echo "Getting blazegraph status"
status=$(curl -s --head -w %{http_code} "$url_blazegraph" -o /dev/null)
debug_msg "blazegraph curl status: $status"

#if [ $GRIDAPPSD_TAG == ':develop' ]; then
pull_containers
#fi

echo " "
echo "Starting the docker containers"
echo " "
echo " "
docker-compose $compose_files up -d
$DOCKER_COMPOSE_CMD $compose_files up -d
container_status=$?

if [ $container_status -ne 0 ]; then
Expand Down Expand Up @@ -233,8 +252,16 @@ echo "Containers are running"
echo "$url_viz"

if tty -s ; then
gridappsd_container=`docker inspect --format="{{.Name}}" \`docker-compose $compose_files ps -q gridappsd\` | sed 's:/::'`

# Try to get container ID from docker-compose ps, fall back to container name
gridappsd_container_id=$($DOCKER_COMPOSE_CMD $compose_files ps -q gridappsd 2>/dev/null)

if [ -z "$gridappsd_container_id" ]; then
# Fall back to using the container name directly
gridappsd_container="gridappsd"
else
gridappsd_container=$(docker inspect --format="{{.Name}}" "$gridappsd_container_id" | sed 's:^/::')
fi

echo " "
echo "Connecting to the gridappsd container"
echo "docker exec -it $gridappsd_container /bin/bash"
Expand Down
23 changes: 21 additions & 2 deletions stop.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
#!/bin/bash

# Detect docker compose command (newer 'docker compose' vs older 'docker-compose')
detect_docker_compose() {
if docker compose version &>/dev/null; then
echo "docker compose"
elif docker-compose --version &>/dev/null; then
echo "docker-compose"
else
echo ""
fi
}

DOCKER_COMPOSE_CMD=$(detect_docker_compose)

if [ -z "$DOCKER_COMPOSE_CMD" ]; then
echo "Error: Neither 'docker compose' nor 'docker-compose' command found"
echo "Please install Docker Compose"
exit 1
fi

echo "Using: $DOCKER_COMPOSE_CMD"

usage () {
/bin/echo "Usage: $0 [-c|w]"
Expand All @@ -12,7 +31,7 @@ usage () {
clean_up () {
echo " "
echo "Removing docker containers"
docker-compose $compose_files down
$DOCKER_COMPOSE_CMD $compose_files down

# remove the dump files if -c option
if [ $cleanup -eq 1 ]; then
Expand Down Expand Up @@ -105,7 +124,7 @@ shift `expr $OPTIND - 1`

echo " "
echo "Shutting down the docker containers"
docker-compose $compose_files stop
$DOCKER_COMPOSE_CMD $compose_files stop

if [ $cleanup -gt 0 ]; then
clean_up
Expand Down