From 951580888aeebdc3e6c12741720676229012dc7d Mon Sep 17 00:00:00 2001 From: Adw8 Date: Wed, 17 Jul 2024 10:00:46 +0530 Subject: [PATCH] Use template for setting config variables for faucet --- README.md | 2 ++ .../compose/docker-compose-laconic-faucet.yml | 4 ++++ .../laconic-faucet/config-template.toml | 11 ++++++++++ .../config/laconic-faucet/start-faucet.sh | 20 +++++++++++++------ .../cerc-laconic-faucet/build.sh | 2 +- .../stacks/laconic-faucet/README.md | 13 +++--------- 6 files changed, 35 insertions(+), 17 deletions(-) create mode 100644 stack-orchestrator/config/laconic-faucet/config-template.toml mode change 100644 => 100755 stack-orchestrator/container-build/cerc-laconic-faucet/build.sh diff --git a/README.md b/README.md index 10d00b6..8e656ed 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,9 @@ Stacks to run a node for laconic testnet - [testnet-laconicd stack documentation](stack-orchestrator/stacks/testnet-laconicd/README.md) - [laconic-console stack documentation](stack-orchestrator/stacks/laconic-console/README.md) (to run laconic registry CLI and console standalone) +- [laconic-faucet stack documentation](stack-orchestrator/stacks/laconic-faucet/README.md) ## Testnet onboarding demo Follow steps in [testnet-onboarding-demo.md](./testnet-onboarding-demo.md) to run demo for onboarding testnet participants in laconicd chain + diff --git a/stack-orchestrator/compose/docker-compose-laconic-faucet.yml b/stack-orchestrator/compose/docker-compose-laconic-faucet.yml index fc40f8e..542d96c 100644 --- a/stack-orchestrator/compose/docker-compose-laconic-faucet.yml +++ b/stack-orchestrator/compose/docker-compose-laconic-faucet.yml @@ -5,9 +5,13 @@ services: environment: CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} CERC_FAUCET_KEY: ${CERC_FAUCET_KEY} + CERC_RPC_ENDPOINT: ${CERC_RPC_ENDPOINT} entrypoint: "bash" command: "./start-faucet.sh" volumes: - ../config/laconic-faucet/start-faucet.sh:/app/start-faucet.sh + - ../config/laconic-faucet/config-template.toml:/app/environments/config-template.toml ports: - "3000:3000" + extra_hosts: + - "host.docker.internal:host-gateway" diff --git a/stack-orchestrator/config/laconic-faucet/config-template.toml b/stack-orchestrator/config/laconic-faucet/config-template.toml new file mode 100644 index 0000000..3fdcf85 --- /dev/null +++ b/stack-orchestrator/config/laconic-faucet/config-template.toml @@ -0,0 +1,11 @@ +[upstream] + rpcEndpoint = "REPLACE_WITH_RPC_ENDPOINT" + chainId = "laconic_9000-1" + denom = "photon" + prefix = "laconic" + faucetKey = "REPLACE_WITH_CERC_FAUCET_KEY" + +[server] + transferAmount = 1000000 + dailyLimit = 3000000 + dbDir = "db" diff --git a/stack-orchestrator/config/laconic-faucet/start-faucet.sh b/stack-orchestrator/config/laconic-faucet/start-faucet.sh index 4348125..6d8ca3f 100644 --- a/stack-orchestrator/config/laconic-faucet/start-faucet.sh +++ b/stack-orchestrator/config/laconic-faucet/start-faucet.sh @@ -6,16 +6,24 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then set -x fi -toml_file="./environments/local.toml" +config_template=$(cat environments/config-template.toml) +local_config="./environments/local.toml" # Set faucet key from env faucet_key=${CERC_FAUCET_KEY} -echo "The faucet key is $faucet_key" -# Update the faucetKey in local.toml -sed -i "s/faucetKey = \"\"/faucetKey = \"$faucet_key\"/" "$toml_file" -echo "Updated faucetKey in local.toml" +rpc_endpoint=${CERC_RPC_ENDPOINT} +echo "The RPC endpoint is $rpc_endpoint" + +FAUCET_CONFIG=$(echo "$config_template" | \ + sed -E "s|REPLACE_WITH_CERC_FAUCET_KEY|${faucet_key}|; s|REPLACE_WITH_RPC_ENDPOINT|${rpc_endpoint}|") + +echo "$FAUCET_CONFIG" > $local_config + +echo "Updated config file" +echo "Config.toml:" +cat $local_config # Start node-js server +echo "Starting faucet..." yarn start-faucet -echo "Started faucet" diff --git a/stack-orchestrator/container-build/cerc-laconic-faucet/build.sh b/stack-orchestrator/container-build/cerc-laconic-faucet/build.sh old mode 100644 new mode 100755 index 2d7a3d7..afa89a1 --- a/stack-orchestrator/container-build/cerc-laconic-faucet/build.sh +++ b/stack-orchestrator/container-build/cerc-laconic-faucet/build.sh @@ -2,4 +2,4 @@ # Build cerc/laconic-faucet source ${CERC_CONTAINER_BASE_DIR}/build-base.sh -docker build -t cerc/laconic-faucet:local ${build_command_args} ${CERC_REPO_BASE_DIR}/laconic-faucet +docker build -t cerc/laconic-faucet:local ${build_command_args} ${CERC_REPO_BASE_DIR}/laconic-testnet-faucet diff --git a/stack-orchestrator/stacks/laconic-faucet/README.md b/stack-orchestrator/stacks/laconic-faucet/README.md index 60d82c2..ee26c3d 100644 --- a/stack-orchestrator/stacks/laconic-faucet/README.md +++ b/stack-orchestrator/stacks/laconic-faucet/README.md @@ -17,10 +17,10 @@ Instructions for running the laconic faucet server * Clone the stack repo: ```bash - laconic-so fetch-stack git.vdb.to/cerc-io/laconic-testnet-faucet + laconic-so fetch-stack git.vdb.to/cerc-io/testnet-laconicd-stack ``` -* Clone the laconic-faucet: +* Clone the laconic-faucet respository: ```bash laconic-so --stack ~/cerc/testnet-laconicd-stack/stack-orchestrator/stacks/laconic-faucet setup-repositories @@ -57,20 +57,13 @@ Instructions for running the laconic faucet server laconic-so --stack ~/cerc/testnet-laconicd-stack/stack-orchestrator/stacks/laconic-faucet deploy create --spec-file laconic-faucet-spec.yml --deployment-dir laconic-faucet-deployment ``` - - ## Configuration * Inside the `laconic-faucet-deployment` deployment directory, open `config.env` file and set following env variables: ```bash CERC_FAUCET_KEY= + CERC_RPC_ENDPOINT= ``` ## Start the deployment