Skip to content
Snippets Groups Projects
Verified Commit b0ff70e6 authored by Mateusz Żebrak's avatar Mateusz Żebrak
Browse files

Build docker images with clive CLI entrypoint

parent 9795b613
No related branches found
No related tags found
3 merge requests!186V1.27.5.0 release,!174RELEASE: 1,!165Update submodule to hive!1012
......@@ -181,6 +181,11 @@ testing_clive:
build_and_push_clive_image:
extends: .prepare_clive_image
build_and_push_clive_cli_image:
extends: build_and_push_clive_image
variables:
BUILD_INSTANCE_ARGS: "--interactive-cli"
build_and_push_clive_testnet_image:
extends: .prepare_clive_image
<<: *clive_testnet_needs
......@@ -188,6 +193,11 @@ build_and_push_clive_testnet_image:
BASE_IMAGE: ${HIVED_IMAGE_NAME}
BUILD_INSTANCE_ARGS: "--embedded-testnet"
build_and_push_clive_cli_testnet_image:
extends: build_and_push_clive_testnet_image
variables:
BUILD_INSTANCE_ARGS: "--embedded-testnet --interactive-cli"
.prepare_clive_stable_image:
extends: .prepare_clive_image
when: on_success
......@@ -207,6 +217,11 @@ build_and_push_clive_testnet_image:
build_and_push_clive_stable_image:
extends: .prepare_clive_stable_image
build_and_push_clive_cli_stable_image:
extends: build_and_push_clive_stable_image
variables:
BUILD_INSTANCE_ARGS: "--interactive-cli"
build_and_push_clive_stable_testnet_image:
extends: .prepare_clive_stable_image
<<: *clive_testnet_needs
......@@ -214,4 +229,9 @@ build_and_push_clive_stable_testnet_image:
BASE_IMAGE: ${HIVED_IMAGE_NAME}
BUILD_INSTANCE_ARGS: "--embedded-testnet --image-path-suffix=-${CI_COMMIT_REF_NAME}"
build_and_push_clive_cli_stable_testnet_image:
extends: build_and_push_clive_stable_testnet_image
variables:
BUILD_INSTANCE_ARGS: "--embedded-testnet --image-path-suffix=-${CI_COMMIT_REF_NAME} --interactive-cli"
#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<| BUILD DOCKER |<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
......@@ -9,6 +9,7 @@ FROM $BASE_IMAGE AS instance
SHELL ["/bin/bash", "-c"]
ADD --chown=hived_admin:users ./docker/entrypoint.sh .
ADD --chown=hived_admin:users . /clive
WORKDIR /clive
......@@ -22,7 +23,12 @@ RUN poetry self update && \
# crucial for proper display
ENV COLORTERM=truecolor
ENTRYPOINT ["poetry", "run", "clive"]
ARG INTERACTIVE_CLI_MODE=0
ENV INTERACTIVE_CLI_MODE=${INTERACTIVE_CLI_MODE}
ENV TESTNET_MODE=0
ENTRYPOINT ["/home/hived_admin/entrypoint.sh"]
# this target should be built using a testnet hived image as a base (to have embedded testnet)
FROM instance as embedded_testnet_instance
......@@ -43,4 +49,6 @@ WORKDIR /clive
# Run installation once again to supplement extras and development dependencies
RUN poetry install
ENTRYPOINT ["poetry", "run", "python", "testnet_node.py"]
ENV TESTNET_MODE=1
ENTRYPOINT ["/home/hived_admin/entrypoint.sh"]
#! /bin/bash
set -euo pipefail
TESTNET_NODE_LOG_FILE=testnet_node.log
wait_for_testnet() {
LIMIT=120 # seconds
TARGET_SUBSTRING="Serving forever"
COMMAND="( tail -f -n0 ${TESTNET_NODE_LOG_FILE} & ) | grep -q '${TARGET_SUBSTRING}'"
echo "Waiting for testnet node to be ready..."
timeout $LIMIT bash -c "${COMMAND}"
echo "Testnet node is ready to use"
}
echo "TESTNET_MODE=${TESTNET_MODE}"
echo "INTERACTIVE_CLI_MODE=${INTERACTIVE_CLI_MODE}"
# Activate the virtual environment
source $(poetry env info --path)/bin/activate
if [ "${TESTNET_MODE}" = "0" ]; then
if [ "${INTERACTIVE_CLI_MODE}" = "0" ]; then
echo "Launching clive in TUI mode on mainnet"
clive
else
echo "Launching clive in CLI mode on mainnet"
bash
fi
else
if [ "${INTERACTIVE_CLI_MODE}" = "0" ]; then
echo "Launching clive in TUI mode on testnet"
python3 testnet_node.py
else
echo "Launching clive in CLI mode on testnet"
python3 testnet_node.py --no-tui >${TESTNET_NODE_LOG_FILE} 2>&1 &
wait_for_testnet
bash
fi
fi
......@@ -12,6 +12,7 @@ REGISTRY=""
SRCROOTDIR=""
IMAGE_TAG_PREFIX=""
IMAGE_TAG_CLI=""
IMAGE_PATH_SUFFIX=""
BEEKEEPER_IMAGE=""
......@@ -19,6 +20,8 @@ BASE_IMAGE=""
DOCKER_TARGET="instance"
INTERACTIVE_CLI_MODE=0
print_help () {
echo "Usage: $0 <image_tag> <src_dir> <registry_url> [OPTION[=VALUE]]..."
echo
......@@ -27,6 +30,7 @@ print_help () {
echo " --beekeeper-source-image=image_name Allows to specify image name containing a prebuilt beekeper tool"
echo " --base-image=image_name Allows to specify an image name being use as a base of the one to be built"
echo " --embedded-testnet Allows to build a clive image having embedded a hived testnet inside (ready for immediate sanboxing run)"
echo " --interactive-cli Allows to build a clive image having interactive CLI mode ready to use"
echo " --image-path-suffix Allows to specify a suffix to be added to the image path, to organize images in a more structured directory-like way"
echo " --help Display this help screen and exit"
echo
......@@ -46,6 +50,10 @@ while [ $# -gt 0 ]; do
DOCKER_TARGET="embedded_testnet_instance"
IMAGE_TAG_PREFIX="testnet-"
;;
--interactive-cli)
INTERACTIVE_CLI_MODE=1
IMAGE_TAG_CLI="cli-"
;;
--image-path-suffix=*)
IMAGE_PATH_SUFFIX="${1#*=}"
;;
......@@ -90,7 +98,7 @@ pushd "$SRCROOTDIR"
export DOCKER_BUILDKIT=1
CLIVE_IMAGE_TAG_PREFIX="${IMAGE_TAG_PREFIX}instance"
CLIVE_IMAGE_TAG_PREFIX="${IMAGE_TAG_PREFIX}${IMAGE_TAG_CLI}instance"
CLIVE_IMAGE_PATH="${REGISTRY}${CLIVE_IMAGE_TAG_PREFIX}${IMAGE_PATH_SUFFIX}"
CLIVE_IMAGE_NAME="${CLIVE_IMAGE_PATH}:${CLIVE_IMAGE_TAG_PREFIX}-${BUILD_IMAGE_TAG}"
......@@ -98,6 +106,7 @@ docker build --target=${DOCKER_TARGET} \
--build-arg CI_REGISTRY_IMAGE=$REGISTRY \
--build-arg BASE_IMAGE=${BASE_IMAGE} \
--build-arg BEEKEEPER_IMAGE=${BEEKEEPER_IMAGE} \
--build-arg INTERACTIVE_CLI_MODE=${INTERACTIVE_CLI_MODE} \
-t ${CLIVE_IMAGE_NAME} \
-f docker/Dockerfile .
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment