Skip to content

Refactor scripts to support both 'docker compose' and 'docker-compose…#63

Merged
afisher1 merged 15 commits intodevelopfrom
new-docker-syntax
Feb 18, 2026
Merged

Refactor scripts to support both 'docker compose' and 'docker-compose…#63
afisher1 merged 15 commits intodevelopfrom
new-docker-syntax

Conversation

@craig8
Copy link
Copy Markdown
Contributor

@craig8 craig8 commented Nov 18, 2025

…' commands

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the Docker Compose-related scripts to support both the newer docker compose command (built into Docker) and the older standalone docker-compose command, improving compatibility across different Docker installation versions.

Key Changes:

  • Added automatic detection logic to identify and use the available Docker Compose command variant
  • Updated all Docker Compose command invocations to use the dynamically detected command
  • Enhanced error handling with clear messages when neither command is found

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
stop.sh Added detect_docker_compose() function and updated all docker-compose command calls to use the detected variant
run.sh Added detect_docker_compose() function, updated all command calls, and improved container ID detection logic with fallback handling
docker-compose.yml Removed trailing whitespace and added ulimits configuration for blazegraph service
.gitignore Added *.log pattern to ignore log files

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread run.sh Outdated
Comment thread docker-compose.yml
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated 8 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md
Comment thread docker-compose.yml Outdated
hard: 65536
working_dir: /gridappsd
entrypoint: ["/bin/bash", "-c"]
command: ["tail -f /dev/null | ./run-gridappsd.sh"]
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

The pipe operator (|) in the command array format won't work as expected. When using array format with ["/bin/bash", "-c"] entrypoint, the pipe needs to be passed as a single string argument to bash. However, tail -f /dev/null will run indefinitely and block the execution of ./run-gridappsd.sh. The logic appears incorrect - this would never reach the script execution. Consider either:

  1. Removing tail -f /dev/null | entirely and just use command: ["./run-gridappsd.sh"]
  2. Or if the intent is to keep the container alive, the run-gridappsd.sh script should handle that internally based on the AUTOSTART environment variable.
Suggested change
command: ["tail -f /dev/null | ./run-gridappsd.sh"]
command: ["./run-gridappsd.sh"]

Copilot uses AI. Check for mistakes.
Comment thread remove_all_containers.sh

if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "Removing all containers..."
docker rm $(docker ps -a -q) 2>/dev/null
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

The command substitution $(docker ps -a -q) will fail if there are no containers, causing docker rm to run without arguments and print an error message. Consider checking if there are containers first:

container_ids=$(docker ps -a -q)
if [ -n "$container_ids" ]; then
    docker rm $container_ids
else
    echo "No containers to remove."
fi
Suggested change
docker rm $(docker ps -a -q) 2>/dev/null
container_ids=$(docker ps -a -q)
if [ -n "$container_ids" ]; then
docker rm $container_ids 2>/dev/null
else
echo "No containers to remove."
fi

Copilot uses AI. Check for mistakes.
Comment thread utils.sh

# Build compose files string from docker-compose.d/*.yml
get_compose_files() {
local files=$( ls -1 docker-compose.d/*yml 2>/dev/null | sed -e 's/^/-f /g' | tr '\n' ' ' )
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

Using ls in a command substitution is fragile and subject to word splitting issues. If filenames contain spaces or special characters, this will break. Consider using a more robust approach:

get_compose_files() {
  local files=""
  for f in docker-compose.d/*.yml 2>/dev/null; do
    [ -f "$f" ] && files="$files -f $f"
  done
  echo "-f docker-compose.yml$files"
}

Or use arrays for safer handling of filenames with special characters.

Suggested change
local files=$( ls -1 docker-compose.d/*yml 2>/dev/null | sed -e 's/^/-f /g' | tr '\n' ' ' )
local files=""
for f in docker-compose.d/*.yml 2>/dev/null; do
[ -f "$f" ] && files="$files -f \"$f\""
done

Copilot uses AI. Check for mistakes.
Comment thread docker-compose.d/docker-compose_timescaledb.yml.dst
Comment thread docker-compose.d/docker-compose_timescaledb.yml.dst
Comment thread docker-compose.d/docker-compose_timescaledb.yml.dst
Comment thread docker-compose.d/docker-compose_timescaledb.yml.dst
@craig8 craig8 requested a review from afisher1 December 11, 2025 19:07
@craig8 craig8 mentioned this pull request Dec 19, 2025
12 tasks
Comment thread docker-compose.yml
Comment thread docker-compose.yml
Comment thread docker-compose.yml
Comment thread docker-compose.yml
Comment thread README.md
Comment out the context path for gridappsd_integration service.
@afisher1 afisher1 changed the base branch from main to develop February 18, 2026 19:48
Copy link
Copy Markdown
Contributor

@afisher1 afisher1 left a comment

Choose a reason for hiding this comment

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

simulations are working when pulling gridappsd containers from this branch.

@afisher1 afisher1 merged commit 5e0e24f into develop Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants