From 70a55b6da0873f8666ddf4411e6ad04f01402333 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mateusz=20=C5=BBebrak?= <mzebrak@syncad.com>
Date: Fri, 10 Nov 2023 10:22:15 +0100
Subject: [PATCH] Adjust dockerfile to the latest changes in images from hived

Due to latest changes in hived docker images:
- git was removed, so we no longer require it in dockerfile
  (previously it was required for poetry install and
  poetry dynamic-versioning commands. It was fixed by
  embedded_testnet_instance installing only dev packages
  via the --no-root switch, so it requires already installed clive
  from previous stage)
- need to install libboost-all-dev because wax requires it
- need to install poetry just for the embedded_testnet_instance
  (so we can supplement with dev dependencies only. We also create venv
  by python3-venv instead of poetry now)
---
 docker/Dockerfile                    | 22 ++++++++++++++++------
 docker/entrypoint.sh                 |  3 ---
 scripts/ci-helpers/build_instance.sh | 11 ++---------
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/docker/Dockerfile b/docker/Dockerfile
index f3b2e1e47c..01278e0175 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -22,14 +22,22 @@ COPY --from=beekeper_source --chown=hived_admin:users "/home/hived/bin/beekeeper
 # crucial for proper display
 ENV COLORTERM=truecolor
 
+# libboost-all-dev is required for wax
+RUN sudo apt-get update && \
+    sudo apt-get install -y python3-venv libboost-all-dev && \
+    sudo apt-get clean && \
+    sudo rm -rf /var/lib/apt/lists/*
+
+# create and use python virtualenv
+ENV PYTHON_VENV_PATH="/clive/venv"
+RUN python3 -m venv ${PYTHON_VENV_PATH}
+ENV PATH="${PYTHON_VENV_PATH}/bin:$PATH" VIRTUAL_ENV=${PYTHON_VENV_PATH}
+
 
 FROM common as instance
 
 ARG CLIVE_VERSION
 
-RUN poetry env use python3
-RUN source "$(poetry env info --path)/bin/activate"
-
 # Project IDS:
 # - 362 -> schemas
 # - 392 -> clive
@@ -45,7 +53,7 @@ ENTRYPOINT ["/home/hived_admin/entrypoint.sh"]
 
 
 # this target should be built using a testnet hived image as a base (to have embedded testnet)
-FROM common as embedded_testnet_instance
+FROM instance as embedded_testnet_instance
 
 ARG CLIVE_SECRETS__DEFAULT_KEY="5KTNAYSHVzhnVPrwHpKhc5QqNQt6aW8JsrMT7T4hyrKydzYvYik"
 ENV CLIVE_SECRETS__DEFAULT_KEY=${CLIVE_SECRETS__DEFAULT_KEY}
@@ -58,9 +66,11 @@ ENV CLI_WALLET_PATH="/home/hived/bin/cli_wallet"
 ENV GET_DEV_KEY_PATH="/home/hived/bin/get_dev_key"
 ENV COMPRESS_BLOCK_LOG_PATH="/home/hived/bin/compress_block_log"
 
+RUN curl -sSL https://install.python-poetry.org | python3 - --version 1.7.0
+ENV PATH="/home/hived_admin/.local/bin:$PATH"
+
 # Run dev installation to supplement with development dependencies
-RUN poetry install
-RUN poetry dynamic-versioning  # Substitute versions because of https://github.com/mtkennerly/poetry-dynamic-versioning/issues/25#issuecomment-698193152, has to be done after installation otherwise pip will show "dirty" version
+RUN poetry install --no-root
 
 ENV TESTNET_MODE=1
 
diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh
index 469b7c1cfb..73f244ada2 100755
--- a/docker/entrypoint.sh
+++ b/docker/entrypoint.sh
@@ -57,9 +57,6 @@ while [ $# -gt 0 ]; do
   shift
 done
 
-# 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"
diff --git a/scripts/ci-helpers/build_instance.sh b/scripts/ci-helpers/build_instance.sh
index b4798d0ae3..c41f218e53 100755
--- a/scripts/ci-helpers/build_instance.sh
+++ b/scripts/ci-helpers/build_instance.sh
@@ -28,7 +28,7 @@ print_help () {
     echo "OPTIONS:"
     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 "  --clive-version=version             Allows to specify a version of clive to be installed in the image (omitted if --embedded-testnet is used)"
+    echo "  --clive-version=version             Allows to specify a version of clive to be installed in the image"
     echo "  --embedded-testnet                  Allows to build a clive image having embedded a hived testnet inside (ready for immediate sanboxing run)"
     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"
@@ -86,14 +86,7 @@ TST_REGISTRY=${REGISTRY:?"Missing arg #3 to specify target container registry"}
 
 TST_BEEKEEPER_IMAGE=${BEEKEEPER_IMAGE:?"Missing --beekeeper-source-image to specify beekeeper binary source"}
 TST_BASE_IMAGE=${BASE_IMAGE:?"Missing --base-image option to specify base image"}
-
-if [ -z "$CLIVE_VERSION" ] && [ "$DOCKER_TARGET" != "embedded_testnet_instance" ];
-then
-  echo "ERROR: Missing --clive-version option to specify clive version to be installed"
-  echo
-  print_help
-  exit 2
-fi
+TST_CLIVE_VERSION=${CLIVE_VERSION:?"Missing --clive-version option to specify clive version to be installed"}
 
 # Supplement a registry path by trailing slash (if needed)
 [[ "${REGISTRY}" != */ ]] && REGISTRY="${REGISTRY}/"
-- 
GitLab