From 55c22b681800b6f3cf2ca7ae3ea2f2c05913e4f5 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Tue, 4 Jun 2024 11:34:09 +0530 Subject: [PATCH] Add a stack with a compose file --- README.md | 6 ++++- .../compose/docker-compose-bsc-node.yml | 23 +++++++++++++++++++ .../config/docker-entrypoint.sh | 19 +++++++++++++++ stack-orchestrator/stacks/bsc-node/README.md | 9 ++++++++ 4 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 stack-orchestrator/compose/docker-compose-bsc-node.yml create mode 100755 stack-orchestrator/config/docker-entrypoint.sh create mode 100644 stack-orchestrator/stacks/bsc-node/README.md diff --git a/README.md b/README.md index 6561249..3280f8f 100644 --- a/README.md +++ b/README.md @@ -1 +1,5 @@ -# bsc-stack \ No newline at end of file +# bsc-stack + +Stack definitions for BSC full node deployment. + +[stack documentation](stack-orchestrator/stacks/bsc-node/README.md) diff --git a/stack-orchestrator/compose/docker-compose-bsc-node.yml b/stack-orchestrator/compose/docker-compose-bsc-node.yml new file mode 100644 index 0000000..be99ccf --- /dev/null +++ b/stack-orchestrator/compose/docker-compose-bsc-node.yml @@ -0,0 +1,23 @@ +services: + bsc: + image: ghcr.io/bnb-chain/bsc:1.4.8 + restart: unless-stopped + environment: + volumes: + - ../config/docker-entrypoint.sh:/bsc/docker-entrypoint.sh + - data:/data + - config:/bsc/config + ports: + - 30311:30311 + - 8545:8545 + - 8546:8546 + healthcheck: + test: ["CMD", "nc", "-vz", "localhost", "8545"] + interval: 5s + retries: 5 + start_period: 10s + timeout: 3s + +volumes: + data: + config: diff --git a/stack-orchestrator/config/docker-entrypoint.sh b/stack-orchestrator/config/docker-entrypoint.sh new file mode 100755 index 0000000..d27950f --- /dev/null +++ b/stack-orchestrator/config/docker-entrypoint.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -e + +# TODO: Check for testnet flag +# TODO: Download and unzip the config files + +BSC_CONFIG=${BSC_HOME}/config/config.toml +BSC_GENESIS=${BSC_HOME}/config/genesis.json + +# Init genesis state if geth not exist +DATA_DIR=$(cat ${BSC_CONFIG} | grep -A1 '\[Node\]' | grep -oP '\"\K.*?(?=\")') + +GETH_DIR=${DATA_DIR}/geth +if [ ! -d "$GETH_DIR" ]; then + geth --datadir ${DATA_DIR} init ${BSC_GENESIS} +fi + +# TODO: Check for archive mode flag +exec "geth" "--config" ${BSC_CONFIG} "$@" diff --git a/stack-orchestrator/stacks/bsc-node/README.md b/stack-orchestrator/stacks/bsc-node/README.md new file mode 100644 index 0000000..2c6e37e --- /dev/null +++ b/stack-orchestrator/stacks/bsc-node/README.md @@ -0,0 +1,9 @@ +# bsc-node + +Instructions for running a BSC node + +## Prerequisite + +Downloaded chain snapshot + +