-
Notifications
You must be signed in to change notification settings - Fork 7
Simple deployment script #392
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
Open
Haigutus
wants to merge
6
commits into
gridsuite:main
Choose a base branch
from
Baltic-RCC:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c4ccf96
Create setup.sh
Haigutus d5c2aa5
- Removed dynamic database path setting. - Added IP replacement.
Haigutus 16a777f
fixed path for ip update
Haigutus e920ce6
Replace IP in folders. Added stop.sh
Haigutus 13ca3a4
switched to suite
Haigutus 3a3d34c
Update docker-compose.technical.yml
Haigutus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Function to download a file if it does not exist | ||
| download_file() { | ||
| local url=$1 | ||
| local target_path=$2 | ||
|
|
||
| # Check if the file already exists to avoid re-downloading | ||
| if [ ! -f "$target_path" ]; then | ||
| echo "Downloading $(basename "$target_path")..." | ||
| curl -s -L "$url" -o "$target_path" || { echo "Failed to download $(basename "$target_path"). Exiting."; exit 1; } | ||
| else | ||
| echo "$(basename "$target_path") already exists. Skipping download." | ||
| fi | ||
| } | ||
|
|
||
| # Set databases path | ||
| GRIDSUITE_DATABASES=$(realpath "DATABASES") | ||
| export GRIDSUITE_DATABASES | ||
|
|
||
| # Create the subdirectories with the required file mode | ||
| mkdir -p "$GRIDSUITE_DATABASES/cases" "$GRIDSUITE_DATABASES/postgres" "$GRIDSUITE_DATABASES/elasticsearch" "$GRIDSUITE_DATABASES/init" || { echo "Failed to create directories. Exiting."; exit 1; } | ||
|
|
||
| # Change the file mode to 777 for all subdirectories | ||
| chmod 777 "$GRIDSUITE_DATABASES/cases" "$GRIDSUITE_DATABASES/postgres" "$GRIDSUITE_DATABASES/elasticsearch" "$GRIDSUITE_DATABASES/init" || { echo "Failed to set permissions. Exiting."; exit 1; } | ||
|
|
||
| echo "Folder structure created under $GRIDSUITE_DATABASES with required permissions." | ||
|
|
||
| # Populate init folder | ||
| download_file "https://raw.githubusercontent.com/gridsuite/geo-data/main/src/test/resources/geo_data_substations.json" "$GRIDSUITE_DATABASES/init/geo_data_substations.json" | ||
| download_file "https://raw.githubusercontent.com/gridsuite/geo-data/main/src/test/resources/geo_data_lines.json" "$GRIDSUITE_DATABASES/init/geo_data_lines.json" | ||
| download_file "https://raw.githubusercontent.com/gridsuite/cgmes-boundary-server/main/src/test/resources/business_processes.json" "$GRIDSUITE_DATABASES/init/business_processes.json" | ||
| download_file "https://raw.githubusercontent.com/gridsuite/cgmes-boundary-server/main/src/test/resources/tsos.json" "$GRIDSUITE_DATABASES/init/tsos.json" | ||
Tristan-WorkGH marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| echo "Configuration files downloaded." | ||
|
|
||
| # Update IP | ||
| # Capture the first IP address into a variable | ||
| target_ip=$(hostname -I | awk '{print $1}') | ||
|
|
||
| # Use the variable as needed | ||
| echo "The target IP address is: $target_ip" | ||
|
|
||
| # Find all files in the directory and its subdirectories | ||
| find "docker-compose" -type f | while read -r file; do | ||
| # Use sed to replace 'localhost' and '172.17.0.1' with 'target_ip' in-place | ||
| sed -i "s/localhost/$target_ip/g" "$file" | ||
| sed -i "s/172.17.0.1/$target_ip/g" "$file" | ||
| done | ||
|
|
||
| # Assuming the Docker Compose file is relative to the script's execution path | ||
| cd docker-compose/explicit-profiles || { echo "Failed to change directory. Check if the path is correct. Exiting."; exit 1; } | ||
| docker compose --profile suite up -d || { echo "Docker Compose failed to start. Check Docker setup. Exiting."; exit 1; } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We prefer to pass the profile name in a parameter to start and stop |
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Set databases path | ||
| GRIDSUITE_DATABASES=$(realpath "DATABASES") | ||
| export GRIDSUITE_DATABASES | ||
|
|
||
| # Assuming the Docker Compose file is relative to the script's execution path | ||
| cd docker-compose/explicit-profiles || { echo "Failed to change directory. Check if the path is correct. Exiting."; exit 1; } | ||
| docker compose --profile suite stop || { echo "Docker Compose failed to stop. Exiting."; exit 1; } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
We don't support a "DATABASES" env var, we define directly "GRIDSUITE_DATABASES" in our env (
.bashrcfor example).It's up to users to decide how they manage it in their environment.
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.
here it creates default folder DATABASES, it is not an ENV variable, the ENV variable is still "GRIDSUITE_DATABASES". One could add check, if it is already defined, then it will not be set again
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.
Yes we prefer to create GRIDSUITE_DATABASES env only if it does not exist