diff --git a/app/build_containers.py b/app/build_containers.py index 52ba3103..7ecf4a82 100644 --- a/app/build_containers.py +++ b/app/build_containers.py @@ -103,7 +103,7 @@ def command(ctx, include, exclude): # Check if we have a repo for this container. If not, set the context dir to the container-build subdir repo_full_path = os.path.join(dev_root_path, repo_dir) repo_dir_or_build_dir = repo_dir if os.path.exists(repo_full_path) else build_dir - build_command = os.path.join(container_build_dir, "default-build.sh") + f" {container} {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 verbose: print(f"Executing: {build_command}") diff --git a/app/build_npms.py b/app/build_npms.py index 101fde3e..4503de65 100644 --- a/app/build_npms.py +++ b/app/build_npms.py @@ -27,6 +27,8 @@ from python_on_whales import docker, DockerException from .base import get_stack from .util import include_exclude_check, get_parsed_stack_config +builder_js_image_name = "cerc/builder-js:local" + @click.command() @click.option('--include', help="only build these packages") @click.option('--exclude', help="don\'t build these packages") @@ -42,6 +44,8 @@ def command(ctx, include, exclude): stack = ctx.obj.stack continue_on_error = ctx.obj.continue_on_error + _ensure_prerequisites() + # build-npms depends on having access to a writable package registry # so we check here that it is available package_registry_stack = get_stack(ctx.obj, "package-registry") @@ -95,7 +99,7 @@ def command(ctx, include, exclude): print(f"Executing: {build_command}") envs = {"CERC_NPM_AUTH_TOKEN": npm_registry_url_token} | ({"CERC_SCRIPT_DEBUG": "true"} if debug else {}) try: - docker.run("cerc/builder-js", + docker.run(builder_js_image_name, remove=True, interactive=True, tty=True, @@ -126,3 +130,13 @@ def command(ctx, include, exclude): else: if verbose: print(f"Excluding: {package}") + + +def _ensure_prerequisites(): + # Check that the builder-js container is available and + # Tell the user how to build it if not + images = docker.image.list(builder_js_image_name) + if len(images) == 0: + print(f"FATAL: builder image: {builder_js_image_name} is required but was not found") + print("Please run this command to create it: laconic-so --stack build-support build-containers") + sys.exit(1) diff --git a/app/data/container-build/default-build.sh b/app/data/container-build/default-build.sh index b369e2c9..3d5d9919 100755 --- a/app/data/container-build/default-build.sh +++ b/app/data/container-build/default-build.sh @@ -1,6 +1,9 @@ #!/usr/bin/env bash # Usage: default-build.sh [] # if is not supplied, the context is the directory where the Dockerfile lives +if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then + set -x +fi if [[ $# -ne 2 ]]; then echo "Illegal number of parameters" >&2 exit 1