From ebb07df27da3077fbb0788150e8686c0de95c7b8 Mon Sep 17 00:00:00 2001 From: Aaron Dewes Date: Thu, 14 Jul 2022 09:24:16 +0200 Subject: [PATCH] Revert "[Feat] Docker compose isolation (#62)" This reverts commit 1b61d525f6026be64971066a0068b887dc160552. --- app/app-manager.py | 24 +++++++++---------- app/app-standard-v2.yml | 2 +- app/app-standard-v3.yml | 2 +- app/lib/manage.py | 12 +++++----- app/lib/validate.py | 2 +- bin/bitcoin-cli | 4 ++-- bin/lncli | 4 ++-- ...-compose.citadel.yml => docker-compose.yml | 0 scripts/configure | 2 +- scripts/debug | 14 +++++------ scripts/start | 2 +- scripts/stop | 2 +- scripts/update/01-run.sh | 2 +- scripts/update/README.md | 2 +- services/manage.py | 10 ++++---- setenv | 2 ++ 16 files changed, 44 insertions(+), 42 deletions(-) rename docker-compose.citadel.yml => docker-compose.yml (100%) diff --git a/app/app-manager.py b/app/app-manager.py index 94b750d1..1a29126b 100755 --- a/app/app-manager.py +++ b/app/app-manager.py @@ -58,12 +58,12 @@ else: os.system(os.path.join(nodeRoot, "scripts", "configure")) os.chdir(nodeRoot) - os.system("docker compose -f docker-compose.citadel.yml stop app-tor") - os.system("docker compose -f docker-compose.citadel.yml start app-tor") - os.system("docker compose -f docker-compose.citadel.yml stop app-2-tor") - os.system("docker compose -f docker-compose.citadel.yml start app-2-tor") - os.system("docker compose -f docker-compose.citadel.yml stop app-3-tor") - os.system("docker compose -f docker-compose.citadel.yml start app-3-tor") + os.system("docker compose stop app-tor") + os.system("docker compose start app-tor") + os.system("docker compose stop app-2-tor") + os.system("docker compose start app-2-tor") + os.system("docker compose stop app-3-tor") + os.system("docker compose start app-3-tor") exit(0) elif args.action == 'update': if args.app is None: @@ -77,12 +77,12 @@ else: os.system(os.path.join(nodeRoot, "scripts", "configure")) os.chdir(nodeRoot) - os.system("docker compose -f docker-compose.citadel.yml stop app-tor") - os.system("docker compose -f docker-compose.citadel.yml start app-tor") - os.system("docker compose -f docker-compose.citadel.yml stop app-2-tor") - os.system("docker compose -f docker-compose.citadel.yml start app-2-tor") - os.system("docker compose -f docker-compose.citadel.yml stop app-3-tor") - os.system("docker compose -f docker-compose.citadel.yml start app-3-tor") + os.system("docker compose stop app-tor") + os.system("docker compose start app-tor") + os.system("docker compose stop app-2-tor") + os.system("docker compose start app-2-tor") + os.system("docker compose stop app-3-tor") + os.system("docker compose start app-3-tor") exit(0) elif args.action == 'ls-installed': # Load the userFile as JSON, check if installedApps is in it, and if so, print the apps diff --git a/app/app-standard-v2.yml b/app/app-standard-v2.yml index 2b22015c..c630d925 100644 --- a/app/app-standard-v2.yml +++ b/app/app-standard-v2.yml @@ -167,7 +167,7 @@ properties: type: boolean description: >- Set this to true if the container shouldn't get an IP & port - exposed. This isn't necessary, but helps the docker-compose.citadel.yml generator to generate a cleaner output. + exposed. This isn't necessary, but helps the docker-compose.yml generator to generate a cleaner output. hiddenServicePorts: type: - object diff --git a/app/app-standard-v3.yml b/app/app-standard-v3.yml index 0a8aad02..39b0b4c4 100644 --- a/app/app-standard-v3.yml +++ b/app/app-standard-v3.yml @@ -173,7 +173,7 @@ properties: type: boolean description: >- Set this to true if the container shouldn't get an IP & port - exposed. This isn't necessary, but helps the docker-compose.citadel.yml generator to generate a cleaner output. + exposed. This isn't necessary, but helps the docker-compose.yml generator to generate a cleaner output. hiddenServicePorts: type: - object diff --git a/app/lib/manage.py b/app/lib/manage.py index a2f33226..3033bec3 100644 --- a/app/lib/manage.py +++ b/app/lib/manage.py @@ -90,7 +90,7 @@ def update(verbose: bool = False): # Loop through the apps and generate valid compose files from them, then put these into the app dir for app in apps: - composeFile = os.path.join(appsDir, app, "docker-compose.citadel.yml") + composeFile = os.path.join(appsDir, app, "docker-compose.yml") appYml = os.path.join(appsDir, app, "app.yml") with open(composeFile, "w") as f: appCompose = getApp(appYml, app) @@ -176,7 +176,7 @@ def stopInstalled(): threads.append(thread) joinThreads(threads) -# Loads an app.yml and converts it to a docker-compose.citadel.yml +# Loads an app.yml and converts it to a docker-compose.yml def getApp(appFile: str, appId: str): @@ -201,8 +201,8 @@ def compose(app, arguments): print("Warning: App {} doesn't exist on Citadel".format(app)) return # Runs a compose command in the app dir - # Before that, check if a docker-compose.citadel.yml exists in the app dir - composeFile = os.path.join(appsDir, app, "docker-compose.citadel.yml") + # Before that, check if a docker-compose.yml exists in the app dir + composeFile = os.path.join(appsDir, app, "docker-compose.yml") commonComposeFile = os.path.join(appSystemDir, "docker-compose.common.yml") os.environ["APP_DOMAIN"] = subprocess.check_output( "hostname -s 2>/dev/null || echo 'citadel'", shell=True).decode("utf-8").strip() + ".local" @@ -233,10 +233,10 @@ def compose(app, arguments): appHiddenServiceFile), shell=True).decode("utf-8").strip() if not os.path.isfile(composeFile): - print("Error: Could not find docker-compose.citadel.yml in " + app) + print("Error: Could not find docker-compose.yml in " + app) exit(1) os.system( - "docker compose -f docker-compose.citadel.yml --env-file '{}' --project-name '{}' --file '{}' --file '{}' {}".format( + "docker compose --env-file '{}' --project-name '{}' --file '{}' --file '{}' {}".format( os.path.join(nodeRoot, ".env"), app, commonComposeFile, composeFile, arguments)) diff --git a/app/lib/validate.py b/app/lib/validate.py index 78cb8a8f..16009d6d 100644 --- a/app/lib/validate.py +++ b/app/lib/validate.py @@ -51,7 +51,7 @@ def findApps(dir: str): for root, dirs, files in os.walk(dir, topdown=False): for name in dirs: app_dir = os.path.join(root, name) - if os.path.isfile(os.path.join(app_dir, "app.yml")) or os.path.isfile(os.path.join(app_dir, "docker-compose.citadel.yml")): + if os.path.isfile(os.path.join(app_dir, "app.yml")) or os.path.isfile(os.path.join(app_dir, "docker-compose.yml")): apps.append(name) return apps diff --git a/bin/bitcoin-cli b/bin/bitcoin-cli index 5456f0ac..688a09d3 100755 --- a/bin/bitcoin-cli +++ b/bin/bitcoin-cli @@ -10,8 +10,8 @@ set -euo pipefail CITADEL_ROOT="$(readlink -f $(dirname "${BASH_SOURCE[0]}")/..)" -result=$(docker compose -f docker-compose.citadel.yml \ - --file "${CITADEL_ROOT}/docker-compose.citadel.yml" \ +result=$(docker compose \ + --file "${CITADEL_ROOT}/docker-compose.yml" \ --env-file "${CITADEL_ROOT}/.env" \ exec bitcoin bitcoin-cli "$@") diff --git a/bin/lncli b/bin/lncli index 1f28723f..67753c0e 100755 --- a/bin/lncli +++ b/bin/lncli @@ -10,8 +10,8 @@ set -euo pipefail CITADEL_ROOT="$(readlink -f $(dirname "${BASH_SOURCE[0]}")/..)" -result=$(docker compose -f docker-compose.citadel.yml \ - --file "${CITADEL_ROOT}/docker-compose.citadel.yml" \ +result=$(docker compose \ + --file "${CITADEL_ROOT}/docker-compose.yml" \ --env-file "${CITADEL_ROOT}/.env" \ exec lightning lncli "$@") diff --git a/docker-compose.citadel.yml b/docker-compose.yml similarity index 100% rename from docker-compose.citadel.yml rename to docker-compose.yml diff --git a/scripts/configure b/scripts/configure index 16d035c8..ada56aaa 100755 --- a/scripts/configure +++ b/scripts/configure @@ -31,7 +31,7 @@ if not is_arm64 and not is_amd64: print('Citadel only works on arm64 and amd64!') exit(1) -# Check the output of "docker compose -f docker-compose.citadel.yml version", if it matches "Docker Compose version v2.0.0-rc.3", return true +# Check the output of "docker compose version", if it matches "Docker Compose version v2.0.0-rc.3", return true # Otherwise, return false def is_compose_rc_or_outdated(): try: diff --git a/scripts/debug b/scripts/debug index 158cac67..ea651974 100755 --- a/scripts/debug +++ b/scripts/debug @@ -139,28 +139,28 @@ if [[ "${1}" == "--run" ]]; then echo "Bitcoin Core logs" echo "-----------------" echo - docker compose -f docker-compose.citadel.yml logs --tail=30 bitcoin + docker compose logs --tail=30 bitcoin echo echo "Lightning logs" echo "--------------" echo - docker compose -f docker-compose.citadel.yml logs --tail=30 lightning + docker compose logs --tail=30 lightning echo echo "Electrum logs" echo "-------------" echo - docker compose -f docker-compose.citadel.yml logs --tail=30 electrum + docker compose logs --tail=30 electrum echo echo "Tor logs" echo "--------" echo - docker compose -f docker-compose.citadel.yml logs --tail=30 tor - docker compose -f docker-compose.citadel.yml logs --tail=30 app-tor - docker compose -f docker-compose.citadel.yml logs --tail=30 app-2-tor - docker compose -f docker-compose.citadel.yml logs --tail=30 app-3-tor + docker compose logs --tail=30 tor + docker compose logs --tail=30 app-tor + docker compose logs --tail=30 app-2-tor + docker compose logs --tail=30 app-3-tor installed_apps=$(./scripts/app ls-installed) if [[ ! -z "${installed_apps:-}" ]]; then diff --git a/scripts/start b/scripts/start index a7d2135f..983a7028 100755 --- a/scripts/start +++ b/scripts/start @@ -111,7 +111,7 @@ echo echo echo "Starting Docker services..." echo -docker compose -f docker-compose.citadel.yml up --detach --build --remove-orphans || { +docker compose up --detach --build --remove-orphans || { echo "Failed to start containers" exit 1 } diff --git a/scripts/stop b/scripts/stop index 15ecb710..2d29536c 100755 --- a/scripts/stop +++ b/scripts/stop @@ -37,4 +37,4 @@ echo echo "Stopping Docker services..." echo -docker compose -f docker-compose.citadel.yml down +docker compose down diff --git a/scripts/update/01-run.sh b/scripts/update/01-run.sh index ab6048b3..a3c5dceb 100755 --- a/scripts/update/01-run.sh +++ b/scripts/update/01-run.sh @@ -95,7 +95,7 @@ echo "Pulling new containers" cat < "$CITADEL_ROOT"/statuses/update-status.json {"state": "installing", "progress": 50, "description": "Pulling new containers", "updateTo": "$RELEASE"} EOF -docker compose -f docker-compose.citadel.yml pull +docker compose pull # Stopping karen echo "Stopping background daemon" diff --git a/scripts/update/README.md b/scripts/update/README.md index d421ef02..55e15f82 100644 --- a/scripts/update/README.md +++ b/scripts/update/README.md @@ -11,7 +11,7 @@ How over-the-air updates work on Citadel. 1. New developments across the any/entire fleet of Citadel's services (bitcoind, lnd, dashboard, middleware, etc) are made, which maintain their own independent version-control and release-schedule. Subsequently, their new docker images are built, tagged and pushed to Docker Hub. -2. The newly built and tagged images are updated in the main repository's (i.e. this repo) [`docker-compose.citadel.yml`](https://github.com/runcitadel/core/blob/main/docker-compose.citadel.yml) file. +2. The newly built and tagged images are updated in the main repository's (i.e. this repo) [`docker-compose.yml`](https://github.com/runcitadel/core/blob/main/docker-compose.yml) file. 3. Any new developments to the main repository (i.e. this repo) are made, eg. adding a new directory or a new config file. diff --git a/services/manage.py b/services/manage.py index b807b6ef..c965b2d3 100755 --- a/services/manage.py +++ b/services/manage.py @@ -29,7 +29,7 @@ args = parser.parse_args() # Function to install a service -# To install it, read the service's YAML file (nodeRoot/services/name.yml) and add it to the main compose file (nodeRoot/docker-compose.citadel.yml) +# To install it, read the service's YAML file (nodeRoot/services/name.yml) and add it to the main compose file (nodeRoot/docker-compose.yml) def setService(name, implementation): # Get all available services services = next(os.walk(os.path.join(nodeRoot, "services")))[1] @@ -51,14 +51,14 @@ def setService(name, implementation): service = yaml.safe_load(stream) # Read the main compose file - with open(os.path.join(nodeRoot, "docker-compose.citadel.yml"), 'r') as stream: + with open(os.path.join(nodeRoot, "docker-compose.yml"), 'r') as stream: compose = yaml.safe_load(stream) # Add the service to the main compose file compose['services'].update(service) # Write the main compose file - with open(os.path.join(nodeRoot, "docker-compose.citadel.yml"), 'w') as stream: + with open(os.path.join(nodeRoot, "docker-compose.yml"), 'w') as stream: yaml.dump(compose, stream, sort_keys=False) # Save the service name in nodeRoot/services/installed.json, which is a JSON file with a list of installed services # If the file doesn't exist, put [] in it, then run the code below @@ -81,7 +81,7 @@ def uninstallService(name): print("Service definition not found, cannot uninstall") exit(1) # Read the main compose file - with open(os.path.join(nodeRoot, "docker-compose.citadel.yml"), 'r') as stream: + with open(os.path.join(nodeRoot, "docker-compose.yml"), 'r') as stream: compose = yaml.safe_load(stream) # Remove the service from the main compose file @@ -91,7 +91,7 @@ def uninstallService(name): pass # Write the main compose file - with open(os.path.join(nodeRoot, "docker-compose.citadel.yml"), 'w') as stream: + with open(os.path.join(nodeRoot, "docker-compose.yml"), 'w') as stream: yaml.dump(compose, stream, sort_keys=False) # Save the service name in nodeRoot/services/installed.json, which is a JSON file with a list of installed services try: diff --git a/setenv b/setenv index edea1a00..3f9073cd 100644 --- a/setenv +++ b/setenv @@ -9,6 +9,8 @@ CITADEL_ROOT="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))" alias citadel-update="${CITADEL_ROOT}/scripts/update/update" alias lncli="docker exec -it lnd lncli" alias bitcoin-cli="docker exec -it bitcoin bitcoin-cli" +alias docker-compose="sudo docker compose" +alias docker="sudo docker" alias debug="${CITADEL_ROOT}/scripts/debug" alias app="${CITADEL_ROOT}/scripts/app"