forked from cerc-io/stack-orchestrator
Check for builder container in npm build
This commit is contained in:
parent
9f07a0ed4b
commit
156758bfa7
@ -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
|
# 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_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
|
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 not dry_run:
|
||||||
if verbose:
|
if verbose:
|
||||||
print(f"Executing: {build_command}")
|
print(f"Executing: {build_command}")
|
||||||
|
@ -27,6 +27,8 @@ from python_on_whales import docker, DockerException
|
|||||||
from .base import get_stack
|
from .base import get_stack
|
||||||
from .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"
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
@click.option('--include', help="only build these packages")
|
@click.option('--include', help="only build these packages")
|
||||||
@click.option('--exclude', help="don\'t 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
|
stack = ctx.obj.stack
|
||||||
continue_on_error = ctx.obj.continue_on_error
|
continue_on_error = ctx.obj.continue_on_error
|
||||||
|
|
||||||
|
_ensure_prerequisites()
|
||||||
|
|
||||||
# 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")
|
||||||
@ -95,7 +99,7 @@ def command(ctx, include, exclude):
|
|||||||
print(f"Executing: {build_command}")
|
print(f"Executing: {build_command}")
|
||||||
envs = {"CERC_NPM_AUTH_TOKEN": npm_registry_url_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(builder_js_image_name,
|
||||||
remove=True,
|
remove=True,
|
||||||
interactive=True,
|
interactive=True,
|
||||||
tty=True,
|
tty=True,
|
||||||
@ -126,3 +130,13 @@ def command(ctx, include, exclude):
|
|||||||
else:
|
else:
|
||||||
if verbose:
|
if verbose:
|
||||||
print(f"Excluding: {package}")
|
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)
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Usage: default-build.sh <image-tag> [<repo-relative-path>]
|
# Usage: default-build.sh <image-tag> [<repo-relative-path>]
|
||||||
# if <repo-relative-path> is not supplied, the context is the directory where the Dockerfile lives
|
# if <repo-relative-path> 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
|
if [[ $# -ne 2 ]]; then
|
||||||
echo "Illegal number of parameters" >&2
|
echo "Illegal number of parameters" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
Loading…
Reference in New Issue
Block a user