From 332085f80bc5c20516ef8739abf1c31bbdc86e6d Mon Sep 17 00:00:00 2001 From: David Boreham Date: Fri, 14 Apr 2023 14:19:27 -0600 Subject: [PATCH] Add force rebuild option (#329) Former-commit-id: 1443c6c6d20f3e9f95432e87ea61109c6b0f1beb --- app/build_containers.py | 9 +++- app/build_npms.py | 6 ++- app/data/container-build/build-base.sh | 13 ++++++ .../cerc-act-runner-task-executor/build.sh | 3 +- .../container-build/cerc-act-runner/build.sh | 4 +- .../cerc-builder-js/build-npm-package.sh | 15 +++++-- .../container-build/cerc-eth-probe/build.sh | 3 +- .../cerc-eth-statediff-fill-service/build.sh | 3 +- .../cerc-eth-statediff-service/build.sh | 3 +- .../cerc-fixturenet-eth-geth/build.sh | 4 +- .../cerc-fixturenet-eth-lighthouse/build.sh | 4 +- .../container-build/cerc-foundry/build.sh | 3 +- .../cerc-go-ethereum-foundry/build.sh | 4 +- .../container-build/cerc-go-ethereum/build.sh | 3 +- .../cerc-ipld-eth-beacon-db/build.sh | 3 +- .../cerc-ipld-eth-beacon-indexer/build.sh | 3 +- .../container-build/cerc-ipld-eth-db/build.sh | 3 +- .../cerc-ipld-eth-server/build.sh | 3 +- .../container-build/cerc-keycloak/build.sh | 4 +- .../cerc-laconic-console-host/build.sh | 4 +- .../cerc-laconic-registry-cli/build.sh | 4 +- .../container-build/cerc-laconicd/build.sh | 5 ++- .../container-build/cerc-lighthouse/build.sh | 4 +- .../container-build/cerc-mobymask-ui/build.sh | 4 +- .../container-build/cerc-mobymask/build.sh | 4 +- .../cerc-optimism-contracts/build.sh | 4 +- .../cerc-optimism-l2geth/build.sh | 3 +- .../cerc-optimism-op-batcher/build.sh | 3 +- .../cerc-optimism-op-node/build.sh | 3 +- .../container-build/cerc-react-peer/build.sh | 4 +- .../cerc-test-container/build.sh | 3 +- .../cerc-test-contract/build.sh | 3 +- .../container-build/cerc-tx-spammer/build.sh | 3 +- .../cerc-uniswap-v3-info/build.sh | 4 +- .../cerc-watcher-erc20/build.sh | 4 +- .../cerc-watcher-erc721/build.sh | 4 +- .../cerc-watcher-mobymask-v2/build.sh | 4 +- .../cerc-watcher-mobymask/build.sh | 4 +- .../cerc-watcher-uniswap-v3/build.sh | 4 +- app/data/container-build/default-build.sh | 9 ++-- docs/cli.md | 45 +++++++++++++++++++ 41 files changed, 176 insertions(+), 46 deletions(-) create mode 100755 app/data/container-build/build-base.sh diff --git a/app/build_containers.py b/app/build_containers.py index 5b85f5bf..3a47a6da 100644 --- a/app/build_containers.py +++ b/app/build_containers.py @@ -36,13 +36,16 @@ from .util import include_exclude_check, get_parsed_stack_config @click.command() @click.option('--include', help="only 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 -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''' quiet = ctx.obj.quiet verbose = ctx.obj.verbose dry_run = ctx.obj.dry_run + debug = ctx.obj.debug local_stack = ctx.obj.local_stack stack = ctx.obj.stack continue_on_error = ctx.obj.continue_on_error @@ -84,10 +87,14 @@ def command(ctx, include, exclude): "CERC_NPM_URL": "http://gitea.local:3000/api/packages/cerc-io/npm/", "CERC_NPM_AUTH_TOKEN": config("CERC_NPM_AUTH_TOKEN", default=""), "CERC_REPO_BASE_DIR": dev_root_path, + "CERC_CONTAINER_BASE_DIR": container_build_dir, "CERC_HOST_UID": f"{os.getuid()}", "CERC_HOST_GID": f"{os.getgid()}", "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): if not quiet: diff --git a/app/build_npms.py b/app/build_npms.py index 3750c4bd..d56b2774 100644 --- a/app/build_npms.py +++ b/app/build_npms.py @@ -33,8 +33,10 @@ 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") +@click.option("--force-rebuild", is_flag=True, default=False, help="Override existing target package version check -- force rebuild") +@click.option("--extra-build-args", help="Supply extra arguments to build") @click.pass_context -def command(ctx, include, exclude): +def command(ctx, include, exclude, force_rebuild, extra_build_args): '''build the set of npm packages required for a complete stack''' quiet = ctx.obj.quiet @@ -123,6 +125,8 @@ def command(ctx, include, exclude): "LACONIC_HOSTED_CONFIG_FILE": "config-hosted.yml" # Convention used by our web app packages } envs.update({"CERC_SCRIPT_DEBUG": "true"} if debug else {}) + envs.update({"CERC_FORCE_REBUILD": "true"} if force_rebuild else {}) + envs.update({"CERC_CONTAINER_EXTRA_BUILD_ARGS": extra_build_args} if extra_build_args else {}) try: docker.run(builder_js_image_name, remove=True, diff --git a/app/data/container-build/build-base.sh b/app/data/container-build/build-base.sh new file mode 100755 index 00000000..61705b79 --- /dev/null +++ b/app/data/container-build/build-base.sh @@ -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} --no-cache" +fi +if [[ -n "$CERC_CONTAINER_EXTRA_BUILD_ARGS" ]]; then + build_command_args="${build_command_args} ${CERC_CONTAINER_EXTRA_BUILD_ARGS}" +fi diff --git a/app/data/container-build/cerc-act-runner-task-executor/build.sh b/app/data/container-build/cerc-act-runner-task-executor/build.sh index 2bfb3bf9..53bfd23b 100755 --- a/app/data/container-build/cerc-act-runner-task-executor/build.sh +++ b/app/data/container-build/cerc-act-runner-task-executor/build.sh @@ -1,3 +1,4 @@ #!/usr/bin/env bash # Build a local version of the task executor for act-runner -docker build -t cerc/act-runner-task-executor:local -f ${CERC_REPO_BASE_DIR}/hosting/gitea/Dockerfile.task-executor ${CERC_REPO_BASE_DIR}/hosting +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh +docker build -t cerc/act-runner-task-executor:local -f ${CERC_REPO_BASE_DIR}/hosting/gitea/Dockerfile.task-executor ${build_command_args} ${CERC_REPO_BASE_DIR}/hosting diff --git a/app/data/container-build/cerc-act-runner/build.sh b/app/data/container-build/cerc-act-runner/build.sh index 2fdb3f2e..89a6e74f 100755 --- a/app/data/container-build/cerc-act-runner/build.sh +++ b/app/data/container-build/cerc-act-runner/build.sh @@ -1,3 +1,5 @@ #!/usr/bin/env bash +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh # Build a local version of the act-runner image -docker build -t cerc/act-runner:local -f ${CERC_REPO_BASE_DIR}/act_runner/Dockerfile ${CERC_REPO_BASE_DIR}/act_runner +# TODO: enhance the default build code path to cope with this container (repo has an _ which needs to be converted to - in the image tag) +docker build -t cerc/act-runner:local -f ${CERC_REPO_BASE_DIR}/act_runner/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/act_runner diff --git a/app/data/container-build/cerc-builder-js/build-npm-package.sh b/app/data/container-build/cerc-builder-js/build-npm-package.sh index 668e0bec..db27955c 100755 --- a/app/data/container-build/cerc-builder-js/build-npm-package.sh +++ b/app/data/container-build/cerc-builder-js/build-npm-package.sh @@ -25,12 +25,21 @@ local_npm_registry_url=$1 npm config set @cerc-io:registry ${local_npm_registry_url} npm config set @lirewine:registry ${local_npm_registry_url} npm config set @muknsys:registry ${local_npm_registry_url} -npm config set -- ${local_npm_registry_url}:_authToken ${CERC_NPM_AUTH_TOKEN} +# Workaround bug in npm unpublish where it needs the url to be of the form // and not http:// +local_npm_registry_url_fixed=$( echo ${local_npm_registry_url} | sed -e 's/^http[s]\{0,1\}://') +npm config set -- ${local_npm_registry_url_fixed}:_authToken ${CERC_NPM_AUTH_TOKEN} # First check if the version of this package we're trying to build already exists in the registry package_exists=$( yarn info --json ${package_name}@${package_publish_version} 2>/dev/null | jq -r .data.dist.tarball ) if [[ ! -z "$package_exists" && "$package_exists" != "null" ]]; then - echo "${package_publish_version} of ${package_name} already exists in the registry, skipping build" - exit 0 + echo "${package_publish_version} of ${package_name} already exists in the registry" + if [[ ${CERC_FORCE_REBUILD} == "true" ]]; then + # Attempt to unpublish the existing package + echo "NOTE: unpublishing existing package version since force rebuild is enabled" + npm unpublish --force ${package_name}@${package_publish_version} + else + echo "skipping build since target version already exists" + exit 0 + fi fi echo "Build and publish ${package_name} version ${package_publish_version}" yarn install diff --git a/app/data/container-build/cerc-eth-probe/build.sh b/app/data/container-build/cerc-eth-probe/build.sh index 4f211307..c90e0627 100755 --- a/app/data/container-build/cerc-eth-probe/build.sh +++ b/app/data/container-build/cerc-eth-probe/build.sh @@ -1,3 +1,4 @@ #!/usr/bin/env bash # Build cerc/eth-probe -docker build -t cerc/eth-probe:local ${CERC_REPO_BASE_DIR}/eth-probe +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh +docker build -t cerc/eth-probe:local ${build_command_args} ${CERC_REPO_BASE_DIR}/eth-probe diff --git a/app/data/container-build/cerc-eth-statediff-fill-service/build.sh b/app/data/container-build/cerc-eth-statediff-fill-service/build.sh index 2a73352f..03896052 100755 --- a/app/data/container-build/cerc-eth-statediff-fill-service/build.sh +++ b/app/data/container-build/cerc-eth-statediff-fill-service/build.sh @@ -1,3 +1,4 @@ #!/usr/bin/env bash # Build cerc/eth-statediff-fill-service -docker build -t cerc/eth-statediff-fill-service:local ${CERC_REPO_BASE_DIR}/eth-statediff-fill-service +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh +docker build -t cerc/eth-statediff-fill-service:local ${build_command_args} ${CERC_REPO_BASE_DIR}/eth-statediff-fill-service diff --git a/app/data/container-build/cerc-eth-statediff-service/build.sh b/app/data/container-build/cerc-eth-statediff-service/build.sh index 6091e8ec..07c2d2ef 100755 --- a/app/data/container-build/cerc-eth-statediff-service/build.sh +++ b/app/data/container-build/cerc-eth-statediff-service/build.sh @@ -1,3 +1,4 @@ #!/usr/bin/env bash # Build cerc/eth-statediff-service -docker build -t cerc/eth-statediff-service:local ${CERC_REPO_BASE_DIR}/eth-statediff-service +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh +docker build -t cerc/eth-statediff-service:local ${build_command_args} ${CERC_REPO_BASE_DIR}/eth-statediff-service diff --git a/app/data/container-build/cerc-fixturenet-eth-geth/build.sh b/app/data/container-build/cerc-fixturenet-eth-geth/build.sh index b06044c7..a00a3f17 100755 --- a/app/data/container-build/cerc-fixturenet-eth-geth/build.sh +++ b/app/data/container-build/cerc-fixturenet-eth-geth/build.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash # Build cerc/fixturenet-eth-geth +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh + SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -docker build -t cerc/fixturenet-eth-geth:local -f ${SCRIPT_DIR}/Dockerfile $SCRIPT_DIR +docker build -t cerc/fixturenet-eth-geth:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} $SCRIPT_DIR diff --git a/app/data/container-build/cerc-fixturenet-eth-lighthouse/build.sh b/app/data/container-build/cerc-fixturenet-eth-lighthouse/build.sh index bc48fde0..e7e06039 100755 --- a/app/data/container-build/cerc-fixturenet-eth-lighthouse/build.sh +++ b/app/data/container-build/cerc-fixturenet-eth-lighthouse/build.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash # Build cerc/fixturenet-eth-lighthouse +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh + SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -docker build -t cerc/fixturenet-eth-lighthouse:local -f ${SCRIPT_DIR}/Dockerfile $SCRIPT_DIR +docker build -t cerc/fixturenet-eth-lighthouse:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} $SCRIPT_DIR diff --git a/app/data/container-build/cerc-foundry/build.sh b/app/data/container-build/cerc-foundry/build.sh index c765f03d..f80276eb 100755 --- a/app/data/container-build/cerc-foundry/build.sh +++ b/app/data/container-build/cerc-foundry/build.sh @@ -1,3 +1,4 @@ #!/usr/bin/env bash # Build a local version of the foundry-rs/foundry image -docker build -t cerc/foundry:local -f ${CERC_REPO_BASE_DIR}/foundry/Dockerfile-debian ${CERC_REPO_BASE_DIR}/foundry +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh +docker build -t cerc/foundry:local -f ${CERC_REPO_BASE_DIR}/foundry/Dockerfile-debian ${build_command_args} ${CERC_REPO_BASE_DIR}/foundry diff --git a/app/data/container-build/cerc-go-ethereum-foundry/build.sh b/app/data/container-build/cerc-go-ethereum-foundry/build.sh index d4fd2deb..41781112 100755 --- a/app/data/container-build/cerc-go-ethereum-foundry/build.sh +++ b/app/data/container-build/cerc-go-ethereum-foundry/build.sh @@ -1,7 +1,9 @@ #!/usr/bin/env bash # Build cerc/go-ethereum-foundry +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh + # See: https://stackoverflow.com/a/246128/1701505 SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -docker build -t cerc/go-ethereum-foundry:local --build-arg GENESIS_FILE_PATH=genesis-automine.json ${SCRIPT_DIR} +docker build -t cerc/go-ethereum-foundry:local --build-arg GENESIS_FILE_PATH=genesis-automine.json ${build_command_args} ${SCRIPT_DIR} diff --git a/app/data/container-build/cerc-go-ethereum/build.sh b/app/data/container-build/cerc-go-ethereum/build.sh index 0ab91354..171d0079 100755 --- a/app/data/container-build/cerc-go-ethereum/build.sh +++ b/app/data/container-build/cerc-go-ethereum/build.sh @@ -1,3 +1,4 @@ #!/usr/bin/env bash # Build cerc/go-ethereum -docker build -t cerc/go-ethereum:local ${CERC_REPO_BASE_DIR}/go-ethereum +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh +docker build -t cerc/go-ethereum:local ${build_command_args} ${CERC_REPO_BASE_DIR}/go-ethereum diff --git a/app/data/container-build/cerc-ipld-eth-beacon-db/build.sh b/app/data/container-build/cerc-ipld-eth-beacon-db/build.sh index c3c620d2..47875ec3 100755 --- a/app/data/container-build/cerc-ipld-eth-beacon-db/build.sh +++ b/app/data/container-build/cerc-ipld-eth-beacon-db/build.sh @@ -1,3 +1,4 @@ #!/usr/bin/env bash # Build cerc/ipld-eth-beacon-db -docker build -t cerc/ipld-eth-beacon-db:local ${CERC_REPO_BASE_DIR}/ipld-eth-beacon-db +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh +docker build -t cerc/ipld-eth-beacon-db:local ${build_command_args} ${build_command_args} ${CERC_REPO_BASE_DIR}/ipld-eth-beacon-db diff --git a/app/data/container-build/cerc-ipld-eth-beacon-indexer/build.sh b/app/data/container-build/cerc-ipld-eth-beacon-indexer/build.sh index 78a4cd00..d304bf3f 100755 --- a/app/data/container-build/cerc-ipld-eth-beacon-indexer/build.sh +++ b/app/data/container-build/cerc-ipld-eth-beacon-indexer/build.sh @@ -1,3 +1,4 @@ #!/usr/bin/env bash # Build cerc/ipld-eth-beacon-indexer -docker build -t cerc/ipld-eth-beacon-indexer:local ${CERC_REPO_BASE_DIR}/ipld-eth-beacon-indexer +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh +docker build -t cerc/ipld-eth-beacon-indexer:local ${build_command_args} ${CERC_REPO_BASE_DIR}/ipld-eth-beacon-indexer diff --git a/app/data/container-build/cerc-ipld-eth-db/build.sh b/app/data/container-build/cerc-ipld-eth-db/build.sh index ec5a905e..d454f3f8 100755 --- a/app/data/container-build/cerc-ipld-eth-db/build.sh +++ b/app/data/container-build/cerc-ipld-eth-db/build.sh @@ -1,3 +1,4 @@ #!/usr/bin/env bash # Build cerc/ipld-eth-db -docker build -t cerc/ipld-eth-db:local ${CERC_REPO_BASE_DIR}/ipld-eth-db +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh +docker build -t cerc/ipld-eth-db:local ${build_command_args} ${CERC_REPO_BASE_DIR}/ipld-eth-db diff --git a/app/data/container-build/cerc-ipld-eth-server/build.sh b/app/data/container-build/cerc-ipld-eth-server/build.sh index 7e714294..04c3907e 100755 --- a/app/data/container-build/cerc-ipld-eth-server/build.sh +++ b/app/data/container-build/cerc-ipld-eth-server/build.sh @@ -1,3 +1,4 @@ #!/usr/bin/env bash # Build cerc/ipld-eth-server -docker build -t cerc/ipld-eth-server:local ${CERC_REPO_BASE_DIR}/ipld-eth-server +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh +docker build -t cerc/ipld-eth-server:local ${build_command_args} ${CERC_REPO_BASE_DIR}/ipld-eth-server diff --git a/app/data/container-build/cerc-keycloak/build.sh b/app/data/container-build/cerc-keycloak/build.sh index 0e147a9d..be8a7d11 100755 --- a/app/data/container-build/cerc-keycloak/build.sh +++ b/app/data/container-build/cerc-keycloak/build.sh @@ -2,7 +2,9 @@ # #Build cerc/keycloack +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh + # See: https://stackoverflow.com/a/246128/1701505 SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -docker build -t cerc/keycloak:local ${SCRIPT_DIR} +docker build -t cerc/keycloak:local ${build_command_args} ${SCRIPT_DIR} diff --git a/app/data/container-build/cerc-laconic-console-host/build.sh b/app/data/container-build/cerc-laconic-console-host/build.sh index cc84d249..a321b195 100755 --- a/app/data/container-build/cerc-laconic-console-host/build.sh +++ b/app/data/container-build/cerc-laconic-console-host/build.sh @@ -1,9 +1,11 @@ #!/usr/bin/env bash # Build cerc/laconic-registry-cli +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh + # See: https://stackoverflow.com/a/246128/1701505 SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -docker build -t cerc/laconic-console-host:local -f ${SCRIPT_DIR}/Dockerfile \ +docker build -t cerc/laconic-console-host:local ${build_command_args} -f ${SCRIPT_DIR}/Dockerfile \ --add-host gitea.local:host-gateway \ --build-arg CERC_NPM_AUTH_TOKEN --build-arg CERC_NPM_URL ${SCRIPT_DIR} diff --git a/app/data/container-build/cerc-laconic-registry-cli/build.sh b/app/data/container-build/cerc-laconic-registry-cli/build.sh index ea157dac..a6264f4b 100755 --- a/app/data/container-build/cerc-laconic-registry-cli/build.sh +++ b/app/data/container-build/cerc-laconic-registry-cli/build.sh @@ -1,9 +1,11 @@ #!/usr/bin/env bash # Build cerc/laconic-registry-cli +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh + # See: https://stackoverflow.com/a/246128/1701505 SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -docker build -t cerc/laconic-registry-cli:local -f ${SCRIPT_DIR}/Dockerfile \ +docker build -t cerc/laconic-registry-cli:local ${build_command_args} -f ${SCRIPT_DIR}/Dockerfile \ --add-host gitea.local:host-gateway \ --build-arg CERC_NPM_AUTH_TOKEN --build-arg CERC_NPM_URL ${SCRIPT_DIR} diff --git a/app/data/container-build/cerc-laconicd/build.sh b/app/data/container-build/cerc-laconicd/build.sh index f5685097..3d897446 100755 --- a/app/data/container-build/cerc-laconicd/build.sh +++ b/app/data/container-build/cerc-laconicd/build.sh @@ -1,3 +1,4 @@ #!/usr/bin/env bash -# Build cerc/chiba-clonk -docker build -t cerc/laconicd:local ${CERC_REPO_BASE_DIR}/laconicd \ No newline at end of file +# Build cerc/laconicd +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh +docker build -t cerc/laconicd:local ${build_command_args} ${CERC_REPO_BASE_DIR}/laconicd \ No newline at end of file diff --git a/app/data/container-build/cerc-lighthouse/build.sh b/app/data/container-build/cerc-lighthouse/build.sh index 7babdbd1..2e9cfe3c 100755 --- a/app/data/container-build/cerc-lighthouse/build.sh +++ b/app/data/container-build/cerc-lighthouse/build.sh @@ -1,7 +1,9 @@ #!/usr/bin/env bash # Build cerc/lighthouse +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh + # See: https://stackoverflow.com/a/246128/1701505 SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -docker build -t cerc/lighthouse:local ${SCRIPT_DIR} +docker build -t cerc/lighthouse:local ${build_command_args} ${SCRIPT_DIR} diff --git a/app/data/container-build/cerc-mobymask-ui/build.sh b/app/data/container-build/cerc-mobymask-ui/build.sh index cabd63ff..52687093 100755 --- a/app/data/container-build/cerc-mobymask-ui/build.sh +++ b/app/data/container-build/cerc-mobymask-ui/build.sh @@ -1,7 +1,9 @@ #!/usr/bin/env bash # Build cerc/mobymask-ui +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh + # See: https://stackoverflow.com/a/246128/1701505 SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -docker build -t cerc/mobymask-ui:local -f ${SCRIPT_DIR}/Dockerfile ${CERC_REPO_BASE_DIR}/mobymask-ui +docker build -t cerc/mobymask-ui:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/mobymask-ui diff --git a/app/data/container-build/cerc-mobymask/build.sh b/app/data/container-build/cerc-mobymask/build.sh index 7628a228..f156846a 100755 --- a/app/data/container-build/cerc-mobymask/build.sh +++ b/app/data/container-build/cerc-mobymask/build.sh @@ -1,7 +1,9 @@ #!/usr/bin/env bash # Build cerc/mobymask +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh + # See: https://stackoverflow.com/a/246128/1701505 SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -docker build -t cerc/mobymask:local -f ${SCRIPT_DIR}/Dockerfile ${CERC_REPO_BASE_DIR}/MobyMask +docker build -t cerc/mobymask:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/MobyMask diff --git a/app/data/container-build/cerc-optimism-contracts/build.sh b/app/data/container-build/cerc-optimism-contracts/build.sh index 8b8e0eaa..b1ddd819 100755 --- a/app/data/container-build/cerc-optimism-contracts/build.sh +++ b/app/data/container-build/cerc-optimism-contracts/build.sh @@ -1,7 +1,9 @@ #!/usr/bin/env bash # Build cerc/optimism-contracts +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh + # See: https://stackoverflow.com/a/246128/1701505 SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -docker build -t cerc/optimism-contracts:local -f ${SCRIPT_DIR}/Dockerfile ${CERC_REPO_BASE_DIR}/optimism +docker build -t cerc/optimism-contracts:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/optimism diff --git a/app/data/container-build/cerc-optimism-l2geth/build.sh b/app/data/container-build/cerc-optimism-l2geth/build.sh index 3ffada73..5e125703 100755 --- a/app/data/container-build/cerc-optimism-l2geth/build.sh +++ b/app/data/container-build/cerc-optimism-l2geth/build.sh @@ -1,3 +1,4 @@ #!/usr/bin/env bash # Build cerc/optimism-l2geth -docker build -t cerc/optimism-l2geth:local ${CERC_REPO_BASE_DIR}/op-geth +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh +docker build -t cerc/optimism-l2geth:local ${build_command_args} ${CERC_REPO_BASE_DIR}/op-geth diff --git a/app/data/container-build/cerc-optimism-op-batcher/build.sh b/app/data/container-build/cerc-optimism-op-batcher/build.sh index 5bc3a238..08b209d0 100755 --- a/app/data/container-build/cerc-optimism-op-batcher/build.sh +++ b/app/data/container-build/cerc-optimism-op-batcher/build.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash # Build cerc/optimism-op-batcher # TODO: use upstream Dockerfile once its buildx-specific content has been removed +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -docker build -t cerc/optimism-op-batcher:local -f ${SCRIPT_DIR}/Dockerfile ${CERC_REPO_BASE_DIR}/optimism +docker build -t cerc/optimism-op-batcher:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/optimism diff --git a/app/data/container-build/cerc-optimism-op-node/build.sh b/app/data/container-build/cerc-optimism-op-node/build.sh index 0ec7e656..9c33529a 100755 --- a/app/data/container-build/cerc-optimism-op-node/build.sh +++ b/app/data/container-build/cerc-optimism-op-node/build.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash # Build cerc/optimism-op-node # TODO: use upstream Dockerfile once its buildx-specific content has been removed +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -docker build -t cerc/optimism-op-node:local -f ${SCRIPT_DIR}/Dockerfile ${CERC_REPO_BASE_DIR}/optimism +docker build -t cerc/optimism-op-node:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/optimism diff --git a/app/data/container-build/cerc-react-peer/build.sh b/app/data/container-build/cerc-react-peer/build.sh index a3d328de..48edc4b3 100755 --- a/app/data/container-build/cerc-react-peer/build.sh +++ b/app/data/container-build/cerc-react-peer/build.sh @@ -1,7 +1,9 @@ #!/usr/bin/env bash # Build cerc/react-peer +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh + # See: https://stackoverflow.com/a/246128/1701505 SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -docker build -t cerc/react-peer:local -f ${SCRIPT_DIR}/Dockerfile ${CERC_REPO_BASE_DIR}/react-peer +docker build -t cerc/react-peer:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/react-peer diff --git a/app/data/container-build/cerc-test-container/build.sh b/app/data/container-build/cerc-test-container/build.sh index 1595645c..ee56576a 100755 --- a/app/data/container-build/cerc-test-container/build.sh +++ b/app/data/container-build/cerc-test-container/build.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash # Build cerc/test-container +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -docker build -t cerc/test-container:local -f ${SCRIPT_DIR}/Dockerfile $SCRIPT_DIR \ No newline at end of file +docker build -t cerc/test-container:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} $SCRIPT_DIR \ No newline at end of file diff --git a/app/data/container-build/cerc-test-contract/build.sh b/app/data/container-build/cerc-test-contract/build.sh index 1b3c925e..9df768fb 100755 --- a/app/data/container-build/cerc-test-contract/build.sh +++ b/app/data/container-build/cerc-test-contract/build.sh @@ -1,3 +1,4 @@ #!/usr/bin/env bash # Build cerc/test-contract -docker build -t cerc/test-contract:local --build-arg ETH_ADDR=http://go-ethereum:8545 ${CERC_REPO_BASE_DIR}/ipld-eth-db-validator/test/contract +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh +docker build -t cerc/test-contract:local --build-arg ETH_ADDR=http://go-ethereum:8545 ${build_command_args} ${CERC_REPO_BASE_DIR}/ipld-eth-db-validator/test/contract diff --git a/app/data/container-build/cerc-tx-spammer/build.sh b/app/data/container-build/cerc-tx-spammer/build.sh index b6752dd7..ee4494e0 100755 --- a/app/data/container-build/cerc-tx-spammer/build.sh +++ b/app/data/container-build/cerc-tx-spammer/build.sh @@ -1,3 +1,4 @@ #!/usr/bin/env bash # Build cerc/tx-spammer -docker build -t cerc/tx-spammer:local ${CERC_REPO_BASE_DIR}/tx-spammer +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh +docker build -t cerc/tx-spammer:local ${build_command_args} ${CERC_REPO_BASE_DIR}/tx-spammer diff --git a/app/data/container-build/cerc-uniswap-v3-info/build.sh b/app/data/container-build/cerc-uniswap-v3-info/build.sh index bda1bb5e..efbc1c08 100755 --- a/app/data/container-build/cerc-uniswap-v3-info/build.sh +++ b/app/data/container-build/cerc-uniswap-v3-info/build.sh @@ -1,7 +1,9 @@ #!/usr/bin/env bash # Build cerc/uniswap-v3-info +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh + # See: https://stackoverflow.com/a/246128/1701505 SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -docker build -t cerc/uniswap-v3-info:local -f ${SCRIPT_DIR}/Dockerfile ${CERC_REPO_BASE_DIR}/uniswap-v3-info +docker build -t cerc/uniswap-v3-info:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/uniswap-v3-info diff --git a/app/data/container-build/cerc-watcher-erc20/build.sh b/app/data/container-build/cerc-watcher-erc20/build.sh index b800b73d..67ac0d24 100755 --- a/app/data/container-build/cerc-watcher-erc20/build.sh +++ b/app/data/container-build/cerc-watcher-erc20/build.sh @@ -1,7 +1,9 @@ #!/usr/bin/env bash # Build cerc/watcher-erc20 +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh + # See: https://stackoverflow.com/a/246128/1701505 SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -docker build -t cerc/watcher-erc20:local -f ${SCRIPT_DIR}/Dockerfile ${CERC_REPO_BASE_DIR}/watcher-ts +docker build -t cerc/watcher-erc20:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/watcher-ts diff --git a/app/data/container-build/cerc-watcher-erc721/build.sh b/app/data/container-build/cerc-watcher-erc721/build.sh index b9c9c0b8..f9c630ac 100755 --- a/app/data/container-build/cerc-watcher-erc721/build.sh +++ b/app/data/container-build/cerc-watcher-erc721/build.sh @@ -1,7 +1,9 @@ #!/usr/bin/env bash # Build cerc/watcher-erc721 +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh + # See: https://stackoverflow.com/a/246128/1701505 SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -docker build -t cerc/watcher-erc721:local -f ${SCRIPT_DIR}/Dockerfile ${CERC_REPO_BASE_DIR}/watcher-ts +docker build -t cerc/watcher-erc721:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/watcher-ts diff --git a/app/data/container-build/cerc-watcher-mobymask-v2/build.sh b/app/data/container-build/cerc-watcher-mobymask-v2/build.sh index 19e82818..f8b59224 100755 --- a/app/data/container-build/cerc-watcher-mobymask-v2/build.sh +++ b/app/data/container-build/cerc-watcher-mobymask-v2/build.sh @@ -1,7 +1,9 @@ #!/usr/bin/env bash # Build cerc/watcher-mobymask-v2 +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh + # See: https://stackoverflow.com/a/246128/1701505 SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -docker build -t cerc/watcher-mobymask-v2:local -f ${SCRIPT_DIR}/Dockerfile ${CERC_REPO_BASE_DIR}/watcher-ts +docker build -t cerc/watcher-mobymask-v2:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/watcher-ts diff --git a/app/data/container-build/cerc-watcher-mobymask/build.sh b/app/data/container-build/cerc-watcher-mobymask/build.sh index f965c770..219b864f 100755 --- a/app/data/container-build/cerc-watcher-mobymask/build.sh +++ b/app/data/container-build/cerc-watcher-mobymask/build.sh @@ -1,9 +1,11 @@ #!/usr/bin/env bash # Build cerc/watcher-mobymask +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh + # See: https://stackoverflow.com/a/246128/1701505 SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -docker build -t cerc/watcher-mobymask:local -f ${SCRIPT_DIR}/Dockerfile ${CERC_REPO_BASE_DIR}/watcher-ts +docker build -t cerc/watcher-mobymask:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/watcher-ts # TODO: add a mechanism to pass two repos into a container rather than the parent directory diff --git a/app/data/container-build/cerc-watcher-uniswap-v3/build.sh b/app/data/container-build/cerc-watcher-uniswap-v3/build.sh index 432feb02..5dc63d50 100755 --- a/app/data/container-build/cerc-watcher-uniswap-v3/build.sh +++ b/app/data/container-build/cerc-watcher-uniswap-v3/build.sh @@ -1,7 +1,9 @@ #!/usr/bin/env bash # Build cerc/watcher-uniswap-v3 +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh + # See: https://stackoverflow.com/a/246128/1701505 SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -docker build -t cerc/watcher-uniswap-v3:local -f ${SCRIPT_DIR}/Dockerfile ${CERC_REPO_BASE_DIR}/uniswap-watcher-ts +docker build -t cerc/watcher-uniswap-v3:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/uniswap-watcher-ts diff --git a/app/data/container-build/default-build.sh b/app/data/container-build/default-build.sh index c52dd043..6757812b 100755 --- a/app/data/container-build/default-build.sh +++ b/app/data/container-build/default-build.sh @@ -1,14 +1,13 @@ #!/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 + +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh + if [[ $# -ne 2 ]]; then echo "Illegal number of parameters" >&2 exit 1 fi image_tag=$1 build_dir=$2 -echo "Building ${image_tag} in ${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} +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} diff --git a/docs/cli.md b/docs/cli.md index 70905d87..f7c6205f 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -1,3 +1,48 @@ # laconic-so Sub-commands and flags + +## build-containers + +Build a single container: +``` +$ laconic-so build-containers --include +``` +e.g. +``` +$ laconic-so build-containers --include cerc/go-ethereum +``` +Build the containers for a stack: +``` +$ laconic-so --stack build-containers +``` +e.g. +``` +$ laconic-so --stack fixturenet-eth build-containers +``` +Force full rebuild of container images: +``` +$ laconic-so build-containers --include --force-rebuild +``` +## build-npms + +Build a single package: +``` +$ laconic-so build-npms --include +``` +e.g. +``` +$ laconic-so build-npms --include laconic-sdk +``` +Build the packages for a stack: +``` +$ laconic-so --stack build-npms +``` +e.g. +``` +$ laconic-so --stack fixturenet-laconicd build-npms +``` +Force full rebuild of packages: +``` +$ laconic-so build-npms --include --force-rebuild +```