From 7fb9ccdfd80ba2c4b84937a6d4bd6692efe2c635 Mon Sep 17 00:00:00 2001 From: David Boreham Date: Sun, 14 Jul 2024 20:51:11 -0600 Subject: [PATCH] Work around explorer host name sensitivity --- .../container-build/cerc-ping-pub/Dockerfile | 2 +- .../scripts/update-explorer-config.sh | 31 +++++++++++++------ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/stack_orchestrator/data/container-build/cerc-ping-pub/Dockerfile b/stack_orchestrator/data/container-build/cerc-ping-pub/Dockerfile index 5cbbc3a4..d5ee238e 100644 --- a/stack_orchestrator/data/container-build/cerc-ping-pub/Dockerfile +++ b/stack_orchestrator/data/container-build/cerc-ping-pub/Dockerfile @@ -2,7 +2,7 @@ FROM cerc/ping-pub-base:local COPY ./scripts/update-explorer-config.sh /scripts COPY ./scripts/start-serving-explorer.sh /scripts -COPY ./config/laconic-chaindata-template.json /config/chains/mainnet/laconic-chaindata-template.json +COPY ./config/laconic-chaindata-template.json /config/chains/laconic-chaindata-template.json EXPOSE 5173 diff --git a/stack_orchestrator/data/container-build/cerc-ping-pub/scripts/update-explorer-config.sh b/stack_orchestrator/data/container-build/cerc-ping-pub/scripts/update-explorer-config.sh index 6128092b..812fa5bd 100755 --- a/stack_orchestrator/data/container-build/cerc-ping-pub/scripts/update-explorer-config.sh +++ b/stack_orchestrator/data/container-build/cerc-ping-pub/scripts/update-explorer-config.sh @@ -18,22 +18,35 @@ if [[ -z ${LACONIC_LACONICD_CHAIN_ID} ]]; then exit 1 fi -explorer_config_dir=/app/chains/mainnet -config_template_file=/config/chains/mainnet/laconic-chaindata-template.json -config_file=${explorer_config_dir}/laconic.json +# Ping-pub explorer has endlessly confusing behavior where it +# infers the directory from which to load chain configuration files +# by the presence or absense of the substring "testnet" in the host name +# (browser side -- the host name of the host in the address bar of the browser) +# Accordingly we configure our network in both directories in order to +# subvert this lunacy. +explorer_mainnet_config_dir=/app/chains/mainnet +explorer_testnet_config_dir=/app/chains/testnet +config_template_file=/config/chains/laconic-chaindata-template.json +chain_config_name=laconic.json +mainnet_config_file=${explorer_mainnet_config_dir}/${chain_config_name} +testnet_config_file=${explorer_testnet_config_dir}/${chain_config_name} # Delete the stock config files -rm -f ${explorer_config_dir}/* +rm -f ${explorer_testnet_config_dir}/* +rm -f ${explorer_mainnet_config_dir}/* # Copy in our template file -cp ${config_template_file} ${config_file} +cp ${config_template_file} ${mainnet_config_file} # Update the file with the config variables -sed -i "s#LACONIC_LACONICD_API_URL#${LACONIC_LACONICD_API_URL}#g" ${config_file} -sed -i "s#LACONIC_LACONICD_RPC_URL#${LACONIC_LACONICD_RPC_URL}#g" ${config_file} -sed -i "s#LACONIC_LACONICD_CHAIN_ID#${LACONIC_LACONICD_CHAIN_ID}#g" ${config_file} +sed -i "s#LACONIC_LACONICD_API_URL#${LACONIC_LACONICD_API_URL}#g" ${mainnet_config_file} +sed -i "s#LACONIC_LACONICD_RPC_URL#${LACONIC_LACONICD_RPC_URL}#g" ${mainnet_config_file} +sed -i "s#LACONIC_LACONICD_CHAIN_ID#${LACONIC_LACONICD_CHAIN_ID}#g" ${mainnet_config_file} if [ -n "$CERC_SCRIPT_DEBUG" ]; then echo "Updated chaindata file:" - cat ${config_file} + cat ${mainnet_config_file} fi + +# Copy over to the testnet directory +cp ${mainnet_config_file} ${testnet_config_file}