From b7d99fcd0864395564da9fc4a1d71a0575b078f8 Mon Sep 17 00:00:00 2001 From: Vivek Teega Date: Wed, 12 Jun 2024 20:08:31 +0530 Subject: [PATCH] Added changes to entrypoint.sh for frontend to take in IP of backend container for RPC connection --- README.md | 31 ++++++++++++------------------- entrypoint.sh | 21 +++++++++++++++++++-- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index c64951c..6fb20cb 100644 --- a/README.md +++ b/README.md @@ -15,17 +15,20 @@ docker build -f Dockerfile -t vivekteega/blockbook:1.0.0 . docker volume create blockbook -# Run backend in "it" mode -docker run -it --mount source=blockbook,target=/opt -p 38366:38366 -p 8066:8066 vivekteega/blockbook:1.0.0 backend +docker network create blockbook -# Run backend in daemon mode -docker run -d --mount source=blockbook,target=/ -p 38366:38366 -p 8066:8066 vivekteega/blockbook:1.0.0 backend +# Run backend in "it" mode for testing +docker run -it --name blockbook-backend --mount source=blockbook,target=/opt -p 38366:38366 -p 8066:8066 --network=blockbook vivekteega/blockbook:1.0.0 backend -# Run frontend in "it" mode -docker run -it --mount source=blockbook,target=/opt -p 9166:9166 -p 9066:9066 vivekteega/blockbook:1.0.0 frontend +# Run backend in daemon mode for production +docker run -d --name blockbook-backend --mount source=blockbook,target=/opt -p 38366:38366 -p 8066:8066 --network=blockbook vivekteega/blockbook:1.0.0 backend -# Run frontend in it mode -docker run -d --mount source=blockbook,target=/ -p 9166:9166 -p 9066:9066 vivekteega/blockbook:1.0.0 frontend + +# Run frontend in "it" mode for testing +docker run -it --name blockbook-frontend --mount source=blockbook,target=/opt -p 9166:9166 -p 9066:9066 --network=blockbook vivekteega/blockbook:1.0.0 frontend 172.20.0.2 + +# Run frontend in daemon mode for production +docker run -d --name blockbook-frontend --mount source=blockbook,target=/opt -p 9166:9166 -p 9066:9066 --network=blockbook vivekteega/blockbook:1.0.0 frontend 172.20.0.2 ``` ## Building & running backend image @@ -38,14 +41,4 @@ docker volume create blockbook docker run -it --mount source=blockbook,target=/opt/coins -p vivekteega/blockbook-backend:1.0. docker run -d --mount source=blockbook,target=/opt/coins -p 38366:38366 -p 8066:8066 vivekteega/blockbook-backend:1.0.0 -``` - -## Building & running frontend image - -``` -docker build -t vivekteega/blockbook-frontend:1.0.0 -f Dockerfile_frontend . - -docker run -it --mount source=blockbook,target=/opt/coins -p 9166:9166 -p 9066:9066 vivekteega/blockbook-frontend:1.0.0 - -docker run -d --mount source=blockbook,target=/opt/coins -p 9166:9166 -p 9066:9066 vivekteega/blockbook-frontend:1.0.0 -``` +``` \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index 610c96a..fdbaf6b 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,9 +1,26 @@ #!/bin/sh set -e +# Function to update config file +update_config_file() { + local config_path=$1 + local new_ip=$2 + if [ -n "$new_ip" ]; then + echo "Updating config file: $config_path with IP: $new_ip" + # Replace IP address in the config file + sed -i "s/127.0.0.1/$new_ip/g" "$config_path" + fi +} + case "$1" in "frontend") - echo "Running frontend command" + if [ -z "$2" ]; then + echo "Missing parameter: new_ip for frontend" + exit 1 + fi + new_ip=$2 + echo "Running frontend command with IP: $new_ip" + update_config_file "/opt/coins/blockbook/flo/config/blockchaincfg.json" "$new_ip" cd /opt/coins/blockbook/flo exec /opt/coins/blockbook/flo/bin/blockbook -blockchaincfg=/opt/coins/blockbook/flo/config/blockchaincfg.json -datadir=/opt/coins/data/flo/blockbook/db -sync -internal=:9066 -public=:9166 -certfile=/opt/coins/blockbook/flo/cert/blockbook -explorer= -log_dir=/opt/coins/blockbook/flo/logs -dbcache=1073741824 ;; @@ -14,7 +31,7 @@ case "$1" in ;; *) echo "Invalid option: $1" - echo "Usage: $0 {frontend|backend}" + echo "Usage: $0 {frontend new_ip|backend}" exit 1 ;; esac