forked from cerc-io/stack-orchestrator
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8d49950a37 |
@@ -12,7 +12,7 @@ jobs:
|
|||||||
- name: "Clone project repository"
|
- name: "Clone project repository"
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
- name: "Install Python"
|
- name: "Install Python"
|
||||||
uses: actions/setup-python@v4
|
uses: cerc-io/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: '3.8'
|
python-version: '3.8'
|
||||||
- name: "Print Python version"
|
- name: "Print Python version"
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ jobs:
|
|||||||
build_tag=$(./scripts/create_build_tag_file.sh)
|
build_tag=$(./scripts/create_build_tag_file.sh)
|
||||||
echo "build-tag=v${build_tag}" >> $GITHUB_OUTPUT
|
echo "build-tag=v${build_tag}" >> $GITHUB_OUTPUT
|
||||||
- name: "Install Python"
|
- name: "Install Python"
|
||||||
uses: actions/setup-python@v4
|
uses: cerc-io/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: '3.8'
|
python-version: '3.8'
|
||||||
- name: "Print Python version"
|
- name: "Print Python version"
|
||||||
@@ -37,7 +37,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cp ${{ steps.build.outputs.package-file }} ./laconic-so
|
cp ${{ steps.build.outputs.package-file }} ./laconic-so
|
||||||
- name: "Create release"
|
- name: "Create release"
|
||||||
uses: https://gitea.com/cerc-io/action-gh-release@gitea-v2
|
uses: cerc-io/action-gh-release@gitea-v1
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ steps.build-info.outputs.build-tag }}
|
tag_name: ${{ steps.build-info.outputs.build-tag }}
|
||||||
# On the publish test branch, mark our release as a draft
|
# On the publish test branch, mark our release as a draft
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ jobs:
|
|||||||
- name: "Clone project repository"
|
- name: "Clone project repository"
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
- name: "Install Python"
|
- name: "Install Python"
|
||||||
uses: actions/setup-python@v4
|
uses: cerc-io/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: '3.8'
|
python-version: '3.8'
|
||||||
- name: "Print Python version"
|
- name: "Print Python version"
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ jobs:
|
|||||||
- name: "Clone project repository"
|
- name: "Clone project repository"
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
- name: "Install Python"
|
- name: "Install Python"
|
||||||
uses: actions/setup-python@v4
|
uses: cerc-io/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: '3.8'
|
python-version: '3.8'
|
||||||
- name: "Print Python version"
|
- name: "Print Python version"
|
||||||
|
|||||||
+6
-5
@@ -15,8 +15,9 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from app.deploy import get_stack_status
|
|
||||||
from decouple import config
|
from decouple import config
|
||||||
|
from .deploy import get_stack_status
|
||||||
|
from .util import _log
|
||||||
|
|
||||||
|
|
||||||
def get_stack(config, stack):
|
def get_stack(config, stack):
|
||||||
@@ -49,7 +50,7 @@ class package_registry_stack(base_stack):
|
|||||||
url_from_environment = os.environ.get("CERC_NPM_REGISTRY_URL")
|
url_from_environment = os.environ.get("CERC_NPM_REGISTRY_URL")
|
||||||
if url_from_environment:
|
if url_from_environment:
|
||||||
if self.config.verbose:
|
if self.config.verbose:
|
||||||
print(f"Using package registry url from CERC_NPM_REGISTRY_URL: {url_from_environment}")
|
_log(f"Using package registry url from CERC_NPM_REGISTRY_URL: {url_from_environment}")
|
||||||
self.url = url_from_environment
|
self.url = url_from_environment
|
||||||
else:
|
else:
|
||||||
# Otherwise we expect to use the local package-registry stack
|
# Otherwise we expect to use the local package-registry stack
|
||||||
@@ -58,13 +59,13 @@ class package_registry_stack(base_stack):
|
|||||||
if registry_running:
|
if registry_running:
|
||||||
# If it is available, get its mapped port and construct its URL
|
# If it is available, get its mapped port and construct its URL
|
||||||
if self.config.debug:
|
if self.config.debug:
|
||||||
print("Found local package registry stack is up")
|
_log("Found local package registry stack is up")
|
||||||
# TODO: get url from deploy-stack
|
# TODO: get url from deploy-stack
|
||||||
self.url = "http://gitea.local:3000/api/packages/cerc-io/npm/"
|
self.url = "http://gitea.local:3000/api/packages/cerc-io/npm/"
|
||||||
else:
|
else:
|
||||||
# If not, print a message about how to start it and return fail to the caller
|
# If not, print a message about how to start it and return fail to the caller
|
||||||
print("ERROR: The package-registry stack is not running, and no external registry specified with CERC_NPM_REGISTRY_URL")
|
_log("ERROR: The package-registry stack is not running, and no external registry specified with CERC_NPM_REGISTRY_URL")
|
||||||
print("ERROR: Start the local package registry with: laconic-so --stack package-registry deploy-system up")
|
_log("ERROR: Start the local package registry with: laconic-so --stack package-registry deploy-system up")
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
+18
-18
@@ -27,8 +27,8 @@ import subprocess
|
|||||||
import click
|
import click
|
||||||
import importlib.resources
|
import importlib.resources
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from app.util import include_exclude_check, get_parsed_stack_config
|
from .util import _log, include_exclude_check, get_parsed_stack_config
|
||||||
from app.base import get_npm_registry_url
|
from .base import get_npm_registry_url
|
||||||
|
|
||||||
# TODO: find a place for this
|
# TODO: find a place for this
|
||||||
# epilog="Config provided either in .env or settings.ini or env vars: CERC_REPO_BASE_DIR (defaults to ~/cerc)"
|
# epilog="Config provided either in .env or settings.ini or env vars: CERC_REPO_BASE_DIR (defaults to ~/cerc)"
|
||||||
@@ -56,18 +56,18 @@ def command(ctx, include, exclude, force_rebuild, extra_build_args):
|
|||||||
|
|
||||||
if local_stack:
|
if local_stack:
|
||||||
dev_root_path = os.getcwd()[0:os.getcwd().rindex("stack-orchestrator")]
|
dev_root_path = os.getcwd()[0:os.getcwd().rindex("stack-orchestrator")]
|
||||||
print(f'Local stack dev_root_path (CERC_REPO_BASE_DIR) overridden to: {dev_root_path}')
|
_log(f'Local stack dev_root_path (CERC_REPO_BASE_DIR) overridden to: {dev_root_path}')
|
||||||
else:
|
else:
|
||||||
dev_root_path = os.path.expanduser(config("CERC_REPO_BASE_DIR", default="~/cerc"))
|
dev_root_path = os.path.expanduser(config("CERC_REPO_BASE_DIR", default="~/cerc"))
|
||||||
|
|
||||||
if not quiet:
|
if not quiet:
|
||||||
print(f'Dev Root is: {dev_root_path}')
|
_log(f'Dev Root is: {dev_root_path}')
|
||||||
|
|
||||||
if not os.path.isdir(dev_root_path):
|
if not os.path.isdir(dev_root_path):
|
||||||
print('Dev root directory doesn\'t exist, creating')
|
_log('Dev root directory doesn\'t exist, creating')
|
||||||
|
|
||||||
# See: https://stackoverflow.com/a/20885799/1701505
|
# See: https://stackoverflow.com/a/20885799/1701505
|
||||||
from app import data
|
from . import data
|
||||||
with importlib.resources.open_text(data, "container-image-list.txt") as container_list_file:
|
with importlib.resources.open_text(data, "container-image-list.txt") as container_list_file:
|
||||||
all_containers = container_list_file.read().splitlines()
|
all_containers = container_list_file.read().splitlines()
|
||||||
|
|
||||||
@@ -79,9 +79,9 @@ def command(ctx, include, exclude, force_rebuild, extra_build_args):
|
|||||||
containers_in_scope = all_containers
|
containers_in_scope = all_containers
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print(f'Containers: {containers_in_scope}')
|
_log(f'Containers: {containers_in_scope}')
|
||||||
if stack:
|
if stack:
|
||||||
print(f"Stack: {stack}")
|
_log(f"Stack: {stack}")
|
||||||
|
|
||||||
# TODO: make this configurable
|
# TODO: make this configurable
|
||||||
container_build_env = {
|
container_build_env = {
|
||||||
@@ -102,16 +102,16 @@ def command(ctx, include, exclude, force_rebuild, extra_build_args):
|
|||||||
|
|
||||||
def process_container(container):
|
def process_container(container):
|
||||||
if not quiet:
|
if not quiet:
|
||||||
print(f"Building: {container}")
|
_log(f"Building: {container}")
|
||||||
build_dir = os.path.join(container_build_dir, container.replace("/", "-"))
|
build_dir = os.path.join(container_build_dir, container.replace("/", "-"))
|
||||||
build_script_filename = os.path.join(build_dir, "build.sh")
|
build_script_filename = os.path.join(build_dir, "build.sh")
|
||||||
if verbose:
|
if verbose:
|
||||||
print(f"Build script filename: {build_script_filename}")
|
_log(f"Build script filename: {build_script_filename}")
|
||||||
if os.path.exists(build_script_filename):
|
if os.path.exists(build_script_filename):
|
||||||
build_command = build_script_filename
|
build_command = build_script_filename
|
||||||
else:
|
else:
|
||||||
if verbose:
|
if verbose:
|
||||||
print(f"No script file found: {build_script_filename}, using default build script")
|
_log(f"No script file found: {build_script_filename}, using default build script")
|
||||||
repo_dir = container.split('/')[1]
|
repo_dir = container.split('/')[1]
|
||||||
# TODO: make this less of a hack -- should be specified in some metadata somewhere
|
# TODO: make this less of a hack -- should be specified in some metadata somewhere
|
||||||
# Check if we have a repo for this container. If not, set the context dir to the container-build subdir
|
# Check if we have a repo for this container. If not, set the context dir to the container-build subdir
|
||||||
@@ -120,23 +120,23 @@ def command(ctx, include, exclude, force_rebuild, extra_build_args):
|
|||||||
build_command = os.path.join(container_build_dir, "default-build.sh") + f" {container}:local {repo_dir_or_build_dir}"
|
build_command = os.path.join(container_build_dir, "default-build.sh") + f" {container}:local {repo_dir_or_build_dir}"
|
||||||
if not dry_run:
|
if not dry_run:
|
||||||
if verbose:
|
if verbose:
|
||||||
print(f"Executing: {build_command} with environment: {container_build_env}")
|
_log(f"Executing: {build_command} with environment: {container_build_env}")
|
||||||
build_result = subprocess.run(build_command, shell=True, env=container_build_env)
|
build_result = subprocess.run(build_command, shell=True, env=container_build_env)
|
||||||
if verbose:
|
if verbose:
|
||||||
print(f"Return code is: {build_result.returncode}")
|
_log(f"Return code is: {build_result.returncode}")
|
||||||
if build_result.returncode != 0:
|
if build_result.returncode != 0:
|
||||||
print(f"Error running build for {container}")
|
_log(f"Error running build for {container}")
|
||||||
if not continue_on_error:
|
if not continue_on_error:
|
||||||
print("FATAL Error: container build failed and --continue-on-error not set, exiting")
|
_log("FATAL Error: container build failed and --continue-on-error not set, exiting")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
print("****** Container Build Error, continuing because --continue-on-error is set")
|
_log("****** Container Build Error, continuing because --continue-on-error is set")
|
||||||
else:
|
else:
|
||||||
print("Skipped")
|
_log("Skipped")
|
||||||
|
|
||||||
for container in containers_in_scope:
|
for container in containers_in_scope:
|
||||||
if include_exclude_check(container, include, exclude):
|
if include_exclude_check(container, include, exclude):
|
||||||
process_container(container)
|
process_container(container)
|
||||||
else:
|
else:
|
||||||
if verbose:
|
if verbose:
|
||||||
print(f"Excluding: {container}")
|
_log(f"Excluding: {container}")
|
||||||
|
|||||||
+3
-3
@@ -25,8 +25,8 @@ from decouple import config
|
|||||||
import click
|
import click
|
||||||
import importlib.resources
|
import importlib.resources
|
||||||
from python_on_whales import docker, DockerException
|
from python_on_whales import docker, DockerException
|
||||||
from app.base import get_stack
|
from .base import get_stack
|
||||||
from app.util import include_exclude_check, get_parsed_stack_config
|
from .util import include_exclude_check, get_parsed_stack_config
|
||||||
|
|
||||||
builder_js_image_name = "cerc/builder-js:local"
|
builder_js_image_name = "cerc/builder-js:local"
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ def command(ctx, include, exclude, force_rebuild, extra_build_args):
|
|||||||
os.makedirs(build_root_path)
|
os.makedirs(build_root_path)
|
||||||
|
|
||||||
# See: https://stackoverflow.com/a/20885799/1701505
|
# See: https://stackoverflow.com/a/20885799/1701505
|
||||||
from app import data
|
from . import data
|
||||||
with importlib.resources.open_text(data, "npm-package-list.txt") as package_list_file:
|
with importlib.resources.open_text(data, "npm-package-list.txt") as package_list_file:
|
||||||
all_packages = package_list_file.read().splitlines()
|
all_packages = package_list_file.read().splitlines()
|
||||||
|
|
||||||
|
|||||||
@@ -23,10 +23,10 @@ services:
|
|||||||
command: |
|
command: |
|
||||||
"./wait-for-it.sh -h ${CERC_L1_HOST:-$${DEFAULT_CERC_L1_HOST}} -p ${CERC_L1_PORT:-$${DEFAULT_CERC_L1_PORT}} -s -t 60 -- ./run.sh"
|
"./wait-for-it.sh -h ${CERC_L1_HOST:-$${DEFAULT_CERC_L1_HOST}} -p ${CERC_L1_PORT:-$${DEFAULT_CERC_L1_PORT}} -s -t 60 -- ./run.sh"
|
||||||
volumes:
|
volumes:
|
||||||
- ../config/network/wait-for-it.sh:/app/packages/contracts-bedrock/wait-for-it.sh
|
- ../config/wait-for-it.sh:/app/packages/contracts-bedrock/wait-for-it.sh
|
||||||
- ../config/optimism-contracts/hardhat-tasks/verify-contract-deployment.ts:/app/packages/contracts-bedrock/tasks/verify-contract-deployment.ts
|
- ../container-build/cerc-optimism-contracts/hardhat-tasks/verify-contract-deployment.ts:/app/packages/contracts-bedrock/tasks/verify-contract-deployment.ts
|
||||||
- ../config/optimism-contracts/hardhat-tasks/rekey-json.ts:/app/packages/contracts-bedrock/tasks/rekey-json.ts
|
- ../container-build/cerc-optimism-contracts/hardhat-tasks/rekey-json.ts:/app/packages/contracts-bedrock/tasks/rekey-json.ts
|
||||||
- ../config/optimism-contracts/hardhat-tasks/send-balance.ts:/app/packages/contracts-bedrock/tasks/send-balance.ts
|
- ../container-build/cerc-optimism-contracts/hardhat-tasks/send-balance.ts:/app/packages/contracts-bedrock/tasks/send-balance.ts
|
||||||
- ../config/fixturenet-optimism/optimism-contracts/update-config.js:/app/packages/contracts-bedrock/update-config.js
|
- ../config/fixturenet-optimism/optimism-contracts/update-config.js:/app/packages/contracts-bedrock/update-config.js
|
||||||
- ../config/fixturenet-optimism/optimism-contracts/run.sh:/app/packages/contracts-bedrock/run.sh
|
- ../config/fixturenet-optimism/optimism-contracts/run.sh:/app/packages/contracts-bedrock/run.sh
|
||||||
- l2_accounts:/l2-accounts
|
- l2_accounts:/l2-accounts
|
||||||
@@ -120,7 +120,7 @@ services:
|
|||||||
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
|
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
|
||||||
CERC_L1_RPC: ${CERC_L1_RPC}
|
CERC_L1_RPC: ${CERC_L1_RPC}
|
||||||
volumes:
|
volumes:
|
||||||
- ../config/network/wait-for-it.sh:/wait-for-it.sh
|
- ../config/wait-for-it.sh:/wait-for-it.sh
|
||||||
- ../config/fixturenet-optimism/run-op-batcher.sh:/run-op-batcher.sh
|
- ../config/fixturenet-optimism/run-op-batcher.sh:/run-op-batcher.sh
|
||||||
- l2_accounts:/l2-accounts:ro
|
- l2_accounts:/l2-accounts:ro
|
||||||
entrypoint: ["sh", "-c"]
|
entrypoint: ["sh", "-c"]
|
||||||
@@ -145,7 +145,7 @@ services:
|
|||||||
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
|
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
|
||||||
CERC_L1_RPC: ${CERC_L1_RPC}
|
CERC_L1_RPC: ${CERC_L1_RPC}
|
||||||
volumes:
|
volumes:
|
||||||
- ../config/network/wait-for-it.sh:/wait-for-it.sh
|
- ../config/wait-for-it.sh:/wait-for-it.sh
|
||||||
- ../config/fixturenet-optimism/run-op-proposer.sh:/run-op-proposer.sh
|
- ../config/fixturenet-optimism/run-op-proposer.sh:/run-op-proposer.sh
|
||||||
- l1_deployment:/contracts-bedrock:ro
|
- l1_deployment:/contracts-bedrock:ro
|
||||||
- l2_accounts:/l2-accounts:ro
|
- l2_accounts:/l2-accounts:ro
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
|
|
||||||
services:
|
|
||||||
|
|
||||||
mainnet-eth-geth-1:
|
|
||||||
restart: always
|
|
||||||
hostname: mainnet-eth-geth-1
|
|
||||||
cap_add:
|
|
||||||
- SYS_PTRACE
|
|
||||||
environment:
|
|
||||||
CERC_REMOTE_DEBUG: "true"
|
|
||||||
CERC_RUN_STATEDIFF: ${CERC_RUN_STATEDIFF:-detect}
|
|
||||||
CERC_STATEDIFF_DB_NODE_ID: 1
|
|
||||||
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
|
|
||||||
image: cerc/go-ethereum:local
|
|
||||||
entrypoint: /bin/sh
|
|
||||||
command: -c "/opt/run-geth.sh"
|
|
||||||
volumes:
|
|
||||||
- mainnet_eth_geth_1_data:/root/ethdata
|
|
||||||
- mainnet_eth_config_data:/etc/mainnet-eth
|
|
||||||
- ../config/mainnet-eth/scripts/run-geth.sh:/opt/run-geth.sh
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "nc", "-v", "localhost", "8545"]
|
|
||||||
interval: 30s
|
|
||||||
timeout: 10s
|
|
||||||
retries: 10
|
|
||||||
start_period: 3s
|
|
||||||
ports:
|
|
||||||
- "8545"
|
|
||||||
- "40000"
|
|
||||||
- "6060"
|
|
||||||
|
|
||||||
mainnet-eth-lighthouse-1:
|
|
||||||
restart: always
|
|
||||||
hostname: mainnet-eth-lighthouse-1
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "wget", "--tries=1", "--connect-timeout=1", "--quiet", "-O", "-", "http://localhost:8001/eth/v2/beacon/blocks/head"]
|
|
||||||
interval: 30s
|
|
||||||
timeout: 10s
|
|
||||||
retries: 10
|
|
||||||
start_period: 30s
|
|
||||||
environment:
|
|
||||||
EXECUTION_ENDPOINT: "http://mainnet-eth-geth-1:8551"
|
|
||||||
image: cerc/lighthouse:local
|
|
||||||
entrypoint: /bin/sh
|
|
||||||
command: -c "/opt/run-lighthouse.sh"
|
|
||||||
volumes:
|
|
||||||
- mainnet_eth_lighthouse_1_data:/var/lighthouse-data-dir
|
|
||||||
- mainnet_eth_config_data:/etc/mainnet-eth
|
|
||||||
- ../config/mainnet-eth/scripts/run-lighthouse.sh:/opt/run-lighthouse.sh
|
|
||||||
ports:
|
|
||||||
- "8001"
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
mainnet_eth_config_data:
|
|
||||||
mainnet_eth_geth_1_data:
|
|
||||||
mainnet_eth_lighthouse_1_data:
|
|
||||||
@@ -2,7 +2,7 @@ services:
|
|||||||
laconicd:
|
laconicd:
|
||||||
restart: no
|
restart: no
|
||||||
image: cerc/laconicd:local
|
image: cerc/laconicd:local
|
||||||
command: ["/bin/sh", "-c", "while :; do sleep 600; done"]
|
command: ["sh", "/docker-entrypoint-scripts.d/create-fixturenet.sh"]
|
||||||
volumes:
|
volumes:
|
||||||
# The cosmos-sdk node's database directory:
|
# The cosmos-sdk node's database directory:
|
||||||
- laconicd-data:/root/.laconicd/data
|
- laconicd-data:/root/.laconicd/data
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ services:
|
|||||||
working_dir: /scripts
|
working_dir: /scripts
|
||||||
command: ["sh", "mobymask-app-start.sh"]
|
command: ["sh", "mobymask-app-start.sh"]
|
||||||
volumes:
|
volumes:
|
||||||
- ../config/network/wait-for-it.sh:/scripts/wait-for-it.sh
|
- ../config/wait-for-it.sh:/scripts/wait-for-it.sh
|
||||||
- ../config/watcher-mobymask-v2/mobymask-app-start.sh:/scripts/mobymask-app-start.sh
|
- ../config/watcher-mobymask-v2/mobymask-app-start.sh:/scripts/mobymask-app-start.sh
|
||||||
- peers_ids:/peers
|
- peers_ids:/peers
|
||||||
- mobymask_deployment:/server
|
- mobymask_deployment:/server
|
||||||
@@ -50,7 +50,7 @@ services:
|
|||||||
working_dir: /scripts
|
working_dir: /scripts
|
||||||
command: ["sh", "mobymask-app-start.sh"]
|
command: ["sh", "mobymask-app-start.sh"]
|
||||||
volumes:
|
volumes:
|
||||||
- ../config/network/wait-for-it.sh:/scripts/wait-for-it.sh
|
- ../config/wait-for-it.sh:/scripts/wait-for-it.sh
|
||||||
- ../config/watcher-mobymask-v2/mobymask-app-start.sh:/scripts/mobymask-app-start.sh
|
- ../config/watcher-mobymask-v2/mobymask-app-start.sh:/scripts/mobymask-app-start.sh
|
||||||
- peers_ids:/peers
|
- peers_ids:/peers
|
||||||
- mobymask_deployment:/server
|
- mobymask_deployment:/server
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ services:
|
|||||||
CERC_DENY_MULTIADDRS: ${CERC_DENY_MULTIADDRS}
|
CERC_DENY_MULTIADDRS: ${CERC_DENY_MULTIADDRS}
|
||||||
command: ["sh", "test-app-start.sh"]
|
command: ["sh", "test-app-start.sh"]
|
||||||
volumes:
|
volumes:
|
||||||
- ../config/network/wait-for-it.sh:/scripts/wait-for-it.sh
|
- ../config/wait-for-it.sh:/scripts/wait-for-it.sh
|
||||||
- ../config/watcher-mobymask-v2/test-app-start.sh:/scripts/test-app-start.sh
|
- ../config/watcher-mobymask-v2/test-app-start.sh:/scripts/test-app-start.sh
|
||||||
- peers_ids:/peers
|
- peers_ids:/peers
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ services:
|
|||||||
CERC_L2_NODE_PORT: ${CERC_L2_NODE_PORT}
|
CERC_L2_NODE_PORT: ${CERC_L2_NODE_PORT}
|
||||||
command: ["sh", "deploy-and-generate-invite.sh"]
|
command: ["sh", "deploy-and-generate-invite.sh"]
|
||||||
volumes:
|
volumes:
|
||||||
- ../config/network/wait-for-it.sh:/app/packages/server/wait-for-it.sh
|
- ../config/wait-for-it.sh:/app/packages/server/wait-for-it.sh
|
||||||
- ../config/watcher-mobymask-v2/secrets-template.json:/app/packages/server/secrets-template.json
|
- ../config/watcher-mobymask-v2/secrets-template.json:/app/packages/server/secrets-template.json
|
||||||
- ../config/watcher-mobymask-v2/deploy-and-generate-invite.sh:/app/packages/server/deploy-and-generate-invite.sh
|
- ../config/watcher-mobymask-v2/deploy-and-generate-invite.sh:/app/packages/server/deploy-and-generate-invite.sh
|
||||||
- mobymask_deployment:/app/packages/server
|
- mobymask_deployment:/app/packages/server
|
||||||
|
|||||||
@@ -75,8 +75,6 @@ services:
|
|||||||
uni-watcher-server:
|
uni-watcher-server:
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
depends_on:
|
depends_on:
|
||||||
ipld-eth-server:
|
|
||||||
condition: service_healthy
|
|
||||||
uniswap-watcher-db:
|
uniswap-watcher-db:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
uni-watcher-job-runner:
|
uni-watcher-job-runner:
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then
|
|
||||||
set -x
|
|
||||||
fi
|
|
||||||
|
|
||||||
CERC_ETH_DATADIR=/root/ethdata
|
|
||||||
|
|
||||||
START_CMD="geth"
|
|
||||||
if [ "true" == "$CERC_REMOTE_DEBUG" ] && [ -x "/usr/local/bin/dlv" ]; then
|
|
||||||
START_CMD="/usr/local/bin/dlv --listen=:40000 --headless=true --api-version=2 --accept-multiclient exec /usr/local/bin/geth --continue --"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# See https://linuxconfig.org/how-to-propagate-a-signal-to-child-processes-from-a-bash-script
|
|
||||||
cleanup() {
|
|
||||||
echo "Signal received, cleaning up..."
|
|
||||||
|
|
||||||
# Kill the child process first (CERC_REMOTE_DEBUG=true uses dlv which starts geth as a child process)
|
|
||||||
pkill -P ${geth_pid}
|
|
||||||
sleep 2
|
|
||||||
kill $(jobs -p)
|
|
||||||
|
|
||||||
wait
|
|
||||||
echo "Done"
|
|
||||||
}
|
|
||||||
|
|
||||||
$START_CMD \
|
|
||||||
--datadir="${CERC_ETH_DATADIR}" \
|
|
||||||
--authrpc.addr="0.0.0.0" \
|
|
||||||
--authrpc.port 8551 \
|
|
||||||
--authrpc.vhosts="*" \
|
|
||||||
--authrpc.jwtsecret="/etc/mainnet-eth/jwtsecret" \
|
|
||||||
--ws \
|
|
||||||
--ws.addr="0.0.0.0" \
|
|
||||||
--ws.origins="*" \
|
|
||||||
--ws.api="${CERC_GETH_WS_APIS:-eth,web3,net,admin,personal,debug,statediff}" \
|
|
||||||
--http.corsdomain="*" \
|
|
||||||
--gcmode full \
|
|
||||||
--txlookuplimit=0 \
|
|
||||||
--cache.preimages \
|
|
||||||
--syncmode=snap \
|
|
||||||
&
|
|
||||||
|
|
||||||
geth_pid=$!
|
|
||||||
|
|
||||||
|
|
||||||
wait $geth_pid
|
|
||||||
|
|
||||||
if [ "true" == "$CERC_KEEP_RUNNING_AFTER_GETH_EXIT" ]; then
|
|
||||||
while [ 1 -eq 1 ]; do
|
|
||||||
sleep 60
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then
|
|
||||||
set -x
|
|
||||||
fi
|
|
||||||
|
|
||||||
DEBUG_LEVEL=${CERC_LIGHTHOUSE_DEBUG_LEVEL:-info}
|
|
||||||
|
|
||||||
data_dir=/var/lighthouse-data-dir
|
|
||||||
|
|
||||||
network_port=9001
|
|
||||||
http_port=8001
|
|
||||||
authrpc_port=8551
|
|
||||||
|
|
||||||
exec lighthouse \
|
|
||||||
bn \
|
|
||||||
--debug-level $DEBUG_LEVEL \
|
|
||||||
--datadir $data_dir \
|
|
||||||
--network mainnet \
|
|
||||||
--execution-endpoint $EXECUTION_ENDPOINT \
|
|
||||||
--execution-jwt /etc/mainnet-eth/jwtsecret \
|
|
||||||
--disable-deposit-contract-sync \
|
|
||||||
--checkpoint-sync-url https://beaconstate.ethstaker.cc
|
|
||||||
@@ -23,8 +23,8 @@
|
|||||||
|
|
||||||
[upstream]
|
[upstream]
|
||||||
[upstream.ethServer]
|
[upstream.ethServer]
|
||||||
gqlApiEndpoint = "http://ipld-eth-server:8082/graphql"
|
gqlApiEndpoint = "http://ipld-eth-server.example.com:8083/graphql"
|
||||||
rpcProviderEndpoint = "http://ipld-eth-server:8081"
|
rpcProviderEndpoint = "http://ipld-eth-server.example.com:8082"
|
||||||
|
|
||||||
[upstream.cache]
|
[upstream.cache]
|
||||||
name = "requests"
|
name = "requests"
|
||||||
|
|||||||
@@ -63,8 +63,8 @@
|
|||||||
|
|
||||||
[upstream]
|
[upstream]
|
||||||
[upstream.ethServer]
|
[upstream.ethServer]
|
||||||
gqlApiEndpoint = "http://ipld-eth-server:8082/graphql"
|
gqlApiEndpoint = "http://ipld-eth-server.example.com:8083/graphql"
|
||||||
rpcProviderEndpoint = "http://ipld-eth-server:8081"
|
rpcProviderEndpoint = "http://ipld-eth-server.example.com:8082"
|
||||||
|
|
||||||
[upstream.cache]
|
[upstream.cache]
|
||||||
name = "requests"
|
name = "requests"
|
||||||
|
|||||||
@@ -22,8 +22,8 @@
|
|||||||
|
|
||||||
[upstream]
|
[upstream]
|
||||||
[upstream.ethServer]
|
[upstream.ethServer]
|
||||||
gqlApiEndpoint = "http://ipld-eth-server:8082/graphql"
|
gqlApiEndpoint = "http://ipld-eth-server.example.com:8083/graphql"
|
||||||
rpcProviderEndpoint = "http://ipld-eth-server:8081"
|
rpcProviderEndpoint = "http://ipld-eth-server.example.com:8082"
|
||||||
|
|
||||||
[upstream.cache]
|
[upstream.cache]
|
||||||
name = "requests"
|
name = "requests"
|
||||||
|
|||||||
@@ -1,104 +0,0 @@
|
|||||||
# mainnet-eth
|
|
||||||
|
|
||||||
Deploys a "head-tracking" mainnet Ethereum stack comprising a [go-ethereum](https://github.com/cerc-io/go-ethereum) execution layer node and a [lighthouse](https://github.com/sigp/lighthouse) consensus layer node.
|
|
||||||
|
|
||||||
## Clone required repositories
|
|
||||||
|
|
||||||
```
|
|
||||||
$ laconic-so --stack mainnet-eth setup-repositories
|
|
||||||
```
|
|
||||||
|
|
||||||
## Build containers
|
|
||||||
|
|
||||||
```
|
|
||||||
$ laconic-so --stack mainnet-eth build-containers
|
|
||||||
```
|
|
||||||
|
|
||||||
## Create a deployment
|
|
||||||
|
|
||||||
```
|
|
||||||
$ laconic-so --stack mainnet-eth deploy init --output mainnet-eth-spec.yml
|
|
||||||
$ laconic-so deploy create --spec-file mainnet-eth-spec.yml --deployment-dir mainnet-eth-deployment
|
|
||||||
```
|
|
||||||
## Start the stack
|
|
||||||
```
|
|
||||||
$ laconic-so deployment --dir mainnet-eth-deployment start
|
|
||||||
```
|
|
||||||
Display stack status:
|
|
||||||
```
|
|
||||||
$ laconic-so deployment --dir mainnet-eth-deployment ps
|
|
||||||
Running containers:
|
|
||||||
id: f39608eca04d72d6b0f1f3acefc5ebb52908da06e221d20c7138f7e3dff5e423, name: laconic-ef641b4d13eb61ed561b19be67063241-foundry-1, ports:
|
|
||||||
id: 4052b1eddd886ae0d6b41f9ff22e68a70f267b2bfde10f4b7b79b5bd1eeddcac, name: laconic-ef641b4d13eb61ed561b19be67063241-mainnet-eth-geth-1-1, ports: 30303/tcp, 30303/udp, 0.0.0.0:49184->40000/tcp, 0.0.0.0:49185->6060/tcp, 0.0.0.0:49186->8545/tcp, 8546/tcp
|
|
||||||
id: ac331232e597944b621b3b8942ace5dafb14524302cab338ff946c7f6e5a1d52, name: laconic-ef641b4d13eb61ed561b19be67063241-mainnet-eth-lighthouse-1-1, ports: 0.0.0.0:49187->8001/tcp
|
|
||||||
```
|
|
||||||
See stack logs:
|
|
||||||
```
|
|
||||||
$ laconic-so deployment --dir mainnet-eth-deployment logs
|
|
||||||
time="2023-07-25T09:46:29-06:00" level=warning msg="The \"CERC_SCRIPT_DEBUG\" variable is not set. Defaulting to a blank string."
|
|
||||||
laconic-ef641b4d13eb61ed561b19be67063241-mainnet-eth-lighthouse-1-1 | Jul 25 15:45:13.362 INFO Logging to file path: "/var/lighthouse-data-dir/beacon/logs/beacon.log"
|
|
||||||
laconic-ef641b4d13eb61ed561b19be67063241-mainnet-eth-lighthouse-1-1 | Jul 25 15:45:13.365 INFO Lighthouse started version: Lighthouse/v4.1.0-693886b
|
|
||||||
laconic-ef641b4d13eb61ed561b19be67063241-mainnet-eth-lighthouse-1-1 | Jul 25 15:45:13.365 INFO Configured for network name: mainnet
|
|
||||||
laconic-ef641b4d13eb61ed561b19be67063241-mainnet-eth-lighthouse-1-1 | Jul 25 15:45:13.366 INFO Data directory initialised datadir: /var/lighthouse-data-dir
|
|
||||||
laconic-ef641b4d13eb61ed561b19be67063241-mainnet-eth-lighthouse-1-1 | Jul 25 15:45:13.366 INFO Deposit contract address: 0x00000000219ab540356cbb839cbe05303d7705fa, deploy_block: 11184524
|
|
||||||
laconic-ef641b4d13eb61ed561b19be67063241-mainnet-eth-lighthouse-1-1 | Jul 25 15:45:13.424 INFO Starting checkpoint sync remote_url: https://beaconstate.ethstaker.cc/, service: beacon
|
|
||||||
```
|
|
||||||
## Monitoring stack sync progress
|
|
||||||
Both go-ethereum and lighthouse will engage in an initial chain sync phase that will last up to several hours depending on hardware performance and network capacity.
|
|
||||||
Syncing can be monitored by looking for these log messages:
|
|
||||||
```
|
|
||||||
Jul 24 12:34:17.001 INFO Downloading historical blocks est_time: 5 days 11 hrs, speed: 14.67 slots/sec, distance: 6932481 slots (137 weeks 3 days), service: slot_notifier
|
|
||||||
INFO [07-24|12:14:52.493] Syncing beacon headers downloaded=145,920 left=17,617,968 eta=1h23m32.815s
|
|
||||||
INFO [07-24|12:33:15.238] Syncing: chain download in progress synced=1.86% chain=148.94MiB headers=368,640@95.03MiB bodies=330,081@40.56MiB receipts=330,081@13.35MiB eta=37m54.505s
|
|
||||||
INFO [07-24|12:35:13.028] Syncing: state download in progress synced=1.32% state=4.64GiB accounts=2,850,314@677.57MiB slots=18,663,070@3.87GiB codes=26662@111.14MiB eta=3h18m0.699s
|
|
||||||
```
|
|
||||||
Once synced up these log messages will be observed:
|
|
||||||
```
|
|
||||||
INFO Synced slot: 6952515, block: 0x5bcb…f6d9, epoch: 217266, finalized_epoch: 217264, finalized_root: 0x6342…2c5c, exec_hash: 0x8d8c…2443 (verified), peers: 31, service: slot_notifier
|
|
||||||
INFO [07-25|03:04:48.941] Imported new potential chain segment number=17,767,316 hash=84f6e7..bc2cb0 blocks=1 txs=137 mgas=16.123 elapsed=57.087ms mgasps=282.434 dirty=461.46MiB
|
|
||||||
INFO [07-25|03:04:49.042] Chain head was updated number=17,767,316 hash=84f6e7..bc2cb0 root=ca58b2..8258c1 elapsed=2.480111ms
|
|
||||||
```
|
|
||||||
## Clean up
|
|
||||||
|
|
||||||
Stop the stack:
|
|
||||||
```
|
|
||||||
$ laconic-so deployment --dir mainnet-eth-deployment stop
|
|
||||||
```
|
|
||||||
This leaves data volumes in place, allowing the stack to be subsequently re-started.
|
|
||||||
To permanently *delete* the stack's data volumes run:
|
|
||||||
```
|
|
||||||
$ laconic-so deployment --dir mainnet-eth-deployment stop --delete-data-volumes
|
|
||||||
```
|
|
||||||
After deleting the volumes, any subsequent re-start will begin chain sync from cold.
|
|
||||||
## Data volumes
|
|
||||||
Container data volumes are bind-mounted to specified paths in the host filesystem.
|
|
||||||
The default setup (generated by `laconic-so deploy init`) places the volumes in the `./data` subdirectory of the deployment directory:
|
|
||||||
```
|
|
||||||
$ cat mainnet-eth-spec.yml
|
|
||||||
stack: mainnet-eth
|
|
||||||
volumes:
|
|
||||||
mainnet_eth_config_data: ./data/mainnet_eth_config_data
|
|
||||||
mainnet_eth_geth_1_data: ./data/mainnet_eth_geth_1_data
|
|
||||||
mainnet_eth_lighthouse_1_data: ./data/mainnet_eth_lighthouse_1_data
|
|
||||||
```
|
|
||||||
A synced-up stack will consume around 900GB of data volume space:
|
|
||||||
```
|
|
||||||
$ sudo du -h mainnet-eth-deployment/data/
|
|
||||||
150M mainnet-eth-deployment/data/mainnet_eth_lighthouse_1_data/beacon/freezer_db
|
|
||||||
25G mainnet-eth-deployment/data/mainnet_eth_lighthouse_1_data/beacon/chain_db
|
|
||||||
16K mainnet-eth-deployment/data/mainnet_eth_lighthouse_1_data/beacon/network
|
|
||||||
368M mainnet-eth-deployment/data/mainnet_eth_lighthouse_1_data/beacon/logs
|
|
||||||
26G mainnet-eth-deployment/data/mainnet_eth_lighthouse_1_data/beacon
|
|
||||||
26G mainnet-eth-deployment/data/mainnet_eth_lighthouse_1_data
|
|
||||||
8.0K mainnet-eth-deployment/data/mainnet_eth_config_data
|
|
||||||
4.0K mainnet-eth-deployment/data/mainnet_eth_geth_1_data/keystore
|
|
||||||
527G mainnet-eth-deployment/data/mainnet_eth_geth_1_data/geth/chaindata/ancient/chain
|
|
||||||
527G mainnet-eth-deployment/data/mainnet_eth_geth_1_data/geth/chaindata/ancient
|
|
||||||
859G mainnet-eth-deployment/data/mainnet_eth_geth_1_data/geth/chaindata
|
|
||||||
4.8M mainnet-eth-deployment/data/mainnet_eth_geth_1_data/geth/nodes
|
|
||||||
242M mainnet-eth-deployment/data/mainnet_eth_geth_1_data/geth/ethash
|
|
||||||
669M mainnet-eth-deployment/data/mainnet_eth_geth_1_data/geth/triecache
|
|
||||||
860G mainnet-eth-deployment/data/mainnet_eth_geth_1_data/geth
|
|
||||||
860G mainnet-eth-deployment/data/mainnet_eth_geth_1_data
|
|
||||||
885G mainnet-eth-deployment/data/
|
|
||||||
```
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
# Copyright © 2023 Cerc
|
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Affero General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
|
||||||
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
from secrets import token_hex
|
|
||||||
|
|
||||||
def init(ctx):
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def setup(ctx):
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def create(ctx):
|
|
||||||
# Generate the JWT secret and save to its config file
|
|
||||||
secret = token_hex(32)
|
|
||||||
jwt_file_path = ctx.deployment_dir.joinpath("data", "mainnet_eth_config_data", "jwtsecret")
|
|
||||||
with open(jwt_file_path, 'w+') as jwt_file:
|
|
||||||
jwt_file.write(secret)
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
version: "1.1"
|
|
||||||
name: mainnet-eth
|
|
||||||
decription: "Ethereum Mainnet"
|
|
||||||
repos:
|
|
||||||
- github.com/cerc-io/go-ethereum
|
|
||||||
- github.com/cerc-io/lighthouse
|
|
||||||
- github.com/dboreham/foundry
|
|
||||||
containers:
|
|
||||||
- cerc/go-ethereum
|
|
||||||
- cerc/lighthouse
|
|
||||||
- cerc/lighthouse-cli
|
|
||||||
- cerc/foundry
|
|
||||||
pods:
|
|
||||||
- mainnet-eth
|
|
||||||
- foundry
|
|
||||||
@@ -13,50 +13,45 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from dataclasses import dataclass
|
import click
|
||||||
from app.util import get_yaml
|
import os
|
||||||
from app.stack_state import State
|
from shutil import copyfile
|
||||||
|
import sys
|
||||||
|
from .util import get_stack_config_filename, get_parsed_deployment_spec
|
||||||
|
|
||||||
default_spec_file_content = """config:
|
default_spec_file_content = """stack: mainnet-laconic
|
||||||
node_moniker: my-node-name
|
data_dir: /my/path
|
||||||
chain_id: my-chain-id
|
node_name: my-node-name
|
||||||
"""
|
"""
|
||||||
|
|
||||||
init_help_text = """Add helpful text here on setting config variables.
|
|
||||||
"""
|
|
||||||
|
|
||||||
@dataclass
|
def make_default_deployment_dir():
|
||||||
class VolumeMapping:
|
return "deployment-001"
|
||||||
host_path: str
|
|
||||||
container_path: str
|
@click.command()
|
||||||
|
@click.option("--output", required=True, help="Write yaml spec file here")
|
||||||
|
@click.pass_context
|
||||||
|
def init(ctx, output):
|
||||||
|
with open(output, "w") as output_file:
|
||||||
|
output_file.write(default_spec_file_content)
|
||||||
|
|
||||||
|
|
||||||
# In order to make this, we need the ability to run the stack
|
@click.command()
|
||||||
# In theory we can make this same way as we would run deploy up
|
@click.option("--spec-file", required=True, help="Spec file to use to create this deployment")
|
||||||
def run_container_command(ctx, ontainer, command, mounts):
|
@click.option("--deployment-dir", help="Create deployment files in this directory")
|
||||||
deploy_context = ctx.obj
|
@click.pass_context
|
||||||
pass
|
def create(ctx, spec_file, deployment_dir):
|
||||||
|
# This function fails with a useful error message if the file doens't exist
|
||||||
|
parsed_spec = get_parsed_deployment_spec(spec_file)
|
||||||
def setup(ctx):
|
if ctx.debug:
|
||||||
node_moniker = "dbdb-node"
|
print(f"parsed spec: {parsed_spec}")
|
||||||
chain_id = "laconic_81337-1"
|
if deployment_dir is None:
|
||||||
mounts = [
|
deployment_dir = make_default_deployment_dir()
|
||||||
VolumeMapping("./path", "~/.laconicd")
|
if os.path.exists(deployment_dir):
|
||||||
]
|
print(f"Error: {deployment_dir} already exists")
|
||||||
output, status = run_container_command(ctx, "laconicd", f"laconicd init {node_moniker} --chain-id {chain_id}", mounts)
|
sys.exit(1)
|
||||||
|
os.mkdir(deployment_dir)
|
||||||
|
# Copy spec file and the stack file into the deployment dir
|
||||||
def init(command_context):
|
copyfile(spec_file, os.path.join(deployment_dir, os.path.basename(spec_file)))
|
||||||
print(init_help_text)
|
stack_file = get_stack_config_filename(parsed_spec.stack)
|
||||||
yaml = get_yaml()
|
copyfile(stack_file, os.path.join(deployment_dir, os.path.basename(stack_file)))
|
||||||
return yaml.load(default_spec_file_content)
|
|
||||||
|
|
||||||
|
|
||||||
def get_state(command_context):
|
|
||||||
print("Here we get state")
|
|
||||||
return State.CONFIGURED
|
|
||||||
|
|
||||||
|
|
||||||
def change_state(command_context):
|
|
||||||
pass
|
|
||||||
|
|||||||
@@ -25,4 +25,7 @@ containers:
|
|||||||
pods:
|
pods:
|
||||||
- mainnet-laconicd
|
- mainnet-laconicd
|
||||||
- fixturenet-laconic-console
|
- fixturenet-laconic-console
|
||||||
|
config:
|
||||||
|
cli:
|
||||||
|
key: laconicd.mykey
|
||||||
|
address: laconicd.myaddress
|
||||||
|
|||||||
@@ -22,13 +22,13 @@ Instructions to deploy Uniswap v3 watcher stack (watcher + uniswap-v3-info front
|
|||||||
* Clone / pull required repositories:
|
* Clone / pull required repositories:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ laconic-so --stack uniswap-v3 setup-repositories
|
$ laconic-so setup-repositories --include vulcanize/uniswap-watcher-ts,vulcanize/uniswap-v3-info --git-ssh --pull
|
||||||
```
|
```
|
||||||
|
|
||||||
* Build watcher and info app container images:
|
* Build watcher and info app container images:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ laconic-so --stack uniswap-v3 build-containers
|
$ laconic-so build-containers --include cerc/watcher-uniswap-v3,cerc/uniswap-v3-info
|
||||||
```
|
```
|
||||||
|
|
||||||
This should create the required docker images in the local image registry.
|
This should create the required docker images in the local image registry.
|
||||||
|
|||||||
@@ -3,14 +3,8 @@ name: uniswap-v3
|
|||||||
repos:
|
repos:
|
||||||
- github.com/vulcanize/uniswap-watcher-ts
|
- github.com/vulcanize/uniswap-watcher-ts
|
||||||
- github.com/vulcanize/uniswap-v3-info
|
- github.com/vulcanize/uniswap-v3-info
|
||||||
- github.com/cerc-io/ipld-eth-db
|
|
||||||
- github.com/cerc-io/ipld-eth-server
|
|
||||||
containers:
|
containers:
|
||||||
- cerc/watcher-uniswap-v3
|
- cerc/watcher-uniswap-v3
|
||||||
- cerc/uniswap-v3-info
|
- cerc/uniswap-v3-info
|
||||||
- cerc/ipld-eth-db
|
|
||||||
- cerc/ipld-eth-server
|
|
||||||
pods:
|
pods:
|
||||||
- watcher-uniswap-v3
|
- watcher-uniswap-v3
|
||||||
- ipld-eth-db
|
|
||||||
- ipld-eth-server
|
|
||||||
|
|||||||
+33
-35
@@ -26,10 +26,9 @@ import subprocess
|
|||||||
from python_on_whales import DockerClient, DockerException
|
from python_on_whales import DockerClient, DockerException
|
||||||
import click
|
import click
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from app.util import include_exclude_check, get_parsed_stack_config, global_options2
|
from .util import _log, include_exclude_check, get_parsed_stack_config, global_options2
|
||||||
from app.deployment_create import create as deployment_create
|
from .deployment_create import create as deployment_create
|
||||||
from app.deployment_create import init as deployment_init
|
from .deployment_create import init as deployment_init
|
||||||
from app.deployment_create import setup as deployment_setup
|
|
||||||
|
|
||||||
|
|
||||||
class DeployCommandContext(object):
|
class DeployCommandContext(object):
|
||||||
@@ -61,7 +60,7 @@ def create_deploy_context(global_context, stack, include, exclude, cluster, env_
|
|||||||
return DeployCommandContext(cluster_context, docker)
|
return DeployCommandContext(cluster_context, docker)
|
||||||
|
|
||||||
|
|
||||||
def up_operation(ctx, services_list, stay_attached=False):
|
def up_operation(ctx, services_list):
|
||||||
global_context = ctx.parent.parent.obj
|
global_context = ctx.parent.parent.obj
|
||||||
deploy_context = ctx.obj
|
deploy_context = ctx.obj
|
||||||
if not global_context.dry_run:
|
if not global_context.dry_run:
|
||||||
@@ -70,10 +69,10 @@ def up_operation(ctx, services_list, stay_attached=False):
|
|||||||
for attr, value in container_exec_env.items():
|
for attr, value in container_exec_env.items():
|
||||||
os.environ[attr] = value
|
os.environ[attr] = value
|
||||||
if global_context.verbose:
|
if global_context.verbose:
|
||||||
print(f"Running compose up with container_exec_env: {container_exec_env}, extra_args: {services_list}")
|
_log(f"Running compose up with container_exec_env: {container_exec_env}, extra_args: {services_list}")
|
||||||
for pre_start_command in cluster_context.pre_start_commands:
|
for pre_start_command in cluster_context.pre_start_commands:
|
||||||
_run_command(global_context, cluster_context.cluster, pre_start_command)
|
_run_command(global_context, cluster_context.cluster, pre_start_command)
|
||||||
deploy_context.docker.compose.up(detach=not stay_attached, services=services_list)
|
deploy_context.docker.compose.up(detach=True, services=services_list)
|
||||||
for post_start_command in cluster_context.post_start_commands:
|
for post_start_command in cluster_context.post_start_commands:
|
||||||
_run_command(global_context, cluster_context.cluster, post_start_command)
|
_run_command(global_context, cluster_context.cluster, post_start_command)
|
||||||
_orchestrate_cluster_config(global_context, cluster_context.config, deploy_context.docker, container_exec_env)
|
_orchestrate_cluster_config(global_context, cluster_context.config, deploy_context.docker, container_exec_env)
|
||||||
@@ -83,7 +82,7 @@ def down_operation(ctx, delete_volumes, extra_args_list):
|
|||||||
global_context = ctx.parent.parent.obj
|
global_context = ctx.parent.parent.obj
|
||||||
if not global_context.dry_run:
|
if not global_context.dry_run:
|
||||||
if global_context.verbose:
|
if global_context.verbose:
|
||||||
print("Running compose down")
|
_log("Running compose down")
|
||||||
timeout_arg = None
|
timeout_arg = None
|
||||||
if extra_args_list:
|
if extra_args_list:
|
||||||
timeout_arg = extra_args_list[0]
|
timeout_arg = extra_args_list[0]
|
||||||
@@ -95,7 +94,7 @@ def ps_operation(ctx):
|
|||||||
global_context = ctx.parent.parent.obj
|
global_context = ctx.parent.parent.obj
|
||||||
if not global_context.dry_run:
|
if not global_context.dry_run:
|
||||||
if global_context.verbose:
|
if global_context.verbose:
|
||||||
print("Running compose ps")
|
_log("Running compose ps")
|
||||||
container_list = ctx.obj.docker.compose.ps()
|
container_list = ctx.obj.docker.compose.ps()
|
||||||
if len(container_list) > 0:
|
if len(container_list) > 0:
|
||||||
print("Running containers:")
|
print("Running containers:")
|
||||||
@@ -121,12 +120,12 @@ def port_operation(ctx, extra_args):
|
|||||||
extra_args_list = list(extra_args) or None
|
extra_args_list = list(extra_args) or None
|
||||||
if not global_context.dry_run:
|
if not global_context.dry_run:
|
||||||
if extra_args_list is None or len(extra_args_list) < 2:
|
if extra_args_list is None or len(extra_args_list) < 2:
|
||||||
print("Usage: port <service> <exposed-port>")
|
_log("Usage: port <service> <exposed-port>")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
service_name = extra_args_list[0]
|
service_name = extra_args_list[0]
|
||||||
exposed_port = extra_args_list[1]
|
exposed_port = extra_args_list[1]
|
||||||
if global_context.verbose:
|
if global_context.verbose:
|
||||||
print(f"Running compose port {service_name} {exposed_port}")
|
_log(f"Running compose port {service_name} {exposed_port}")
|
||||||
mapped_port_data = ctx.obj.docker.compose.port(service_name, exposed_port)
|
mapped_port_data = ctx.obj.docker.compose.port(service_name, exposed_port)
|
||||||
print(f"{mapped_port_data[0]}:{mapped_port_data[1]}")
|
print(f"{mapped_port_data[0]}:{mapped_port_data[1]}")
|
||||||
|
|
||||||
@@ -136,17 +135,17 @@ def exec_operation(ctx, extra_args):
|
|||||||
extra_args_list = list(extra_args) or None
|
extra_args_list = list(extra_args) or None
|
||||||
if not global_context.dry_run:
|
if not global_context.dry_run:
|
||||||
if extra_args_list is None or len(extra_args_list) < 2:
|
if extra_args_list is None or len(extra_args_list) < 2:
|
||||||
print("Usage: exec <service> <cmd>")
|
_log("Usage: exec <service> <cmd>")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
service_name = extra_args_list[0]
|
service_name = extra_args_list[0]
|
||||||
command_to_exec = ["sh", "-c"] + extra_args_list[1:]
|
command_to_exec = ["sh", "-c"] + extra_args_list[1:]
|
||||||
container_exec_env = _make_runtime_env(global_context)
|
container_exec_env = _make_runtime_env(global_context)
|
||||||
if global_context.verbose:
|
if global_context.verbose:
|
||||||
print(f"Running compose exec {service_name} {command_to_exec}")
|
_log(f"Running compose exec {service_name} {command_to_exec}")
|
||||||
try:
|
try:
|
||||||
ctx.obj.docker.compose.execute(service_name, command_to_exec, envs=container_exec_env)
|
ctx.obj.docker.compose.execute(service_name, command_to_exec, envs=container_exec_env)
|
||||||
except DockerException as error:
|
except DockerException as error:
|
||||||
print(f"container command returned error exit status")
|
_log(f"container command returned error exit status")
|
||||||
|
|
||||||
|
|
||||||
def logs_operation(ctx, extra_args):
|
def logs_operation(ctx, extra_args):
|
||||||
@@ -154,7 +153,7 @@ def logs_operation(ctx, extra_args):
|
|||||||
extra_args_list = list(extra_args) or None
|
extra_args_list = list(extra_args) or None
|
||||||
if not global_context.dry_run:
|
if not global_context.dry_run:
|
||||||
if global_context.verbose:
|
if global_context.verbose:
|
||||||
print("Running compose logs")
|
_log("Running compose logs")
|
||||||
logs_output = ctx.obj.docker.compose.logs(services=extra_args_list if extra_args_list is not None else [])
|
logs_output = ctx.obj.docker.compose.logs(services=extra_args_list if extra_args_list is not None else [])
|
||||||
print(logs_output)
|
print(logs_output)
|
||||||
|
|
||||||
@@ -212,15 +211,15 @@ def get_stack_status(ctx, stack):
|
|||||||
docker = DockerClient(compose_files=cluster_context.compose_files, compose_project_name=cluster_context.cluster)
|
docker = DockerClient(compose_files=cluster_context.compose_files, compose_project_name=cluster_context.cluster)
|
||||||
# TODO: refactor to avoid duplicating this code above
|
# TODO: refactor to avoid duplicating this code above
|
||||||
if ctx.verbose:
|
if ctx.verbose:
|
||||||
print("Running compose ps")
|
_log("Running compose ps")
|
||||||
container_list = docker.compose.ps()
|
container_list = docker.compose.ps()
|
||||||
if len(container_list) > 0:
|
if len(container_list) > 0:
|
||||||
if ctx.debug:
|
if ctx.debug:
|
||||||
print(f"Container list from compose ps: {container_list}")
|
_log(f"Container list from compose ps: {container_list}")
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
if ctx.debug:
|
if ctx.debug:
|
||||||
print("No containers found from compose ps")
|
_log("No containers found from compose ps")
|
||||||
False
|
False
|
||||||
|
|
||||||
|
|
||||||
@@ -238,7 +237,7 @@ def _make_cluster_context(ctx, stack, include, exclude, cluster, env_file):
|
|||||||
|
|
||||||
if ctx.local_stack:
|
if ctx.local_stack:
|
||||||
dev_root_path = os.getcwd()[0:os.getcwd().rindex("stack-orchestrator")]
|
dev_root_path = os.getcwd()[0:os.getcwd().rindex("stack-orchestrator")]
|
||||||
print(f'Local stack dev_root_path (CERC_REPO_BASE_DIR) overridden to: {dev_root_path}')
|
_log(f'Local stack dev_root_path (CERC_REPO_BASE_DIR) overridden to: {dev_root_path}')
|
||||||
else:
|
else:
|
||||||
dev_root_path = os.path.expanduser(config("CERC_REPO_BASE_DIR", default="~/cerc"))
|
dev_root_path = os.path.expanduser(config("CERC_REPO_BASE_DIR", default="~/cerc"))
|
||||||
|
|
||||||
@@ -257,14 +256,14 @@ def _make_cluster_context(ctx, stack, include, exclude, cluster, env_file):
|
|||||||
path = os.path.realpath(sys.argv[0])
|
path = os.path.realpath(sys.argv[0])
|
||||||
unique_cluster_descriptor = f"{path},{stack},{include},{exclude}"
|
unique_cluster_descriptor = f"{path},{stack},{include},{exclude}"
|
||||||
if ctx.debug:
|
if ctx.debug:
|
||||||
print(f"pre-hash descriptor: {unique_cluster_descriptor}")
|
_log(f"pre-hash descriptor: {unique_cluster_descriptor}")
|
||||||
hash = hashlib.md5(unique_cluster_descriptor.encode()).hexdigest()
|
hash = hashlib.md5(unique_cluster_descriptor.encode()).hexdigest()
|
||||||
cluster = f"laconic-{hash}"
|
cluster = f"laconic-{hash}"
|
||||||
if ctx.verbose:
|
if ctx.verbose:
|
||||||
print(f"Using cluster name: {cluster}")
|
_log(f"Using cluster name: {cluster}")
|
||||||
|
|
||||||
# See: https://stackoverflow.com/a/20885799/1701505
|
# See: https://stackoverflow.com/a/20885799/1701505
|
||||||
from app import data
|
from . import data
|
||||||
with resources.open_text(data, "pod-list.txt") as pod_list_file:
|
with resources.open_text(data, "pod-list.txt") as pod_list_file:
|
||||||
all_pods = pod_list_file.read().splitlines()
|
all_pods = pod_list_file.read().splitlines()
|
||||||
|
|
||||||
@@ -282,7 +281,7 @@ def _make_cluster_context(ctx, stack, include, exclude, cluster, env_file):
|
|||||||
pods_in_scope = _convert_to_new_format(pods_in_scope)
|
pods_in_scope = _convert_to_new_format(pods_in_scope)
|
||||||
|
|
||||||
if ctx.verbose:
|
if ctx.verbose:
|
||||||
print(f"Pods: {pods_in_scope}")
|
_log(f"Pods: {pods_in_scope}")
|
||||||
|
|
||||||
# Construct a docker compose command suitable for our purpose
|
# Construct a docker compose command suitable for our purpose
|
||||||
|
|
||||||
@@ -308,10 +307,10 @@ def _make_cluster_context(ctx, stack, include, exclude, cluster, env_file):
|
|||||||
compose_files.append(compose_file_name)
|
compose_files.append(compose_file_name)
|
||||||
else:
|
else:
|
||||||
if ctx.verbose:
|
if ctx.verbose:
|
||||||
print(f"Excluding: {pod_name}")
|
_log(f"Excluding: {pod_name}")
|
||||||
|
|
||||||
if ctx.verbose:
|
if ctx.verbose:
|
||||||
print(f"files: {compose_files}")
|
_log(f"files: {compose_files}")
|
||||||
|
|
||||||
return cluster_context(cluster, compose_files, pre_start_commands, post_start_commands, cluster_config, env_file)
|
return cluster_context(cluster, compose_files, pre_start_commands, post_start_commands, cluster_config, env_file)
|
||||||
|
|
||||||
@@ -343,7 +342,7 @@ def _convert_to_new_format(old_pod_array):
|
|||||||
|
|
||||||
def _run_command(ctx, cluster_name, command):
|
def _run_command(ctx, cluster_name, command):
|
||||||
if ctx.verbose:
|
if ctx.verbose:
|
||||||
print(f"Running command: {command}")
|
_log(f"Running command: {command}")
|
||||||
command_dir = os.path.dirname(command)
|
command_dir = os.path.dirname(command)
|
||||||
command_file = os.path.join(".", os.path.basename(command))
|
command_file = os.path.join(".", os.path.basename(command))
|
||||||
command_env = os.environ.copy()
|
command_env = os.environ.copy()
|
||||||
@@ -352,7 +351,7 @@ def _run_command(ctx, cluster_name, command):
|
|||||||
command_env["CERC_SCRIPT_DEBUG"] = "true"
|
command_env["CERC_SCRIPT_DEBUG"] = "true"
|
||||||
command_result = subprocess.run(command_file, shell=True, env=command_env, cwd=command_dir)
|
command_result = subprocess.run(command_file, shell=True, env=command_env, cwd=command_dir)
|
||||||
if command_result.returncode != 0:
|
if command_result.returncode != 0:
|
||||||
print(f"FATAL Error running command: {command}")
|
_log(f"FATAL Error running command: {command}")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
@@ -369,7 +368,7 @@ def _orchestrate_cluster_config(ctx, cluster_config, docker, container_exec_env)
|
|||||||
for container in cluster_config:
|
for container in cluster_config:
|
||||||
container_config = cluster_config[container]
|
container_config = cluster_config[container]
|
||||||
if ctx.verbose:
|
if ctx.verbose:
|
||||||
print(f"{container} config: {container_config}")
|
_log(f"{container} config: {container_config}")
|
||||||
for directive in container_config:
|
for directive in container_config:
|
||||||
pd = ConfigDirective(
|
pd = ConfigDirective(
|
||||||
container_config[directive].split(".")[0],
|
container_config[directive].split(".")[0],
|
||||||
@@ -378,7 +377,7 @@ def _orchestrate_cluster_config(ctx, cluster_config, docker, container_exec_env)
|
|||||||
directive
|
directive
|
||||||
)
|
)
|
||||||
if ctx.verbose:
|
if ctx.verbose:
|
||||||
print(f"Setting {pd.destination_container}.{pd.destination_variable}"
|
_log(f"Setting {pd.destination_container}.{pd.destination_variable}"
|
||||||
f" = {pd.source_container}.{pd.source_variable}")
|
f" = {pd.source_container}.{pd.source_variable}")
|
||||||
# TODO: add a timeout
|
# TODO: add a timeout
|
||||||
waiting_for_data = True
|
waiting_for_data = True
|
||||||
@@ -395,19 +394,19 @@ def _orchestrate_cluster_config(ctx, cluster_config, docker, container_exec_env)
|
|||||||
envs=container_exec_env)
|
envs=container_exec_env)
|
||||||
except DockerException as error:
|
except DockerException as error:
|
||||||
if ctx.debug:
|
if ctx.debug:
|
||||||
print(f"Docker exception reading config source: {error}")
|
_log(f"Docker exception reading config source: {error}")
|
||||||
# If the script executed failed for some reason, we get:
|
# If the script executed failed for some reason, we get:
|
||||||
# "It returned with code 1"
|
# "It returned with code 1"
|
||||||
if "It returned with code 1" in str(error):
|
if "It returned with code 1" in str(error):
|
||||||
if ctx.verbose:
|
if ctx.verbose:
|
||||||
print("Config export script returned an error, re-trying")
|
_log("Config export script returned an error, re-trying")
|
||||||
# If the script failed to execute (e.g. the file is not there) then we get:
|
# If the script failed to execute (e.g. the file is not there) then we get:
|
||||||
# "It returned with code 2"
|
# "It returned with code 2"
|
||||||
if "It returned with code 2" in str(error):
|
if "It returned with code 2" in str(error):
|
||||||
print(f"Fatal error reading config source: {error}")
|
_log(f"Fatal error reading config source: {error}")
|
||||||
if source_value:
|
if source_value:
|
||||||
if ctx.debug:
|
if ctx.debug:
|
||||||
print(f"fetched source value: {source_value}")
|
_log(f"fetched source value: {source_value}")
|
||||||
destination_output = docker.compose.execute(pd.destination_container,
|
destination_output = docker.compose.execute(pd.destination_container,
|
||||||
["sh", "-c",
|
["sh", "-c",
|
||||||
f"sh /scripts/import-{pd.destination_variable}.sh"
|
f"sh /scripts/import-{pd.destination_variable}.sh"
|
||||||
@@ -416,9 +415,8 @@ def _orchestrate_cluster_config(ctx, cluster_config, docker, container_exec_env)
|
|||||||
envs=container_exec_env)
|
envs=container_exec_env)
|
||||||
waiting_for_data = False
|
waiting_for_data = False
|
||||||
if ctx.debug:
|
if ctx.debug:
|
||||||
print(f"destination output: {destination_output}")
|
_log(f"destination output: {destination_output}")
|
||||||
|
|
||||||
|
|
||||||
command.add_command(deployment_init)
|
command.add_command(deployment_init)
|
||||||
command.add_command(deployment_create)
|
command.add_command(deployment_create)
|
||||||
command.add_command(deployment_setup)
|
|
||||||
|
|||||||
+22
-14
@@ -17,8 +17,8 @@ import click
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import sys
|
import sys
|
||||||
from app.deploy import up_operation, down_operation, ps_operation, port_operation, exec_operation, logs_operation, create_deploy_context
|
from .deploy import up_operation, down_operation, ps_operation, port_operation, exec_operation, logs_operation, create_deploy_context
|
||||||
from app.util import global_options
|
from .util import global_options
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@@ -54,46 +54,42 @@ def make_deploy_context(ctx):
|
|||||||
|
|
||||||
|
|
||||||
@command.command()
|
@command.command()
|
||||||
@click.option("--stay-attached/--detatch-terminal", default=False, help="detatch or not to see container stdout")
|
|
||||||
@click.argument('extra_args', nargs=-1) # help: command: up <service1> <service2>
|
@click.argument('extra_args', nargs=-1) # help: command: up <service1> <service2>
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def up(ctx, stay_attached, extra_args):
|
def up(ctx, extra_args):
|
||||||
ctx.obj = make_deploy_context(ctx)
|
ctx.obj = make_deploy_context(ctx)
|
||||||
services_list = list(extra_args) or None
|
services_list = list(extra_args) or None
|
||||||
up_operation(ctx, services_list, stay_attached)
|
up_operation(ctx, services_list)
|
||||||
|
|
||||||
|
|
||||||
# start is the preferred alias for up
|
# start is the preferred alias for up
|
||||||
@command.command()
|
@command.command()
|
||||||
@click.option("--stay-attached/--detatch-terminal", default=False, help="detatch or not to see container stdout")
|
|
||||||
@click.argument('extra_args', nargs=-1) # help: command: up <service1> <service2>
|
@click.argument('extra_args', nargs=-1) # help: command: up <service1> <service2>
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def start(ctx, stay_attached, extra_args):
|
def start(ctx, extra_args):
|
||||||
ctx.obj = make_deploy_context(ctx)
|
ctx.obj = make_deploy_context(ctx)
|
||||||
services_list = list(extra_args) or None
|
services_list = list(extra_args) or None
|
||||||
up_operation(ctx, services_list, stay_attached)
|
up_operation(ctx, services_list)
|
||||||
|
|
||||||
|
|
||||||
@command.command()
|
@command.command()
|
||||||
@click.option("--delete-volumes/--preserve-volumes", default=False, help="delete data volumes")
|
|
||||||
@click.argument('extra_args', nargs=-1) # help: command: down <service1> <service2>
|
@click.argument('extra_args', nargs=-1) # help: command: down <service1> <service2>
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def down(ctx, delete_volumes, extra_args):
|
def down(ctx, extra_args):
|
||||||
# Get the stack config file name
|
# Get the stack config file name
|
||||||
# TODO: add cluster name and env file here
|
# TODO: add cluster name and env file here
|
||||||
ctx.obj = make_deploy_context(ctx)
|
ctx.obj = make_deploy_context(ctx)
|
||||||
down_operation(ctx, delete_volumes, extra_args)
|
down_operation(ctx, extra_args, None)
|
||||||
|
|
||||||
|
|
||||||
# stop is the preferred alias for down
|
# stop is the preferred alias for down
|
||||||
@command.command()
|
@command.command()
|
||||||
@click.option("--delete-volumes/--preserve-volumes", default=False, help="delete data volumes")
|
|
||||||
@click.argument('extra_args', nargs=-1) # help: command: down <service1> <service2>
|
@click.argument('extra_args', nargs=-1) # help: command: down <service1> <service2>
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def stop(ctx, delete_volumes, extra_args):
|
def stop(ctx, extra_args):
|
||||||
# TODO: add cluster name and env file here
|
# TODO: add cluster name and env file here
|
||||||
ctx.obj = make_deploy_context(ctx)
|
ctx.obj = make_deploy_context(ctx)
|
||||||
down_operation(ctx, delete_volumes, extra_args)
|
down_operation(ctx, extra_args, None)
|
||||||
|
|
||||||
|
|
||||||
@command.command()
|
@command.command()
|
||||||
@@ -130,3 +126,15 @@ def logs(ctx, extra_args):
|
|||||||
@click.pass_context
|
@click.pass_context
|
||||||
def status(ctx):
|
def status(ctx):
|
||||||
print(f"Context: {ctx.parent.obj}")
|
print(f"Context: {ctx.parent.obj}")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#from importlib import resources, util
|
||||||
|
# TODO: figure out how to do this dynamically
|
||||||
|
#stack = "mainnet-laconic"
|
||||||
|
#module_name = "commands"
|
||||||
|
#spec = util.spec_from_file_location(module_name, "./app/data/stacks/" + stack + "/deploy/commands.py")
|
||||||
|
#imported_stack = util.module_from_spec(spec)
|
||||||
|
#spec.loader.exec_module(imported_stack)
|
||||||
|
#command.add_command(imported_stack.init)
|
||||||
|
#command.add_command(imported_stack.create)
|
||||||
|
|||||||
+16
-94
@@ -14,18 +14,20 @@
|
|||||||
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import click
|
import click
|
||||||
from dataclasses import dataclass
|
|
||||||
from importlib import util
|
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from shutil import copyfile, copytree
|
from shutil import copyfile, copytree
|
||||||
import sys
|
import sys
|
||||||
from app.util import get_stack_file_path, get_parsed_deployment_spec, get_parsed_stack_config, global_options, get_yaml
|
import ruamel.yaml
|
||||||
|
from .util import get_stack_file_path, get_parsed_deployment_spec, get_parsed_stack_config, global_options
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class DeploymentContext:
|
def _get_yaml():
|
||||||
stack: str
|
# See: https://stackoverflow.com/a/45701840/1701505
|
||||||
deployment_dir: Path
|
yaml = ruamel.yaml.YAML()
|
||||||
|
yaml.preserve_quotes = True
|
||||||
|
yaml.indent(sequence=3, offset=1)
|
||||||
|
return yaml
|
||||||
|
|
||||||
|
|
||||||
def _make_default_deployment_dir():
|
def _make_default_deployment_dir():
|
||||||
@@ -45,7 +47,7 @@ def _get_named_volumes(stack):
|
|||||||
named_volumes = []
|
named_volumes = []
|
||||||
parsed_stack = get_parsed_stack_config(stack)
|
parsed_stack = get_parsed_stack_config(stack)
|
||||||
pods = parsed_stack["pods"]
|
pods = parsed_stack["pods"]
|
||||||
yaml = get_yaml()
|
yaml = _get_yaml()
|
||||||
for pod in pods:
|
for pod in pods:
|
||||||
pod_file_path = os.path.join(_get_compose_file_dir(), f"docker-compose-{pod}.yml")
|
pod_file_path = os.path.join(_get_compose_file_dir(), f"docker-compose-{pod}.yml")
|
||||||
parsed_pod_file = yaml.load(open(pod_file_path, "r"))
|
parsed_pod_file = yaml.load(open(pod_file_path, "r"))
|
||||||
@@ -94,77 +96,21 @@ def _fixup_pod_file(pod, spec, compose_dir):
|
|||||||
pod["volumes"][volume] = new_volume_spec
|
pod["volumes"][volume] = new_volume_spec
|
||||||
|
|
||||||
|
|
||||||
def call_stack_deploy_init(stack):
|
|
||||||
# Link with the python file in the stack
|
|
||||||
# Call a function in it
|
|
||||||
# If no function found, return None
|
|
||||||
python_file_path = get_stack_file_path(stack).parent.joinpath("deploy", "commands.py")
|
|
||||||
spec = util.spec_from_file_location("commands", python_file_path)
|
|
||||||
imported_stack = util.module_from_spec(spec)
|
|
||||||
spec.loader.exec_module(imported_stack)
|
|
||||||
return imported_stack.init(None)
|
|
||||||
|
|
||||||
|
|
||||||
# TODO: fold this with function above
|
|
||||||
def call_stack_deploy_setup(stack):
|
|
||||||
# Link with the python file in the stack
|
|
||||||
# Call a function in it
|
|
||||||
# If no function found, return None
|
|
||||||
python_file_path = get_stack_file_path(stack).parent.joinpath("deploy", "commands.py")
|
|
||||||
spec = util.spec_from_file_location("commands", python_file_path)
|
|
||||||
imported_stack = util.module_from_spec(spec)
|
|
||||||
spec.loader.exec_module(imported_stack)
|
|
||||||
return imported_stack.setup(None)
|
|
||||||
|
|
||||||
|
|
||||||
# TODO: fold this with function above
|
|
||||||
def call_stack_deploy_create(deployment_context):
|
|
||||||
# Link with the python file in the stack
|
|
||||||
# Call a function in it
|
|
||||||
# If no function found, return None
|
|
||||||
python_file_path = get_stack_file_path(deployment_context.stack).parent.joinpath("deploy", "commands.py")
|
|
||||||
spec = util.spec_from_file_location("commands", python_file_path)
|
|
||||||
imported_stack = util.module_from_spec(spec)
|
|
||||||
spec.loader.exec_module(imported_stack)
|
|
||||||
return imported_stack.create(deployment_context)
|
|
||||||
|
|
||||||
|
|
||||||
# Inspect the pod yaml to find config files referenced in subdirectories
|
|
||||||
# other than the one associated with the pod
|
|
||||||
def _find_extra_config_dirs(parsed_pod_file, pod):
|
|
||||||
config_dirs = set()
|
|
||||||
services = parsed_pod_file["services"]
|
|
||||||
for service in services:
|
|
||||||
service_info = services[service]
|
|
||||||
if "volumes" in service_info:
|
|
||||||
for volume in service_info["volumes"]:
|
|
||||||
if ":" in volume:
|
|
||||||
host_path = volume.split(":")[0]
|
|
||||||
if host_path.startswith("../config"):
|
|
||||||
config_dir = host_path.split("/")[2]
|
|
||||||
if config_dir != pod:
|
|
||||||
config_dirs.add(config_dir)
|
|
||||||
return config_dirs
|
|
||||||
|
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
@click.option("--output", required=True, help="Write yaml spec file here")
|
@click.option("--output", required=True, help="Write yaml spec file here")
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def init(ctx, output):
|
def init(ctx, output):
|
||||||
yaml = get_yaml()
|
yaml = _get_yaml()
|
||||||
stack = global_options(ctx).stack
|
stack = global_options(ctx).stack
|
||||||
verbose = global_options(ctx).verbose
|
verbose = global_options(ctx).verbose
|
||||||
default_spec_file_content = call_stack_deploy_init(stack)
|
|
||||||
spec_file_content = {"stack": stack}
|
spec_file_content = {"stack": stack}
|
||||||
if default_spec_file_content:
|
|
||||||
spec_file_content.update(default_spec_file_content)
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print(f"Creating spec file for stack: {stack}")
|
print(f"Creating spec file for stack: {stack}")
|
||||||
named_volumes = _get_named_volumes(stack)
|
named_volumes = _get_named_volumes(stack)
|
||||||
if named_volumes:
|
if named_volumes:
|
||||||
volume_descriptors = {}
|
volume_descriptors = {}
|
||||||
for named_volume in named_volumes:
|
for named_volume in named_volumes:
|
||||||
volume_descriptors[named_volume] = f"./data/{named_volume}"
|
volume_descriptors[named_volume] = f"../data/{named_volume}"
|
||||||
spec_file_content["volumes"] = volume_descriptors
|
spec_file_content["volumes"] = volume_descriptors
|
||||||
with open(output, "w") as output_file:
|
with open(output, "w") as output_file:
|
||||||
yaml.dump(spec_file_content, output_file)
|
yaml.dump(spec_file_content, output_file)
|
||||||
@@ -196,38 +142,14 @@ def create(ctx, spec_file, deployment_dir):
|
|||||||
destination_compose_dir = os.path.join(deployment_dir, "compose")
|
destination_compose_dir = os.path.join(deployment_dir, "compose")
|
||||||
os.mkdir(destination_compose_dir)
|
os.mkdir(destination_compose_dir)
|
||||||
data_dir = Path(__file__).absolute().parent.joinpath("data")
|
data_dir = Path(__file__).absolute().parent.joinpath("data")
|
||||||
yaml = get_yaml()
|
yaml = _get_yaml()
|
||||||
for pod in pods:
|
for pod in pods:
|
||||||
pod_file_path = os.path.join(_get_compose_file_dir(), f"docker-compose-{pod}.yml")
|
pod_file_path = os.path.join(_get_compose_file_dir(), f"docker-compose-{pod}.yml")
|
||||||
parsed_pod_file = yaml.load(open(pod_file_path, "r"))
|
parsed_pod_file = yaml.load(open(pod_file_path, "r"))
|
||||||
extra_config_dirs = _find_extra_config_dirs(parsed_pod_file, pod)
|
|
||||||
if global_options(ctx).debug:
|
|
||||||
print(f"extra config dirs: {extra_config_dirs}")
|
|
||||||
_fixup_pod_file(parsed_pod_file, parsed_spec, destination_compose_dir)
|
_fixup_pod_file(parsed_pod_file, parsed_spec, destination_compose_dir)
|
||||||
with open(os.path.join(destination_compose_dir, os.path.basename(pod_file_path)), "w") as output_file:
|
with open(os.path.join(destination_compose_dir, os.path.basename(pod_file_path)), "w") as output_file:
|
||||||
yaml.dump(parsed_pod_file, output_file)
|
yaml.dump(parsed_pod_file, output_file)
|
||||||
# Copy the config files for the pod, if any
|
# Copy the config files for the pod, if any
|
||||||
config_dirs = {pod}
|
source_config_dir = data_dir.joinpath("config", pod)
|
||||||
config_dirs = config_dirs.union(extra_config_dirs)
|
if os.path.exists(source_config_dir):
|
||||||
for config_dir in config_dirs:
|
copytree(source_config_dir, os.path.join(deployment_dir, "config", pod))
|
||||||
source_config_dir = data_dir.joinpath("config", config_dir)
|
|
||||||
if os.path.exists(source_config_dir):
|
|
||||||
destination_config_dir = os.path.join(deployment_dir, "config", config_dir)
|
|
||||||
# If the same config dir appears in multiple pods, it may already have been copied
|
|
||||||
if not os.path.exists(destination_config_dir):
|
|
||||||
copytree(source_config_dir, destination_config_dir)
|
|
||||||
# Delegate to the stack's Python code
|
|
||||||
deployment_context = DeploymentContext(stack_name, Path(deployment_dir))
|
|
||||||
call_stack_deploy_create(deployment_context)
|
|
||||||
|
|
||||||
|
|
||||||
@click.command()
|
|
||||||
@click.option("--node-moniker", help="Help goes here")
|
|
||||||
@click.option("--key-name", help="Help goes here")
|
|
||||||
@click.option("--initialize-network", is_flag=True, default=False, help="Help goes here")
|
|
||||||
@click.option("--join-network", is_flag=True, default=False, help="Help goes here")
|
|
||||||
@click.option("--create-network", is_flag=True, default=False, help="Help goes here")
|
|
||||||
@click.pass_context
|
|
||||||
def setup(ctx, node_moniker, key_name, initialize_network, join_network, create_network):
|
|
||||||
stack = global_options(ctx).stack
|
|
||||||
call_stack_deploy_setup(stack)
|
|
||||||
|
|||||||
+26
-26
@@ -25,7 +25,7 @@ import click
|
|||||||
import importlib.resources
|
import importlib.resources
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import yaml
|
import yaml
|
||||||
from app.util import include_exclude_check
|
from .util import _log, include_exclude_check
|
||||||
|
|
||||||
|
|
||||||
class GitProgress(git.RemoteProgress):
|
class GitProgress(git.RemoteProgress):
|
||||||
@@ -88,7 +88,7 @@ def _get_repo_current_branch_or_tag(full_filesystem_repo_path):
|
|||||||
# TODO: fix the messy arg list here
|
# TODO: fix the messy arg list here
|
||||||
def process_repo(verbose, quiet, dry_run, pull, check_only, git_ssh, dev_root_path, branches_array, fully_qualified_repo):
|
def process_repo(verbose, quiet, dry_run, pull, check_only, git_ssh, dev_root_path, branches_array, fully_qualified_repo):
|
||||||
if verbose:
|
if verbose:
|
||||||
print(f"Processing repo: {fully_qualified_repo}")
|
_log(f"Processing repo: {fully_qualified_repo}")
|
||||||
repo_host, repo_path, repo_branch = host_and_path_for_repo(fully_qualified_repo)
|
repo_host, repo_path, repo_branch = host_and_path_for_repo(fully_qualified_repo)
|
||||||
git_ssh_prefix = f"git@{repo_host}:"
|
git_ssh_prefix = f"git@{repo_host}:"
|
||||||
git_http_prefix = f"https://{repo_host}/"
|
git_http_prefix = f"https://{repo_host}/"
|
||||||
@@ -100,40 +100,40 @@ def process_repo(verbose, quiet, dry_run, pull, check_only, git_ssh, dev_root_pa
|
|||||||
if not quiet:
|
if not quiet:
|
||||||
present_text = f"already exists active {'branch' if is_branch else 'tag'}: {current_repo_branch_or_tag}" if is_present \
|
present_text = f"already exists active {'branch' if is_branch else 'tag'}: {current_repo_branch_or_tag}" if is_present \
|
||||||
else 'Needs to be fetched'
|
else 'Needs to be fetched'
|
||||||
print(f"Checking: {full_filesystem_repo_path}: {present_text}")
|
_log(f"Checking: {full_filesystem_repo_path}: {present_text}")
|
||||||
# Quick check that it's actually a repo
|
# Quick check that it's actually a repo
|
||||||
if is_present:
|
if is_present:
|
||||||
if not is_git_repo(full_filesystem_repo_path):
|
if not is_git_repo(full_filesystem_repo_path):
|
||||||
print(f"Error: {full_filesystem_repo_path} does not contain a valid git repository")
|
_log(f"Error: {full_filesystem_repo_path} does not contain a valid git repository")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
if pull:
|
if pull:
|
||||||
if verbose:
|
if verbose:
|
||||||
print(f"Running git pull for {full_filesystem_repo_path}")
|
_log(f"Running git pull for {full_filesystem_repo_path}")
|
||||||
if not check_only:
|
if not check_only:
|
||||||
if is_branch:
|
if is_branch:
|
||||||
git_repo = git.Repo(full_filesystem_repo_path)
|
git_repo = git.Repo(full_filesystem_repo_path)
|
||||||
origin = git_repo.remotes.origin
|
origin = git_repo.remotes.origin
|
||||||
origin.pull(progress=None if quiet else GitProgress())
|
origin.pull(progress=None if quiet else GitProgress())
|
||||||
else:
|
else:
|
||||||
print(f"skipping pull because this repo checked out a tag")
|
_log(f"skipping pull because this repo checked out a tag")
|
||||||
else:
|
else:
|
||||||
print("(git pull skipped)")
|
_log("(git pull skipped)")
|
||||||
if not is_present:
|
if not is_present:
|
||||||
# Clone
|
# Clone
|
||||||
if verbose:
|
if verbose:
|
||||||
print(f'Running git clone for {full_github_repo_path} into {full_filesystem_repo_path}')
|
_log(f'Running git clone for {full_github_repo_path} into {full_filesystem_repo_path}')
|
||||||
if not dry_run:
|
if not dry_run:
|
||||||
git.Repo.clone_from(full_github_repo_path,
|
git.Repo.clone_from(full_github_repo_path,
|
||||||
full_filesystem_repo_path,
|
full_filesystem_repo_path,
|
||||||
progress=None if quiet else GitProgress())
|
progress=None if quiet else GitProgress())
|
||||||
else:
|
else:
|
||||||
print("(git clone skipped)")
|
_log("(git clone skipped)")
|
||||||
# Checkout the requested branch, if one was specified
|
# Checkout the requested branch, if one was specified
|
||||||
branch_to_checkout = None
|
branch_to_checkout = None
|
||||||
if branches_array:
|
if branches_array:
|
||||||
# Find the current repo in the branches list
|
# Find the current repo in the branches list
|
||||||
print("Checking")
|
_log("Checking")
|
||||||
for repo_branch in branches_array:
|
for repo_branch in branches_array:
|
||||||
repo_branch_tuple = repo_branch.split(" ")
|
repo_branch_tuple = repo_branch.split(" ")
|
||||||
if repo_branch_tuple[0] == branch_strip(fully_qualified_repo):
|
if repo_branch_tuple[0] == branch_strip(fully_qualified_repo):
|
||||||
@@ -145,13 +145,13 @@ def process_repo(verbose, quiet, dry_run, pull, check_only, git_ssh, dev_root_pa
|
|||||||
if branch_to_checkout:
|
if branch_to_checkout:
|
||||||
if current_repo_branch_or_tag is None or (current_repo_branch_or_tag and (current_repo_branch_or_tag != branch_to_checkout)):
|
if current_repo_branch_or_tag is None or (current_repo_branch_or_tag and (current_repo_branch_or_tag != branch_to_checkout)):
|
||||||
if not quiet:
|
if not quiet:
|
||||||
print(f"switching to branch {branch_to_checkout} in repo {repo_path}")
|
_log(f"switching to branch {branch_to_checkout} in repo {repo_path}")
|
||||||
git_repo = git.Repo(full_filesystem_repo_path)
|
git_repo = git.Repo(full_filesystem_repo_path)
|
||||||
# git checkout works for both branches and tags
|
# git checkout works for both branches and tags
|
||||||
git_repo.git.checkout(branch_to_checkout)
|
git_repo.git.checkout(branch_to_checkout)
|
||||||
else:
|
else:
|
||||||
if verbose:
|
if verbose:
|
||||||
print(f"repo {repo_path} is already on branch/tag {branch_to_checkout}")
|
_log(f"repo {repo_path} is already on branch/tag {branch_to_checkout}")
|
||||||
|
|
||||||
|
|
||||||
def parse_branches(branches_string):
|
def parse_branches(branches_string):
|
||||||
@@ -161,7 +161,7 @@ def parse_branches(branches_string):
|
|||||||
for branch_directive in branches_directives:
|
for branch_directive in branches_directives:
|
||||||
split_directive = branch_directive.split("@")
|
split_directive = branch_directive.split("@")
|
||||||
if len(split_directive) != 2:
|
if len(split_directive) != 2:
|
||||||
print(f"Error: branch specified is not valid: {branch_directive}")
|
_log(f"Error: branch specified is not valid: {branch_directive}")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
result_array.append(f"{split_directive[0]} {split_directive[1]}")
|
result_array.append(f"{split_directive[0]} {split_directive[1]}")
|
||||||
return result_array
|
return result_array
|
||||||
@@ -191,43 +191,43 @@ def command(ctx, include, exclude, git_ssh, check_only, pull, branches, branches
|
|||||||
# TODO: branches file needs to be re-worked in the context of stacks
|
# TODO: branches file needs to be re-worked in the context of stacks
|
||||||
if branches_file:
|
if branches_file:
|
||||||
if branches:
|
if branches:
|
||||||
print("Error: can't specify both --branches and --branches-file")
|
_log("Error: can't specify both --branches and --branches-file")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
if verbose:
|
if verbose:
|
||||||
print(f"loading branches from: {branches_file}")
|
_log(f"loading branches from: {branches_file}")
|
||||||
with open(branches_file) as branches_file_open:
|
with open(branches_file) as branches_file_open:
|
||||||
branches_array = branches_file_open.read().splitlines()
|
branches_array = branches_file_open.read().splitlines()
|
||||||
|
|
||||||
print(f"branches: {branches}")
|
_log(f"branches: {branches}")
|
||||||
if branches:
|
if branches:
|
||||||
if branches_file:
|
if branches_file:
|
||||||
print("Error: can't specify both --branches and --branches-file")
|
_log("Error: can't specify both --branches and --branches-file")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
branches_array = parse_branches(branches)
|
branches_array = parse_branches(branches)
|
||||||
|
|
||||||
if branches_array and verbose:
|
if branches_array and verbose:
|
||||||
print(f"Branches are: {branches_array}")
|
_log(f"Branches are: {branches_array}")
|
||||||
|
|
||||||
local_stack = ctx.obj.local_stack
|
local_stack = ctx.obj.local_stack
|
||||||
|
|
||||||
if local_stack:
|
if local_stack:
|
||||||
dev_root_path = os.getcwd()[0:os.getcwd().rindex("stack-orchestrator")]
|
dev_root_path = os.getcwd()[0:os.getcwd().rindex("stack-orchestrator")]
|
||||||
print(f"Local stack dev_root_path (CERC_REPO_BASE_DIR) overridden to: {dev_root_path}")
|
_log(f"Local stack dev_root_path (CERC_REPO_BASE_DIR) overridden to: {dev_root_path}")
|
||||||
else:
|
else:
|
||||||
dev_root_path = os.path.expanduser(config("CERC_REPO_BASE_DIR", default="~/cerc"))
|
dev_root_path = os.path.expanduser(config("CERC_REPO_BASE_DIR", default="~/cerc"))
|
||||||
|
|
||||||
if not quiet:
|
if not quiet:
|
||||||
print(f"Dev Root is: {dev_root_path}")
|
_log(f"Dev Root is: {dev_root_path}")
|
||||||
|
|
||||||
if not os.path.isdir(dev_root_path):
|
if not os.path.isdir(dev_root_path):
|
||||||
if not quiet:
|
if not quiet:
|
||||||
print('Dev root directory doesn\'t exist, creating')
|
_log('Dev root directory doesn\'t exist, creating')
|
||||||
os.makedirs(dev_root_path)
|
os.makedirs(dev_root_path)
|
||||||
|
|
||||||
# See: https://stackoverflow.com/a/20885799/1701505
|
# See: https://stackoverflow.com/a/20885799/1701505
|
||||||
from app import data
|
from . import data
|
||||||
with importlib.resources.open_text(data, "repository-list.txt") as repository_list_file:
|
with importlib.resources.open_text(data, "repository-list.txt") as repository_list_file:
|
||||||
all_repos = repository_list_file.read().splitlines()
|
all_repos = repository_list_file.read().splitlines()
|
||||||
|
|
||||||
@@ -244,9 +244,9 @@ def command(ctx, include, exclude, git_ssh, check_only, pull, branches, branches
|
|||||||
repos_in_scope = all_repos
|
repos_in_scope = all_repos
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print(f"Repos: {repos_in_scope}")
|
_log(f"Repos: {repos_in_scope}")
|
||||||
if stack:
|
if stack:
|
||||||
print(f"Stack: {stack}")
|
_log(f"Stack: {stack}")
|
||||||
|
|
||||||
repos = []
|
repos = []
|
||||||
for repo in repos_in_scope:
|
for repo in repos_in_scope:
|
||||||
@@ -254,11 +254,11 @@ def command(ctx, include, exclude, git_ssh, check_only, pull, branches, branches
|
|||||||
repos.append(repo)
|
repos.append(repo)
|
||||||
else:
|
else:
|
||||||
if verbose:
|
if verbose:
|
||||||
print(f"Excluding: {repo}")
|
_log(f"Excluding: {repo}")
|
||||||
|
|
||||||
for repo in repos:
|
for repo in repos:
|
||||||
try:
|
try:
|
||||||
process_repo(verbose, quiet, dry_run, pull, check_only, git_ssh, dev_root_path, branches_array, repo)
|
process_repo(verbose, quiet, dry_run, pull, check_only, git_ssh, dev_root_path, branches_array, repo)
|
||||||
except git.exc.GitCommandError as error:
|
except git.exc.GitCommandError as error:
|
||||||
print(f"\n******* git command returned error exit status:\n{error}")
|
_log(f"\n******* git command returned error exit status:\n{error}")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
# Copyright © 2023 Cerc
|
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Affero General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
|
||||||
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
from enum import Enum
|
|
||||||
|
|
||||||
class State(Enum):
|
|
||||||
CREATED = 1
|
|
||||||
CONFIGURED = 2
|
|
||||||
STARTED = 3
|
|
||||||
STOPPED = 4
|
|
||||||
+7
-11
@@ -15,10 +15,14 @@
|
|||||||
|
|
||||||
import os.path
|
import os.path
|
||||||
import sys
|
import sys
|
||||||
import ruamel.yaml
|
import yaml
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
def _log(*args):
|
||||||
|
print(*args, file=sys.stderr)
|
||||||
|
|
||||||
|
|
||||||
def include_exclude_check(s, include, exclude):
|
def include_exclude_check(s, include, exclude):
|
||||||
if include is None and exclude is None:
|
if include is None and exclude is None:
|
||||||
return True
|
return True
|
||||||
@@ -42,7 +46,7 @@ def get_parsed_stack_config(stack):
|
|||||||
stack_file_path = stack if isinstance(stack, os.PathLike) else get_stack_file_path(stack)
|
stack_file_path = stack if isinstance(stack, os.PathLike) else get_stack_file_path(stack)
|
||||||
try:
|
try:
|
||||||
with stack_file_path:
|
with stack_file_path:
|
||||||
stack_config = get_yaml().load(open(stack_file_path, "r"))
|
stack_config = yaml.safe_load(open(stack_file_path, "r"))
|
||||||
return stack_config
|
return stack_config
|
||||||
except FileNotFoundError as error:
|
except FileNotFoundError as error:
|
||||||
# We try here to generate a useful diagnostic error
|
# We try here to generate a useful diagnostic error
|
||||||
@@ -60,7 +64,7 @@ def get_parsed_deployment_spec(spec_file):
|
|||||||
spec_file_path = Path(spec_file)
|
spec_file_path = Path(spec_file)
|
||||||
try:
|
try:
|
||||||
with spec_file_path:
|
with spec_file_path:
|
||||||
deploy_spec = get_yaml().load(open(spec_file_path, "r"))
|
deploy_spec = yaml.safe_load(open(spec_file_path, "r"))
|
||||||
return deploy_spec
|
return deploy_spec
|
||||||
except FileNotFoundError as error:
|
except FileNotFoundError as error:
|
||||||
# We try here to generate a useful diagnostic error
|
# We try here to generate a useful diagnostic error
|
||||||
@@ -69,14 +73,6 @@ def get_parsed_deployment_spec(spec_file):
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def get_yaml():
|
|
||||||
# See: https://stackoverflow.com/a/45701840/1701505
|
|
||||||
yaml = ruamel.yaml.YAML()
|
|
||||||
yaml.preserve_quotes = True
|
|
||||||
yaml.indent(sequence=3, offset=1)
|
|
||||||
return yaml
|
|
||||||
|
|
||||||
|
|
||||||
# TODO: this is fragile wrt to the subcommand depth
|
# TODO: this is fragile wrt to the subcommand depth
|
||||||
# See also: https://github.com/pallets/click/issues/108
|
# See also: https://github.com/pallets/click/issues/108
|
||||||
def global_options(ctx):
|
def global_options(ctx):
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ def command(ctx):
|
|||||||
'''print tool version'''
|
'''print tool version'''
|
||||||
|
|
||||||
# See: https://stackoverflow.com/a/20885799/1701505
|
# See: https://stackoverflow.com/a/20885799/1701505
|
||||||
from app import data
|
from . import data
|
||||||
with importlib.resources.open_text(data, "build_tag.txt") as version_file:
|
with importlib.resources.open_text(data, "build_tag.txt") as version_file:
|
||||||
# TODO: code better version that skips comment lines
|
# TODO: code better version that skips comment lines
|
||||||
version_string = version_file.read().splitlines()[1]
|
version_string = version_file.read().splitlines()[1]
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -e
|
|
||||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
|
||||||
set -x
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Running stack-orchestrator Ethereum mainnet test"
|
|
||||||
# Bit of a hack, test the most recent package
|
|
||||||
TEST_TARGET_SO=$( ls -t1 ./package/laconic-so* | head -1 )
|
|
||||||
# Set a new unique repo dir
|
|
||||||
export CERC_REPO_BASE_DIR=$(mktemp -d stack-orchestrator-mainnet-eth-test.XXXXXXXXXX)
|
|
||||||
DEPLOYMENT_DIR=mainnet-eth-deployment-test
|
|
||||||
echo "Testing this package: $TEST_TARGET_SO"
|
|
||||||
echo "Test version command"
|
|
||||||
reported_version_string=$( $TEST_TARGET_SO version )
|
|
||||||
echo "Version reported is: ${reported_version_string}"
|
|
||||||
echo "Cloning repositories into: $CERC_REPO_BASE_DIR"
|
|
||||||
$TEST_TARGET_SO --stack mainnet-eth setup-repositories
|
|
||||||
$TEST_TARGET_SO --stack mainnet-eth build-containers
|
|
||||||
$TEST_TARGET_SO --stack mainnet-eth deploy init --output mainnet-eth-spec.yml
|
|
||||||
$TEST_TARGET_SO deploy create --spec-file mainnet-eth-spec.yml --deployment-dir $DEPLOYMENT_DIR
|
|
||||||
# Start the stack
|
|
||||||
$TEST_TARGET_SO deployment --dir $DEPLOYMENT_DIR start
|
|
||||||
# Verify that the stack is up and running
|
|
||||||
$TEST_TARGET_SO deployment --dir $DEPLOYMENT_DIR ps
|
|
||||||
#TODO: add a check that the container logs show good startup
|
|
||||||
$TEST_TARGET_SO deployment --dir $DEPLOYMENT_DIR stop --delete-volumes
|
|
||||||
echo "Removing deployment directory"
|
|
||||||
rm -rf $DEPLOYMENT_DIR
|
|
||||||
echo "Removing cloned repositories"
|
|
||||||
rm -rf $CERC_REPO_BASE_DIR
|
|
||||||
exit $test_result
|
|
||||||
Reference in New Issue
Block a user