From e1a02c8b766d89ec67770b275d3aaf0411659c04 Mon Sep 17 00:00:00 2001 From: Slava <20563034+veaceslavdoina@users.noreply.github.com> Date: Tue, 1 Oct 2024 16:05:22 +0300 Subject: [PATCH] Use CLI args when passed for cirdl in Docker entrypoint (#927) * Use CLI args when passed for cirdl in Docker entrypoint Signed-off-by: Slava <20563034+veaceslavdoina@users.noreply.github.com> * Increase CI timeout Signed-off-by: Slava <20563034+veaceslavdoina@users.noreply.github.com> --------- Signed-off-by: Slava <20563034+veaceslavdoina@users.noreply.github.com> --- .github/workflows/ci-reusable.yml | 2 +- docker/docker-entrypoint.sh | 23 +++++++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-reusable.yml b/.github/workflows/ci-reusable.yml index 595ce99d..591e2003 100644 --- a/.github/workflows/ci-reusable.yml +++ b/.github/workflows/ci-reusable.yml @@ -26,7 +26,7 @@ jobs: name: '${{ matrix.os }}-${{ matrix.cpu }}-${{ matrix.nim_version }}-${{ matrix.tests }}' runs-on: ${{ matrix.builder }} - timeout-minutes: 90 + timeout-minutes: 100 steps: - name: Checkout sources uses: actions/checkout@v4 diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh index ab03e634..325025c9 100644 --- a/docker/docker-entrypoint.sh +++ b/docker/docker-entrypoint.sh @@ -1,6 +1,8 @@ #!/bin/bash # Environment variables from files +# If set to file path, read the file and export the variables +# If set to directory path, read all files in the directory and export the variables if [[ -n "${ENV_PATH}" ]]; then set -a [[ -f "${ENV_PATH}" ]] && source "${ENV_PATH}" || for f in "${ENV_PATH}"/*; do source "$f"; done @@ -53,15 +55,28 @@ fi # Circuit downloader # cirdl [circuitPath] [rpcEndpoint] [marketplaceAddress] if [[ "$@" == *"prover"* ]]; then - echo "Run Circuit downloader" - # Set circuits dir from CODEX_CIRCUIT_DIR variables if set + echo "Prover is enabled - Run Circuit downloader" + + # Set variables required by cirdl from command line arguments when passed + for arg in data-dir circuit-dir eth-provider marketplace-address; do + arg_value=$(grep -o "${arg}=[^ ,]\+" <<< $@ | awk -F '=' '{print $2}') + if [[ -n "${arg_value}" ]]; then + var_name=$(tr '[:lower:]' '[:upper:]' <<< "CODEX_${arg//-/_}") + export "${var_name}"="${arg_value}" + fi + done + + # Set circuit dir from CODEX_CIRCUIT_DIR variables if set if [[ -z "${CODEX_CIRCUIT_DIR}" ]]; then export CODEX_CIRCUIT_DIR="${CODEX_DATA_DIR}/circuits" fi - # Download circuits + + # Download circuit mkdir -p "${CODEX_CIRCUIT_DIR}" chmod 700 "${CODEX_CIRCUIT_DIR}" - cirdl "${CODEX_CIRCUIT_DIR}" "${CODEX_ETH_PROVIDER}" "${CODEX_MARKETPLACE_ADDRESS}" + download="cirdl ${CODEX_CIRCUIT_DIR} ${CODEX_ETH_PROVIDER} ${CODEX_MARKETPLACE_ADDRESS}" + echo "${download}" + eval "${download}" [[ $? -ne 0 ]] && { echo "Failed to download circuit files"; exit 1; } fi