-
Notifications
You must be signed in to change notification settings - Fork 16
Refactor scripts to support both 'docker compose' and 'docker-compose… #63
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
There was a problem hiding this 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.
docker-compose.yml
Outdated
| hard: 65536 | ||
| working_dir: /gridappsd | ||
| entrypoint: ["/bin/bash", "-c"] | ||
| command: ["tail -f /dev/null | ./run-gridappsd.sh"] |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
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:
- 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 |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
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| 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' ' ' ) |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
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.
| 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 |
| ports: | ||
| - "3000:3000" | ||
| environment: | ||
| PGRST_DB_URI: postgres://authenticator:mysecretpassword@timescaledb:5432/${TIMESCALE_DB:-gridappsd_ts} |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hardcoded password 'mysecretpassword' in the database URI is a security risk. Even though this is a template file (.dst), it sets a bad precedent. Consider using an environment variable like ${AUTHENTICATOR_PASSWORD:-mysecretpassword} and document that users should change this in production.
| PGRST_DB_URI: postgres://authenticator:mysecretpassword@timescaledb:5432/${TIMESCALE_DB:-gridappsd_ts} | |
| # WARNING: Change AUTHENTICATOR_PASSWORD in production! | |
| PGRST_DB_URI: postgres://authenticator:${AUTHENTICATOR_PASSWORD:-mysecretpassword}@timescaledb:5432/${TIMESCALE_DB:-gridappsd_ts} |
| command: ["tail -f /dev/null"] | ||
|
|
||
| timescaledb: | ||
| image: timescale/timescaledb-ha:pg16.11-ts2.24.0-oss |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using a less specific version pin (e.g., pg16-ts2.24-oss or pg16-latest) or making it configurable via environment variable. The current pin to pg16.11-ts2.24.0-oss may become outdated quickly and could miss important security patches. Alternatively, add a comment explaining why this specific version is required.
| image: timescale/timescaledb-ha:pg16.11-ts2.24.0-oss | |
| # Use environment variable TIMESCALE_IMAGE to override the TimescaleDB image version. | |
| # Default is a less specific tag to allow for security updates. | |
| image: ${TIMESCALE_IMAGE:-timescale/timescaledb-ha:pg16-ts2.24-oss} |
| - ../apps/proven-docker/timeseriesdb/init-db.sh:/docker-entrypoint-initdb.d/01-init-db.sh | ||
| - ../apps/proven-docker/timeseriesdb/create_roles.sql:/docker-entrypoint-initdb.d/sql/create_roles.sql | ||
| - ../apps/proven-docker/timeseriesdb/create_tables.sql:/docker-entrypoint-initdb.d/sql/create_tables.sql | ||
| - ../apps/proven-docker/timeseriesdb/grant_privs.sql:/docker-entrypoint-initdb.d/sql/grant_privs.sql |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The volume mappings reference paths outside the gridappsd-docker repository (../Centralized/ and ../apps/proven-docker/). This creates a dependency on external directory structure that may not exist for users. Consider either:
- Including these files in the gridappsd-docker repository
- Providing clear documentation about required external repositories
- Adding error handling in the scripts to check if these paths exist before starting
| build: | ||
| context: ../Centralized/gridappsd_integration | ||
| dockerfile: Dockerfile |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The build context references ../Centralized/gridappsd_integration which is outside the gridappsd-docker repository. This will fail if users don't have this external repository cloned. See comment on lines 43-46 for the same issue with volume mappings.
…' commands