diff --git a/app/data/compose/docker-compose-mainnet-laconicd.yml b/app/data/compose/docker-compose-mainnet-laconicd.yml index 5037687c..9de3cbb4 100644 --- a/app/data/compose/docker-compose-mainnet-laconicd.yml +++ b/app/data/compose/docker-compose-mainnet-laconicd.yml @@ -1,15 +1,15 @@ services: laconicd: - restart: unless-stopped + restart: no image: cerc/laconicd:local command: ["sh", "/docker-entrypoint-scripts.d/create-fixturenet.sh"] volumes: # The cosmos-sdk node's database directory: - laconicd-data:/root/.laconicd/data # TODO: look at folding these scripts into the container - - ../config/fixturenet-laconicd/create-fixturenet.sh:/docker-entrypoint-scripts.d/create-fixturenet.sh - - ../config/fixturenet-laconicd/export-mykey.sh:/docker-entrypoint-scripts.d/export-mykey.sh - - ../config/fixturenet-laconicd/export-myaddress.sh:/docker-entrypoint-scripts.d/export-myaddress.sh + - ./config/mainnet-laconicd/create-fixturenet.sh:/docker-entrypoint-scripts.d/create-fixturenet.sh + - ./config/mainnet-laconicd/export-mykey.sh:/docker-entrypoint-scripts.d/export-mykey.sh + - ./config/mainnet-laconicd/export-myaddress.sh:/docker-entrypoint-scripts.d/export-myaddress.sh # TODO: determine which of the ports below is really needed ports: - "6060" @@ -24,7 +24,7 @@ services: cli: image: cerc/laconic-registry-cli:local volumes: - - ../config/fixturenet-laconicd/registry-cli-config-template.yml:/registry-cli-config-template.yml + - ./config/mainnet-laconicd/registry-cli-config-template.yml:/registry-cli-config-template.yml volumes: laconicd-data: diff --git a/app/deployment_create.py b/app/deployment_create.py index 58b5f983..3d66b6e9 100644 --- a/app/deployment_create.py +++ b/app/deployment_create.py @@ -16,9 +16,9 @@ import click import os from pathlib import Path -from shutil import copyfile +from shutil import copyfile, copytree import sys -from .util import get_stack_config_path, get_parsed_deployment_spec, get_parsed_stack_config, global_options +from .util import get_stack_file_path, get_parsed_deployment_spec, get_parsed_stack_config, global_options default_spec_file_content = """stack: mainnet-laconic data_dir: /my/path @@ -44,8 +44,9 @@ def init(ctx, output): 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) - stack_file = get_stack_config_path(parsed_spec['stack']) - parsed_stack = get_parsed_stack_config(stack_file) + stack_name = parsed_spec['stack'] + stack_file = get_stack_file_path(stack_name) + parsed_stack = get_parsed_stack_config(stack_name) if global_options(ctx).debug: print(f"parsed spec: {parsed_spec}") if deployment_dir is None: @@ -60,8 +61,13 @@ def create(ctx, spec_file, deployment_dir): # Copy the pod files into the deployment dir pods = parsed_stack['pods'] # TODO: refactor to use common code with deploy command - # See: https://stackoverflow.com/questions/25389095/python-get-path-of-root-project-structure - compose_dir = Path(__file__).absolute().parent.joinpath("data", "compose") + # See: https://stackoverflow.com/questions/25389095/python-get-path-of-root-project-structure + data_dir = Path(__file__).absolute().parent.joinpath("data") + compose_dir = data_dir.joinpath("compose") for pod in pods: pod_file_path = os.path.join(compose_dir, f"docker-compose-{pod}.yml") copyfile(pod_file_path, os.path.join(deployment_dir, os.path.basename(pod_file_path))) + # Copy the config files for the pod, if any + source_config_dir = data_dir.joinpath("config", pod) + if os.path.exists(source_config_dir): + copytree(source_config_dir, os.path.join(deployment_dir, "config", pod)) diff --git a/app/util.py b/app/util.py index 6a1c16dc..69eda4af 100644 --- a/app/util.py +++ b/app/util.py @@ -30,7 +30,7 @@ def include_exclude_check(s, include, exclude): return s not in exclude_list -def get_stack_config_path(stack): +def get_stack_file_path(stack): # In order to be compatible with Python 3.8 we need to use this hack to get the path: # See: https://stackoverflow.com/questions/25389095/python-get-path-of-root-project-structure stack_file_path = Path(__file__).absolute().parent.joinpath("data", "stacks", stack, "stack.yml") @@ -39,7 +39,7 @@ def get_stack_config_path(stack): # Caller can pass either the name of a stack, or a path to a stack file def get_parsed_stack_config(stack): - stack_file_path = stack if isinstance(stack, os.PathLike) else get_stack_config_path(stack) + stack_file_path = stack if isinstance(stack, os.PathLike) else get_stack_file_path(stack) try: with stack_file_path: stack_config = yaml.safe_load(open(stack_file_path, "r"))