forked from cerc-io/stack-orchestrator
Wire up to build-npms
This commit is contained in:
parent
f1cbce1d00
commit
7e6268c39d
@ -42,7 +42,7 @@ class base_stack(ABC):
|
|||||||
|
|
||||||
class package_registry_stack(base_stack):
|
class package_registry_stack(base_stack):
|
||||||
|
|
||||||
def ensure_available(self, ctx):
|
def ensure_available(self):
|
||||||
self.url = "<no registry url set>"
|
self.url = "<no registry url set>"
|
||||||
# Check if we were given an external registry URL
|
# Check if we were given an external registry URL
|
||||||
url_from_environment = os.environ.get("CERC_NPM_REGISTRY_URL")
|
url_from_environment = os.environ.get("CERC_NPM_REGISTRY_URL")
|
||||||
@ -53,7 +53,7 @@ class package_registry_stack(base_stack):
|
|||||||
else:
|
else:
|
||||||
# Otherwise we expect to use the local package-registry stack
|
# Otherwise we expect to use the local package-registry stack
|
||||||
# First check if the stack is up
|
# First check if the stack is up
|
||||||
registry_running = get_stack_status("package-registry")
|
registry_running = get_stack_status(self.config, "package-registry")
|
||||||
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:
|
||||||
@ -61,6 +61,8 @@ class package_registry_stack(base_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")
|
||||||
|
print("ERROR: Start the local package registry with: laconic-so --stack package-registry deploy-system up")
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -44,9 +44,16 @@ def command(ctx, include, exclude):
|
|||||||
|
|
||||||
# build-npms depends on having access to a writable package registry
|
# build-npms depends on having access to a writable package registry
|
||||||
# so we check here that it is available
|
# so we check here that it is available
|
||||||
package_registry_stack = get_stack(ctx.obj, 'package-registry')
|
package_registry_stack = get_stack(ctx.obj, "package-registry")
|
||||||
package_registry_stack.ensure_available()
|
registry_available = package_registry_stack.ensure_available()
|
||||||
npm_registry_url = package_registry_stack.get_url('package-registry')
|
if not registry_available:
|
||||||
|
print("FATAL: no npm registry available for build-npms command")
|
||||||
|
sys.exit(1)
|
||||||
|
npm_registry_url = package_registry_stack.get_url()
|
||||||
|
npm_registry_url_token = config("CERC_NPM_AUTH_TOKEN", default=None)
|
||||||
|
if not npm_registry_url_token:
|
||||||
|
print("FATAL: CERC_NPM_AUTH_TOKEN is not defined")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
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")]
|
||||||
@ -86,7 +93,7 @@ def command(ctx, include, exclude):
|
|||||||
if not dry_run:
|
if not dry_run:
|
||||||
if verbose:
|
if verbose:
|
||||||
print(f"Executing: {build_command}")
|
print(f"Executing: {build_command}")
|
||||||
envs = {"CERC_NPM_AUTH_TOKEN": os.environ["CERC_NPM_AUTH_TOKEN"]} | ({"CERC_SCRIPT_DEBUG": "true"} if debug else {})
|
envs = {"CERC_NPM_AUTH_TOKEN": npm_registry_url_token} | ({"CERC_SCRIPT_DEBUG": "true"} if debug else {})
|
||||||
try:
|
try:
|
||||||
docker.run("cerc/builder-js",
|
docker.run("cerc/builder-js",
|
||||||
remove=True,
|
remove=True,
|
||||||
|
@ -61,10 +61,10 @@ def command(ctx, include, exclude, cluster, command, extra_args):
|
|||||||
if verbose:
|
if verbose:
|
||||||
print(f"Running compose up for extra_args: {extra_args_list}")
|
print(f"Running compose up for extra_args: {extra_args_list}")
|
||||||
for pre_start_command in cluster_context.pre_start_commands:
|
for pre_start_command in cluster_context.pre_start_commands:
|
||||||
_run_command(ctx.obj, cluster, pre_start_command)
|
_run_command(ctx.obj, cluster_context.cluster, pre_start_command)
|
||||||
docker.compose.up(detach=True, services=extra_args_list)
|
docker.compose.up(detach=True, services=extra_args_list)
|
||||||
for post_start_command in cluster_context.post_start_commands:
|
for post_start_command in cluster_context.post_start_commands:
|
||||||
_run_command(ctx.obj, cluster, post_start_command)
|
_run_command(ctx.obj, cluster_context.cluster, post_start_command)
|
||||||
elif command == "down":
|
elif command == "down":
|
||||||
if verbose:
|
if verbose:
|
||||||
print("Running compose down")
|
print("Running compose down")
|
||||||
@ -123,7 +123,7 @@ def get_stack_status(ctx, stack):
|
|||||||
ctx_copy = copy.copy(ctx)
|
ctx_copy = copy.copy(ctx)
|
||||||
ctx_copy.stack = stack
|
ctx_copy.stack = stack
|
||||||
|
|
||||||
cluster_context = _make_cluster_context(ctx_copy, [], [], None)
|
cluster_context = _make_cluster_context(ctx_copy, None, None, None)
|
||||||
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:
|
||||||
|
Loading…
Reference in New Issue
Block a user