Add config files to deployment

This commit is contained in:
David Boreham 2023-06-22 19:35:27 -06:00
parent 6e23398484
commit b355566596
3 changed files with 19 additions and 13 deletions

View File

@ -1,15 +1,15 @@
services: services:
laconicd: laconicd:
restart: unless-stopped restart: no
image: cerc/laconicd:local image: cerc/laconicd:local
command: ["sh", "/docker-entrypoint-scripts.d/create-fixturenet.sh"] 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
# TODO: look at folding these scripts into the container # TODO: look at folding these scripts into the container
- ../config/fixturenet-laconicd/create-fixturenet.sh:/docker-entrypoint-scripts.d/create-fixturenet.sh - ./config/mainnet-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/mainnet-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/export-myaddress.sh:/docker-entrypoint-scripts.d/export-myaddress.sh
# TODO: determine which of the ports below is really needed # TODO: determine which of the ports below is really needed
ports: ports:
- "6060" - "6060"
@ -24,7 +24,7 @@ services:
cli: cli:
image: cerc/laconic-registry-cli:local image: cerc/laconic-registry-cli:local
volumes: 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: volumes:
laconicd-data: laconicd-data:

View File

@ -16,9 +16,9 @@
import click import click
import os import os
from pathlib import Path from pathlib import Path
from shutil import copyfile from shutil import copyfile, copytree
import sys 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 default_spec_file_content = """stack: mainnet-laconic
data_dir: /my/path data_dir: /my/path
@ -44,8 +44,9 @@ def init(ctx, output):
def create(ctx, spec_file, deployment_dir): def create(ctx, spec_file, deployment_dir):
# This function fails with a useful error message if the file doens't exist # This function fails with a useful error message if the file doens't exist
parsed_spec = get_parsed_deployment_spec(spec_file) parsed_spec = get_parsed_deployment_spec(spec_file)
stack_file = get_stack_config_path(parsed_spec['stack']) stack_name = parsed_spec['stack']
parsed_stack = get_parsed_stack_config(stack_file) stack_file = get_stack_file_path(stack_name)
parsed_stack = get_parsed_stack_config(stack_name)
if global_options(ctx).debug: if global_options(ctx).debug:
print(f"parsed spec: {parsed_spec}") print(f"parsed spec: {parsed_spec}")
if deployment_dir is None: if deployment_dir is None:
@ -61,7 +62,12 @@ def create(ctx, spec_file, deployment_dir):
pods = parsed_stack['pods'] pods = parsed_stack['pods']
# TODO: refactor to use common code with deploy command # TODO: refactor to use common code with deploy command
# See: https://stackoverflow.com/questions/25389095/python-get-path-of-root-project-structure # See: https://stackoverflow.com/questions/25389095/python-get-path-of-root-project-structure
compose_dir = Path(__file__).absolute().parent.joinpath("data", "compose") data_dir = Path(__file__).absolute().parent.joinpath("data")
compose_dir = data_dir.joinpath("compose")
for pod in pods: for pod in pods:
pod_file_path = os.path.join(compose_dir, f"docker-compose-{pod}.yml") 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))) 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))

View File

@ -30,7 +30,7 @@ def include_exclude_check(s, include, exclude):
return s not in exclude_list 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: # 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 # 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") 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 # Caller can pass either the name of a stack, or a path to a stack file
def get_parsed_stack_config(stack): 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: try:
with stack_file_path: with stack_file_path:
stack_config = yaml.safe_load(open(stack_file_path, "r")) stack_config = yaml.safe_load(open(stack_file_path, "r"))