diff --git a/docker/my-dojo/docker-compose.yaml b/docker/my-dojo/docker-compose.yaml index cc366b6..b679107 100644 --- a/docker/my-dojo/docker-compose.yaml +++ b/docker/my-dojo/docker-compose.yaml @@ -19,10 +19,6 @@ services: dojonet: ipv4_address: 172.28.1.1 - bitcoind: - image: "samouraiwallet/dojo-bitcoind:${DOJO_BITCOIND_VERSION_TAG}" - container_name: bitcoind - node: image: "samouraiwallet/dojo-nodejs:${DOJO_NODEJS_VERSION_TAG}" container_name: nodejs @@ -42,7 +38,6 @@ services: volumes: - data-nodejs:/data depends_on: - - bitcoind - db networks: dojonet: diff --git a/docker/my-dojo/dojo.sh b/docker/my-dojo/dojo.sh index 7c1175e..c25fde9 100755 --- a/docker/my-dojo/dojo.sh +++ b/docker/my-dojo/dojo.sh @@ -13,22 +13,29 @@ source_file "$DIR/conf/docker-bitcoind.conf" source_file "$DIR/.env" -# Docker up -docker_up() { +# Select YAML files +select_yaml_files() { source_file "$DIR/conf/docker-bitcoind.conf" - overrides="" + yamlFiles="-f $DIR/docker-compose.yaml" if [ "$BITCOIND_INSTALL" == "on" ]; then - overrides="-f $DIR/overrides/bitcoind.install.yaml" + yamlFiles="$yamlFiles -f $DIR/overrides/bitcoind.install.yaml" if [ "$BITCOIND_RPC_EXTERNAL" == "on" ]; then - overrides="$overrides -f $DIR/overrides/bitcoind.rpc.expose.yaml" + yamlFiles="$yamlFiles -f $DIR/overrides/bitcoind.rpc.expose.yaml" export BITCOIND_RPC_EXTERNAL_IP fi fi - eval "docker-compose -f $DIR/docker-compose.yaml $overrides up $1 -d" + # Return yamlFiles + echo "$yamlFiles" +} + +# Docker up +docker_up() { + yamlFiles=$(select_yaml_files) + eval "docker-compose $yamlFiles up $1 -d" } # Start @@ -54,7 +61,8 @@ stop() { sleep 15s fi - docker-compose down + yamlFiles=$(select_yaml_files) + eval "docker-compose $yamlFiles down" } # Restart dojo @@ -79,14 +87,16 @@ install() { if [ $launchInstall -eq 0 ]; then init_config_files docker_up --remove-orphans - docker-compose logs --tail=0 --follow + logs fi } # Delete everything uninstall() { docker-compose rm - docker-compose down + + yamlFiles=$(select_yaml_files) + eval "docker-compose $yamlFiles down" docker image rm samouraiwallet/dojo-db:"$DOJO_DB_VERSION_TAG" docker image rm samouraiwallet/dojo-bitcoind:"$DOJO_BITCOIND_VERSION_TAG" @@ -131,12 +141,13 @@ upgrade() { fi if [ $launchUpgrade -eq 0 ]; then + yamlFiles=$(select_yaml_files) update_config_files cleanup - docker-compose build --no-cache + eval "docker-compose $yamlFiles build --no-cache" docker_up --remove-orphans update_dojo_db - docker-compose logs --tail=0 --follow + logs fi } @@ -169,6 +180,8 @@ logs_node() { } logs() { + source_file "$DIR/conf/docker-bitcoind.conf" + case $1 in db ) docker-compose logs --tail=50 --follow db @@ -187,7 +200,12 @@ logs() { logs_node $1 $2 $3 ;; * ) - docker-compose logs --tail=0 --follow + yamlFiles=$(select_yaml_files) + services="nginx node tor db" + if [ "$BITCOIND_INSTALL" == "on" ]; then + services="$services bitcoind" + fi + eval "docker-compose $yamlFiles logs --tail=0 --follow $services" ;; esac } diff --git a/docker/my-dojo/overrides/bitcoind.install.yaml b/docker/my-dojo/overrides/bitcoind.install.yaml index 0f1d983..38ad273 100644 --- a/docker/my-dojo/overrides/bitcoind.install.yaml +++ b/docker/my-dojo/overrides/bitcoind.install.yaml @@ -26,5 +26,10 @@ services: dojonet: ipv4_address: 172.28.1.5 + node: + depends_on: + - bitcoind + - db + volumes: data-bitcoind: