Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Baedeker helper script #984

Merged
merged 2 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .baedeker/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/.bdk-env
/rewrites.jsonnet
/vendor
/baedeker-library
6 changes: 6 additions & 0 deletions .baedeker/down.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
set -e
BDK_DIR=$(dirname $(readlink -f "$0"))
cd $BDK_DIR/.bdk-env
docker compose down -v --remove-orphans
rm -rf discover.env secret specs
17 changes: 17 additions & 0 deletions .baedeker/rewrites.example.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
local dotenv = {
[std.splitLimit(line, "=", 2)[0]]: std.splitLimit(line, "=", 2)[1]
for line in std.split(importstr "../.env", "\n")
if line != ""
if std.member(line, "=")
};

function(prev, repoDir)
(import 'baedeker-library/ops/rewrites.libsonnet').rewriteNodePaths({
'bin/unique':'%s/target/release/unique-collator' % repoDir,
'bin/polkadot':{dockerImage:'uniquenetwork/builder-polkadot:%s' % dotenv.POLKADOT_MAINNET_BRANCH},
'bin/acala':{dockerImage:'uniquenetwork/builder-acala:%s' % dotenv.ACALA_BUILD_BRANCH},
'bin/moonbeam':{dockerImage:'uniquenetwork/builder-moonbeam:%s' % dotenv.MOONBEAM_BUILD_BRANCH},
'bin/cumulus':{dockerImage:'uniquenetwork/builder-cumulus:%s' % dotenv.STATEMINE_BUILD_BRANCH},
'bin/astar':{dockerImage:'uniquenetwork/builder-astar:%s' % dotenv.ASTAR_BUILD_BRANCH},
'bin/polkadex':{dockerImage:'uniquenetwork/builder-polkadex:%s' % dotenv.POLKADEX_BUILD_BRANCH},
})(prev)
6 changes: 6 additions & 0 deletions .baedeker/up.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
set -e
BDK_DIR=$(dirname $(readlink -f "$0"))
RUST_LOG=info baedeker --spec=docker -J$BDK_DIR --generator=docker_compose=$BDK_DIR/.bdk-env --generator=docker_compose_discover=$BDK_DIR/.bdk-env/discover.env --secret=file=$BDK_DIR/.bdk-env/secret --tla-str=relay_spec=rococo-local --input-modules='lib:baedeker-library/ops/nginx.libsonnet' --input-modules='lib:baedeker-library/ops/devtools.libsonnet' --tla-str=repoDir=$(realpath $BDK_DIR/..) $@ $BDK_DIR/rewrites.jsonnet
cd $BDK_DIR/.bdk-env
docker compose up -d --wait --remove-orphans
45 changes: 45 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/sh

# Load .envrc from parent directories
source_up_if_exists
# Common variables from .env
dotenv

RED='\033[0;31m'
GREEN='\033[0;32m'
RESET='\033[0m'

dep_not_found=false
function check_bdk {
if ! has $1; then
echo -e "${RED}$1 not found (wanted for beadeker discovery)${RESET}"
dep_not_found=true
fi
}

watch_file .baedeker/.bdk-env/discover.env
if test -f .baedeker/.bdk-env/discover.env; then
check_bdk baedeker
check_bdk docker
check_bdk jq
if $dep_not_found; then
echo -e "${RED}Not performing bdk discovery${RESET}"
exit 0
fi

echo -e "${GREEN}Baedeker env updated${RESET}"
nginx_id=$(docker compose -f $PWD/.bdk-env/docker-compose.yml ps --format=json | jq -r '.[] | select(.Service == "nginx") | .ID' -e)
if ! [ $? -eq 0 ]; then
echo -e "${RED}Nginx container not found${RESET}"
exit 0
fi
nginx_ip=$(docker inspect $nginx_id | jq -r -e '.[0].NetworkSettings.Networks[].IPAddress')
if ! [ $? -eq 0 ]; then
echo -e "${RED}Nginx container network misconfigured?${RESET}"
exit 0
fi
tmpenv=$(mktemp)
cat .baedeker/.bdk-env/discover.env | sed "s|BALANCER_URL|$nginx_ip|g" > $tmpenv
dotenv $tmpenv
echo -e "${GREEN}Enjoy your baedeker networks at $(echo $BDK_BALANCER || sed "s|BALANCER_URL|$nginx_ip|g")${RESET}"
fi
125 changes: 0 additions & 125 deletions launch-config-full.json

This file was deleted.

154 changes: 0 additions & 154 deletions launch-config.json

This file was deleted.

6 changes: 0 additions & 6 deletions launch-testnet-full.sh

This file was deleted.

6 changes: 0 additions & 6 deletions launch-testnet.sh

This file was deleted.

Loading
Loading