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
4 changes: 4 additions & 0 deletions docker-compose/technical/docker-compose.technical.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ services:
- 5601:5601
environment:
- LOGSPOUT=ignore
- SERVER_HOST=0.0.0.0
- SERVER_PORT=5601
depends_on:
- elasticsearch
restart: unless-stopped
Expand Down Expand Up @@ -138,5 +140,7 @@ services:
- GF_AUTH_DISABLE_LOGIN_FORM=true
- GF_ANALYTICS_REPORTING_ENABLED=false
- GF_ANALYTICS_CHECK_FOR_UPDATES=false
- HTTP_PORT=3000
- HTTP_ADDR=0.0.0.0
ports:
- "7000:3000"
53 changes: 53 additions & 0 deletions setup.sh
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
Comment on lines +18 to +19
Copy link
Contributor

@Tristan-WorkGH Tristan-WorkGH Feb 21, 2024

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 (.bashrc for example).
It's up to users to decide how they manage it in their environment.

Copy link
Author

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

Copy link
Contributor

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


# 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"

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; }
Copy link
Contributor

Choose a reason for hiding this comment

The 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

9 changes: 9 additions & 0 deletions stop.sh
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; }