From 13d04e925696b5f02ef31c757fe7711938c80c94 Mon Sep 17 00:00:00 2001 From: David Boreham Date: Sat, 13 Jul 2024 14:24:23 +0000 Subject: [PATCH] Integrate ping-pub explorer (#872) Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/872 --- .../docker-compose-laconic-explorer.yml | 10 +++++ .../cerc-laconic-console-host/build.sh | 2 +- .../container-build/cerc-ping-pub/Dockerfile | 9 +++++ .../cerc-ping-pub/Dockerfile.base | 8 ++++ .../container-build/cerc-ping-pub/build.sh | 5 ++- .../config/laconic-chaindata-template.json | 22 +++++++++++ .../scripts/start-serving-explorer.sh | 12 ++++++ .../scripts/update-explorer-config.sh | 39 +++++++++++++++++++ .../scripts/apply-runtime-env.sh | 2 + .../data/stacks/mainnet-laconic/stack.yml | 20 +++++----- 10 files changed, 118 insertions(+), 11 deletions(-) create mode 100644 stack_orchestrator/data/compose/docker-compose-laconic-explorer.yml create mode 100644 stack_orchestrator/data/container-build/cerc-ping-pub/Dockerfile create mode 100644 stack_orchestrator/data/container-build/cerc-ping-pub/Dockerfile.base create mode 100644 stack_orchestrator/data/container-build/cerc-ping-pub/config/laconic-chaindata-template.json create mode 100755 stack_orchestrator/data/container-build/cerc-ping-pub/scripts/start-serving-explorer.sh create mode 100755 stack_orchestrator/data/container-build/cerc-ping-pub/scripts/update-explorer-config.sh diff --git a/stack_orchestrator/data/compose/docker-compose-laconic-explorer.yml b/stack_orchestrator/data/compose/docker-compose-laconic-explorer.yml new file mode 100644 index 00000000..ad3e7a8a --- /dev/null +++ b/stack_orchestrator/data/compose/docker-compose-laconic-explorer.yml @@ -0,0 +1,10 @@ +services: + laconic-explorer: + restart: unless-stopped + image: cerc/ping-pub:local + environment: + - LACONIC_LACONICD_API_URL=${LACONIC_LACONICD_API_URL:-http://localhost:1317} + - LACONIC_LACONICD_RPC_URL=${LACONIC_LACONICD_RPC_URL:-http://localhost:26657} + - LACONIC_LACONICD_CHAIN_ID=${LACONIC_LACONICD_CHAIN_ID:-chain-id-not-set} + ports: + - "5173" diff --git a/stack_orchestrator/data/container-build/cerc-laconic-console-host/build.sh b/stack_orchestrator/data/container-build/cerc-laconic-console-host/build.sh index 77a38917..4c015a4f 100755 --- a/stack_orchestrator/data/container-build/cerc-laconic-console-host/build.sh +++ b/stack_orchestrator/data/container-build/cerc-laconic-console-host/build.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Build cerc/laconic-registry-cli +# Build cerc/laconic-console-host source ${CERC_CONTAINER_BASE_DIR}/build-base.sh diff --git a/stack_orchestrator/data/container-build/cerc-ping-pub/Dockerfile b/stack_orchestrator/data/container-build/cerc-ping-pub/Dockerfile new file mode 100644 index 00000000..1282a04d --- /dev/null +++ b/stack_orchestrator/data/container-build/cerc-ping-pub/Dockerfile @@ -0,0 +1,9 @@ +FROM cerc/ping-pub-base:local + +COPY ./scripts/update-explorer-config.sh /scripts +COPY ./config/laconic-chaindata-template.json /config/chains/mainnet/laconic-chaindata-template.json + +EXPOSE 5173 + +WORKDIR /app +CMD ["/scripts/start-serving-explorer.sh"] diff --git a/stack_orchestrator/data/container-build/cerc-ping-pub/Dockerfile.base b/stack_orchestrator/data/container-build/cerc-ping-pub/Dockerfile.base new file mode 100644 index 00000000..62572c47 --- /dev/null +++ b/stack_orchestrator/data/container-build/cerc-ping-pub/Dockerfile.base @@ -0,0 +1,8 @@ +FROM cerc/webapp-base:local + +WORKDIR /app + +COPY . . + +RUN yarn + diff --git a/stack_orchestrator/data/container-build/cerc-ping-pub/build.sh b/stack_orchestrator/data/container-build/cerc-ping-pub/build.sh index 391525dd..5e85f5b8 100755 --- a/stack_orchestrator/data/container-build/cerc-ping-pub/build.sh +++ b/stack_orchestrator/data/container-build/cerc-ping-pub/build.sh @@ -1,5 +1,8 @@ #!/usr/bin/env bash # Build the ping pub image source ${CERC_CONTAINER_BASE_DIR}/build-base.sh +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -docker build -t cerc/ping-pub:local ${build_command_args} -f $CERC_REPO_BASE_DIR/explorer/Dockerfile $CERC_REPO_BASE_DIR/explorer +# Two-stage build is to allow us to pick up both the upstream repo's files, and local files here for config +docker build -t cerc/ping-pub-base:local ${build_command_args} -f $SCRIPT_DIR/Dockerfile.base $CERC_REPO_BASE_DIR/explorer +docker build -t cerc/ping-pub:local ${build_command_args} -f $SCRIPT_DIR/Dockerfile $SCRIPT_DIR diff --git a/stack_orchestrator/data/container-build/cerc-ping-pub/config/laconic-chaindata-template.json b/stack_orchestrator/data/container-build/cerc-ping-pub/config/laconic-chaindata-template.json new file mode 100644 index 00000000..282a61aa --- /dev/null +++ b/stack_orchestrator/data/container-build/cerc-ping-pub/config/laconic-chaindata-template.json @@ -0,0 +1,22 @@ +{ + "chain_name": "LACONIC_LACONICD_CHAIN_ID", + "registry_name": "LACONIC_LACONICD_CHAIN_ID", + "api": [ + {"provider": "LX-one-tree-one-seven", "address": "LACONIC_LACONICD_API_URL"} + ], + "rpc": [ + {"provider": "LX-tendermint-rpc", "address": "LACONIC_LACONICD_RPC_URL"} + ], + "sdk_version": "0.45.1", + "coin_type": "118", + "min_tx_fee": "800", + "addr_prefix": "ethm", + "logo": "/logos/cosmos.svg", + "assets": [{ + "base": "aphoton", + "symbol": "LNT", + "exponent": "6", + "coingecko_id": "cosmos", + "logo": "/logos/cosmos.svg" + }] +} diff --git a/stack_orchestrator/data/container-build/cerc-ping-pub/scripts/start-serving-explorer.sh b/stack_orchestrator/data/container-build/cerc-ping-pub/scripts/start-serving-explorer.sh new file mode 100755 index 00000000..37ff98b4 --- /dev/null +++ b/stack_orchestrator/data/container-build/cerc-ping-pub/scripts/start-serving-explorer.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -e +if [ -n "$CERC_SCRIPT_DEBUG" ]; then + set -x +fi + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +${SCRIPT_DIR}/update-explorer-config.sh + +echo "Starting serving explorer" +yarn serve --host 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 new file mode 100755 index 00000000..d940ba2f --- /dev/null +++ b/stack_orchestrator/data/container-build/cerc-ping-pub/scripts/update-explorer-config.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +set -e +if [ -n "$CERC_SCRIPT_DEBUG" ]; then + set -x +fi + +# Verify that we have the config variables we need +if [[ -z ${LACONIC_LACONICD_API_URL} ]]; then + echo "Error: LACONIC_LACONICD_API_URL not defined" + exit 1 +fi +if [[ -z ${LACONIC_LACONICD_RPC_URL} ]]; then + echo "Error: LACONIC_LACONICD_RPC_URL not defined" + exit 1 +fi +if [[ -z ${LACONIC_LACONICD_CHAIN_ID} ]]; then + echo "Error: LACONIC_LACONICD_CHAIN_ID not defined" + 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-chaindata.json + +# Delete the stock config files +rm -f ${explorer_config_dir}/* + +# Copy in our template file +cp ${config_template_file} ${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} + +if [ -n "$CERC_SCRIPT_DEBUG" ]; then + echo "Updated chaindata file:" + cat ${config_file} +fi diff --git a/stack_orchestrator/data/container-build/cerc-webapp-base/scripts/apply-runtime-env.sh b/stack_orchestrator/data/container-build/cerc-webapp-base/scripts/apply-runtime-env.sh index 0e48303f..2ffb9a1a 100755 --- a/stack_orchestrator/data/container-build/cerc-webapp-base/scripts/apply-runtime-env.sh +++ b/stack_orchestrator/data/container-build/cerc-webapp-base/scripts/apply-runtime-env.sh @@ -4,6 +4,8 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then set -x fi +# TODO: document what this script does + WORK_DIR="${1:-./}" cd "${WORK_DIR}" || exit 1 diff --git a/stack_orchestrator/data/stacks/mainnet-laconic/stack.yml b/stack_orchestrator/data/stacks/mainnet-laconic/stack.yml index e4e6781e..d0986891 100644 --- a/stack_orchestrator/data/stacks/mainnet-laconic/stack.yml +++ b/stack_orchestrator/data/stacks/mainnet-laconic/stack.yml @@ -2,14 +2,15 @@ version: "1.0" name: mainnet-laconic description: "Mainnet laconic node" repos: - - cerc-io/laconicd - - lirewine/debug - - lirewine/crypto - - lirewine/gem - - lirewine/sdk - - cerc-io/laconic-sdk - - cerc-io/laconic-registry-cli - - cerc-io/laconic-console + - git.vdb.to/cerc-io/laconicd + - github.com/lirewine/debug + - github.com/lirewine/crypto + - github.com/lirewine/gem + - github.com/lirewine/sdk + - git.vdb.to/cerc-io/laconic-sdk + - git.vdb.to/cerc-io/laconic-registry-cli + - git.vdb.to/cerc-io/laconic-console + - github.com/ping-pub/explorer npms: - laconic-sdk - laconic-registry-cli @@ -23,7 +24,8 @@ containers: - cerc/laconic-registry-cli - cerc/webapp-base - cerc/laconic-console-host + - cerc/ping-pub pods: - mainnet-laconicd - fixturenet-laconic-console - + - laconic-explorer