Refactor scripts to support both 'docker compose' and 'docker-compose…#63
Refactor scripts to support both 'docker compose' and 'docker-compose…#63
Conversation
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
| hard: 65536 | ||
| working_dir: /gridappsd | ||
| entrypoint: ["/bin/bash", "-c"] | ||
| command: ["tail -f /dev/null | ./run-gridappsd.sh"] |
There was a problem hiding this comment.
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:
- Removing
tail -f /dev/null |entirely and just usecommand: ["./run-gridappsd.sh"] - 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.
| command: ["tail -f /dev/null | ./run-gridappsd.sh"] | |
| command: ["./run-gridappsd.sh"] |
|
|
||
| if [[ $REPLY =~ ^[Yy]$ ]]; then | ||
| echo "Removing all containers..." | ||
| docker rm $(docker ps -a -q) 2>/dev/null |
There was a problem hiding this comment.
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| 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 |
|
|
||
| # 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' ' ' ) |
There was a problem hiding this comment.
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.
| 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 |
Comment out the context path for gridappsd_integration service.
afisher1
left a comment
There was a problem hiding this comment.
simulations are working when pulling gridappsd containers from this branch.
…' commands