diff --git a/env/env.common b/env/env.common index 43d5aaa..16c193b 100644 --- a/env/env.common +++ b/env/env.common @@ -1,4 +1,6 @@ -# Networking configuration +# Networking configuration. +# These addresses are for INSIDE DOCKER communication ONLY. +# do NOT change these based on your custom local setup, MIHAI. ARTIFACTS_URI=http://artifacts:8080 RPC_URI=http://ethereum:8545 DATABASE_API_URI=http://database-api-server:5002 diff --git a/env/env.frontend b/env/env.frontend index 9267a87..bf6ea01 100644 --- a/env/env.frontend +++ b/env/env.frontend @@ -1,5 +1,5 @@ # The endpoints and chain id used by the UI -UI_RPC_URL=http://localhost:8545 +UI_RPC_URL=http://localhost:ETH_PORT UI_ADDRESSES_URL=http://localhost:8080 UI_CHAIN_ID=42069 diff --git a/env/env.postgres b/env/env.postgres index 4249d7f..d4f99d0 100644 --- a/env/env.postgres +++ b/env/env.postgres @@ -1,5 +1,5 @@ POSTGRES_USER=admin POSTGRES_PASSWORD=password POSTGRES_DB=postgres_db -POSTGRES_HOST="db" +POSTGRES_HOST=db POSTGRES_PORT=5432 diff --git a/setup_env.sh b/setup_env.sh index fb435a0..2cbbfe8 100755 --- a/setup_env.sh +++ b/setup_env.sh @@ -179,4 +179,37 @@ if $COMPETITION; then cat env/env.time >>.env fi +# source: https://chat.openai.com/share/ebaf2531-b46c-4aed-aaa6-1e1400a5fd8f +if $PORTS; then + while IFS='=' read -r var value; do + if [[ ! $var =~ ^# ]]; then + changed=false + declared_change=false + temp_file=$(mktemp) + while IFS= read -r line; do + original_line="$line" + # Check if the line contains the variable but doesn't start with it + if [[ "$line" == *"$var"* ]] && [[ ! "$line" == "$var="* ]]; then + line="${line//$var/$value}" # Replace all occurrences of $var with $value + if [ "$original_line" != "$line" ]; then + if [ "$declared_change" = false ]; then + echo "Setting $var to $value:" + declared_change=true + fi + echo " $original_line" + echo " -> $line" + changed=true # Add this line + fi + fi + echo "$line" >> "$temp_file" + done < .env + if [ "$changed" = true ]; then + mv "$temp_file" .env # Replace the original .env file with the modified one + else + rm "$temp_file" # Remove the temporary file if no changes were made + fi + fi + done < env/env.ports +fi + echo "Environment filed created at .env"