-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the Dockerfile to generate docker image that can run lava node. (Implemented using the artifacts in docker/ directory.) To start a lava node in a container, run the command: docker-compose --profile node -f docker/docker-compose.yml up It will execute the script `start_node.sh` (from docker/), which follows the instructions for starting a node (with cosmovisor).
- Loading branch information
1 parent
41ca04b
commit e70ae4e
Showing
4 changed files
with
206 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
version: '3.9' | ||
|
||
x-env: &env-common | ||
environment: | ||
- LAVA_EXTERNAL_IP=${LAVA_EXTERNAL_IP:-0.0.0.0} | ||
|
||
services: | ||
|
||
lava-node: | ||
build: .. | ||
image: lava:latest | ||
command: "node" | ||
<<: *env-common | ||
ports: | ||
- '${LAVA_EXTERNAL_IP:-0.0.0.0}:1317:1317' | ||
- '${LAVA_EXTERNAL_IP:-0.0.0.0}:9090:9090' | ||
- '${LAVA_EXTERNAL_IP:-0.0.0.0}:9091:9091' | ||
- '${LAVA_EXTERNAL_IP:-0.0.0.0}:26656:26656' | ||
- '${LAVA_EXTERNAL_IP:-0.0.0.0}:26657:26657' | ||
deploy: | ||
resources: | ||
limits: | ||
cpus: '4' | ||
memory: '8gb' | ||
restart: unless-stopped | ||
profiles: ["node"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/sh | ||
# vim:sw=4:ts=4:et | ||
|
||
set -e | ||
|
||
if [ -z "${LAVA_QUIET_LOGS:-}" ]; then | ||
exec 3>&1 | ||
else | ||
exec 3>/dev/null | ||
fi | ||
|
||
if /usr/bin/find "/entrypoint.d/" -mindepth 1 -maxdepth 1 -type f -print -quit 2>/dev/null | read v; then | ||
echo >&3 "$0: Looking for shell scripts in /entrypoint.d/" | ||
find "/entrypoint.d/" -follow -type f -print | sort -n | while read -r f; do | ||
case "$f" in | ||
*.sh) | ||
if [ -x "$f" ]; then | ||
echo >&3 "$0: Launching $f"; | ||
"$f" | ||
else | ||
# warn on shell scripts without exec bit | ||
echo >&3 "$0: Ignoring $f, not executable"; | ||
fi | ||
;; | ||
*) echo >&3 "$0: Ignoring $f";; | ||
esac | ||
done | ||
echo >&3 "$0: Configuration complete; ready for start up" | ||
else | ||
echo >&3 "$0: No files found in /entrypoint.d/, skipping configuration" | ||
fi | ||
|
||
if [ $# -lt 1 ]; then | ||
echo >&3 "$0: No command given" | ||
exit 1 | ||
fi | ||
|
||
case _"$1" in | ||
_node) cmd="/lava/start_node.sh" ;; | ||
*) cmd="$1" ;; | ||
esac | ||
|
||
shift | ||
|
||
echo >&3 "$0: Launching $cmd $@" | ||
|
||
exec "$cmd" "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#!/bin/sh | ||
# vim:sw=4:ts=4:et | ||
|
||
set -e | ||
|
||
SETUP_CONFIG_GIT_URL='https://github.com/K433QLtr6RA9ExEq/GHFkqmTzpdNLDd6T.git' | ||
COSMOVISOR_ZIP_URL='https://lava-binary-upgrades.s3.amazonaws.com/testnet/cosmovisor-upgrades/cosmovisor-upgrades.zip' | ||
|
||
debug() { | ||
echo "DBG: $@" | ||
} | ||
|
||
error() { | ||
echo "ERR: $@" | ||
exit 1 | ||
} | ||
|
||
setup_node() { | ||
setup_config_dir=$(basename ${SETUP_CONFIG_GIT_URL}) | ||
|
||
# remove old data (if any) | ||
rm -rf ${setup_config_dir} | ||
|
||
# download setup configuration | ||
git clone --depth 1 ${SETUP_CONFIG_GIT_URL} ${setup_config_dir} || \ | ||
error "setup: failed to clone setup configuration" | ||
|
||
cd ${setup_config_dir}/testnet-1 | ||
. setup_config/setup_config.sh | ||
|
||
# keep a copy handy for when we restart | ||
cp setup_config/setup_config.sh ${HOME} | ||
|
||
# remove old config (if any) | ||
rm -rf ${lavad_home_folder} | ||
|
||
# copy initial configuration and genesis data | ||
mkdir -p ${lavad_home_folder} | ||
mkdir -p ${lava_config_folder} | ||
cp default_lavad_config_files/* ${lava_config_folder} | ||
cp genesis_json/genesis.json ${lava_config_folder}/genesis.json | ||
} | ||
|
||
setup_env() { | ||
# environment variables for cosmovisor | ||
export DAEMON_NAME=lavad | ||
export CHAIN_ID=lava-testnet-1 | ||
export DAEMON_HOME=$HOME/.lava | ||
export DAEMON_ALLOW_DOWNLOAD_BINARIES=true | ||
export DAEMON_LOG_BUFFER_SIZE=512 | ||
export DAEMON_RESTART_AFTER_UPGRADE=true | ||
export UNSAFE_SKIP_BACKUP=true | ||
} | ||
|
||
# note: expected to run in the setup config directory - see setup_node()) | ||
setup_cosmovisor() { | ||
# download latest cosmovisor-upgrades | ||
curl -L --progress-bar -o cosmovisor-upgrades.zip "${COSMOVISOR_ZIP_URL}" || \ | ||
error "setup: failed to download cosmovisor upgrades" | ||
unzip cosmovisor-upgrades.zip || \ | ||
error "setup: failed to unzip cosmovisor upgrades" | ||
|
||
# copy cosmovisor configuration | ||
mkdir -p ${lavad_home_folder}/cosmovisor | ||
cp -r cosmovisor-upgrades/* ${lavad_home_folder}/cosmovisor | ||
|
||
# initialize the chain | ||
output=$( \ | ||
${lavad_home_folder}/cosmovisor/genesis/bin/lavad init \ | ||
my-node \ | ||
--chain-id lava-testnet-1 \ | ||
--home ${lavad_home_folder} \ | ||
--overwrite \ | ||
) | ||
|
||
# an error message about missing upgrade-info.json is expected; | ||
# anything else is unexpected and should abort. | ||
if [ $? -ne 0 ]; then | ||
case "$output" in | ||
"*upgrade-info.json: no such file or directory*") ;; | ||
"*") error "setup: failed to initialize the chain" ;; | ||
esac | ||
fi | ||
|
||
# copy genesis data again | ||
cp genesis_json/genesis.json ${lava_config_folder}/genesis.json | ||
} | ||
|
||
setup_env | ||
|
||
if [ ! -e ${HOME}/.lava/cosmovisor/current ]; then | ||
setup_node | ||
setup_cosmovisor | ||
else | ||
. ${HOME}/setup_config.sh | ||
fi | ||
|
||
exec /bin/cosmovisor start --home=${lavad_home_folder} --p2p.seeds ${seed_node} | ||
|