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: 3 additions & 1 deletion env/env.common
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion env/env.frontend
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion env/env.postgres
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
POSTGRES_USER=admin
POSTGRES_PASSWORD=password
POSTGRES_DB=postgres_db
POSTGRES_HOST="db"
POSTGRES_HOST=db
POSTGRES_PORT=5432
33 changes: 33 additions & 0 deletions setup_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"