Initial commit
This commit is contained in:
parent
7c6c46febb
commit
7deb49825d
@ -36,13 +36,16 @@ from .util import include_exclude_check, get_parsed_stack_config
|
|||||||
@click.command()
|
@click.command()
|
||||||
@click.option('--include', help="only build these containers")
|
@click.option('--include', help="only build these containers")
|
||||||
@click.option('--exclude', help="don\'t build these containers")
|
@click.option('--exclude', help="don\'t build these containers")
|
||||||
|
@click.option("--force-rebuild", is_flag=True, default=False, help="Override dependency checking -- always rebuild")
|
||||||
|
@click.option("--extra-build-args", help="Supply extra arguments to build")
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def command(ctx, include, exclude):
|
def command(ctx, include, exclude, force_rebuild, extra_build_args):
|
||||||
'''build the set of containers required for a complete stack'''
|
'''build the set of containers required for a complete stack'''
|
||||||
|
|
||||||
quiet = ctx.obj.quiet
|
quiet = ctx.obj.quiet
|
||||||
verbose = ctx.obj.verbose
|
verbose = ctx.obj.verbose
|
||||||
dry_run = ctx.obj.dry_run
|
dry_run = ctx.obj.dry_run
|
||||||
|
debug = ctx.obj.debug
|
||||||
local_stack = ctx.obj.local_stack
|
local_stack = ctx.obj.local_stack
|
||||||
stack = ctx.obj.stack
|
stack = ctx.obj.stack
|
||||||
continue_on_error = ctx.obj.continue_on_error
|
continue_on_error = ctx.obj.continue_on_error
|
||||||
@ -88,6 +91,9 @@ def command(ctx, include, exclude):
|
|||||||
"CERC_HOST_GID": f"{os.getgid()}",
|
"CERC_HOST_GID": f"{os.getgid()}",
|
||||||
"DOCKER_BUILDKIT": "0"
|
"DOCKER_BUILDKIT": "0"
|
||||||
}
|
}
|
||||||
|
container_build_env.update({"CERC_SCRIPT_DEBUG": "true"} if debug else {})
|
||||||
|
container_build_env.update({"CERC_FORCE_REBUILD": "true"} if force_rebuild else {})
|
||||||
|
container_build_env.update({"CERC_CONTAINER_EXTRA_BUILD_ARGS": extra_build_args} if extra_build_args else {})
|
||||||
|
|
||||||
def process_container(container):
|
def process_container(container):
|
||||||
if not quiet:
|
if not quiet:
|
||||||
|
13
app/data/container-build/build-base.sh
Executable file
13
app/data/container-build/build-base.sh
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
# source'ed into container build scripts to do generic command setup
|
||||||
|
if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then
|
||||||
|
set -x
|
||||||
|
echo "Build environment variables:"
|
||||||
|
env
|
||||||
|
fi
|
||||||
|
build_command_args=""
|
||||||
|
if [[ ${CERC_FORCE_REBUILD} == "true" ]]; then
|
||||||
|
build_command_args="${build_command_args} --pull --no-cache"
|
||||||
|
fi
|
||||||
|
if [[ -n "$CERC_CONTAINER_EXTRA_BUILD_ARGS" ]]; then
|
||||||
|
build_command_args="${build_command_args} ${CERC_CONTAINER_EXTRA_BUILD_ARGS}"
|
||||||
|
fi
|
@ -1,14 +1,15 @@
|
|||||||
#!/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
|
# See: https://stackoverflow.com/a/246128/1701505
|
||||||
fi
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
|
source ${SCRIPT_DIR}/build-base.sh
|
||||||
|
|
||||||
if [[ $# -ne 2 ]]; then
|
if [[ $# -ne 2 ]]; then
|
||||||
echo "Illegal number of parameters" >&2
|
echo "Illegal number of parameters" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
image_tag=$1
|
image_tag=$1
|
||||||
build_dir=$2
|
build_dir=$2
|
||||||
echo "Building ${image_tag} in ${build_dir}"
|
docker build -t ${image_tag} ${build_command_args} --build-arg CERC_HOST_UID=${CERC_HOST_UID} --build-arg CERC_HOST_GID=${CERC_HOST_GID} ${build_dir}
|
||||||
docker build -t ${image_tag} --build-arg CERC_HOST_UID=${CERC_HOST_UID} --build-arg CERC_HOST_GID=${CERC_HOST_GID} ${build_dir}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user