Skip to content

Instantly share code, notes, and snippets.

@shackra
Last active June 15, 2023 04:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shackra/02703a299654557ae10c917eece98ec0 to your computer and use it in GitHub Desktop.
Save shackra/02703a299654557ae10c917eece98ec0 to your computer and use it in GitHub Desktop.
ignite cli docker wrapper for cool and fashion people that uses unsupported OS like NixOS
#!/usr/bin/env bash
set -e
cli_home=$HOME/.cache/ignite
cli_version=v0.27.1
run_serve=false
for arg in "$@"; do
if [ "$arg" = "serve" ]; then
run_serve=true
break
fi
done
if [ ! -d "$cli_home" ]; then
mkdir -p "$cli_home"
fi
# cross the directory tree until it finds the project
project_home="."
while [[ "$project_home" != "/" ]]; do
for file in "config.yml" "go.mod"; do
if [[ -e "$project_home/$file" ]]; then
break 2
fi
done
last_project_home="$project_home"
project_home=$(realpath "$project_home/..")
if [[ "$project_home" == "$last_project_home" ]]; then
break
fi
done
project_home=$(realpath "$project_home")
# use $PWD in case no project was found
project_found=$PWD
if [ -e "$project_home/config.yml" ]; then
project_found=$project_home
fi
if [ "$run_serve" = true ]; then
faucet_port=$(yq '.faucet.port // 4500' "$project_home/config.yml")
cosmos_port=1317
tendermint_port=26657
docker run --rm -ti \
-v "$cli_home":/home/tendermint \
-v "$project_found":/apps \
-p $cosmos_port:$cosmos_port \
-p $tendermint_port:$tendermint_port \
-p $faucet_port:$faucet_port \
ignitehq/cli:$cli_version "$@"
else
docker run --rm -ti \
-v "$cli_home":/home/tendermint \
-v "$project_found":/apps \
ignitehq/cli:$cli_version "$@"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment