From 3c3a97ce1588d0c70b7d8ea5b60e6a97f4bc9b95 Mon Sep 17 00:00:00 2001 From: Blair Vanderlugt Date: Mon, 6 Sep 2021 12:07:57 -0700 Subject: [PATCH] run signer as a service over http --- apps/cic-eth/docker/Dockerfile | 17 ++--- .../docker/entrypoints/start_tasker.sh | 36 +++++------ apps/cic-eth/tools_requirements.txt | 2 +- docker-compose.yml | 63 ++++++++++++++++++- 4 files changed, 89 insertions(+), 29 deletions(-) diff --git a/apps/cic-eth/docker/Dockerfile b/apps/cic-eth/docker/Dockerfile index bbb0fbbe..5e798d72 100644 --- a/apps/cic-eth/docker/Dockerfile +++ b/apps/cic-eth/docker/Dockerfile @@ -13,7 +13,16 @@ ARG EXTRA_PIP_ARGS="" # pip install --index-url https://pypi.org/simple \ # --force-reinstall \ # --extra-index-url $GITLAB_PYTHON_REGISTRY --extra-index-url $EXTRA_INDEX_URL \ -# -r requirements.txt +# -r requirements.txt + +RUN --mount=type=cache,mode=0755,target=/root/.cache/pip \ + pip install --index-url https://pypi.org/simple \ + --extra-index-url $GITLAB_PYTHON_REGISTRY \ + --extra-index-url $EXTRA_INDEX_URL \ + $EXTRA_PIP_ARGS \ + cic-eth-aux-erc20-demurrage-token~=0.0.2a6 + + COPY *requirements.txt ./ RUN --mount=type=cache,mode=0755,target=/root/.cache/pip \ pip install --index-url https://pypi.org/simple \ @@ -29,12 +38,6 @@ RUN python setup.py install ENV PYTHONPATH . -RUN --mount=type=cache,mode=0755,target=/root/.cache/pip \ - pip install --index-url https://pypi.org/simple \ - --extra-index-url $GITLAB_PYTHON_REGISTRY \ - --extra-index-url $EXTRA_INDEX_URL \ - $EXTRA_PIP_ARGS \ - cic-eth-aux-erc20-demurrage-token~=0.0.2a6 COPY docker/entrypoints/* ./ RUN chmod 755 *.sh diff --git a/apps/cic-eth/docker/entrypoints/start_tasker.sh b/apps/cic-eth/docker/entrypoints/start_tasker.sh index d0984322..14d82b90 100644 --- a/apps/cic-eth/docker/entrypoints/start_tasker.sh +++ b/apps/cic-eth/docker/entrypoints/start_tasker.sh @@ -5,27 +5,27 @@ set -e # set CONFINI_ENV_PREFIX to override the env prefix to override env vars -echo "!!! starting signer" -python /usr/local/bin/crypto-dev-daemon -c /usr/local/etc/crypto-dev-signer -vv 2> /tmp/signer.log & +#echo "!!! starting signer" +#python /usr/local/bin/crypto-dev-daemon -c /usr/local/etc/crypto-dev-signer -vv 2> /tmp/signer.log & echo "!!! starting taskerd" /usr/local/bin/cic-eth-taskerd $@ # thanks! https://docs.docker.com/config/containers/multi-service_container/ -sleep 1; -echo "!!! entering monitor loop" -while true; do - ps aux | grep crypto-dev-daemon | grep -q -v grep - PROCESS_1_STATUS=$? - ps aux | grep cic-eth-tasker |grep -q -v grep - PROCESS_2_STATUS=$? - # If the greps above find anything, they exit with 0 status - # If they are not both 0, then something is wrong - if [ $PROCESS_1_STATUS -ne 0 -o $PROCESS_2_STATUS -ne 0 ]; then - echo "One of the processes has already exited." - exit 1 - fi - sleep 15; -done - +#sleep 1; +#echo "!!! entering monitor loop" +#while true; do +# ps aux | grep crypto-dev-daemon | grep -q -v grep +# PROCESS_1_STATUS=$? +# ps aux | grep cic-eth-tasker |grep -q -v grep +# PROCESS_2_STATUS=$? +# # If the greps above find anything, they exit with 0 status +# # If they are not both 0, then something is wrong +# if [ $PROCESS_1_STATUS -ne 0 -o $PROCESS_2_STATUS -ne 0 ]; then +# echo "One of the processes has already exited." +# exit 1 +# fi +# sleep 15; +#done +# set +e diff --git a/apps/cic-eth/tools_requirements.txt b/apps/cic-eth/tools_requirements.txt index 1ecb54a6..54200ef7 100644 --- a/apps/cic-eth/tools_requirements.txt +++ b/apps/cic-eth/tools_requirements.txt @@ -1,4 +1,4 @@ -crypto-dev-signer>=0.4.15a1,<=0.4.15 +crypto-dev-signer>=0.4.15a2,<=0.4.15 chainqueue>=0.0.5a1,<0.1.0 cic-eth-registry>=0.6.1a2,<0.7.0 redis==3.5.3 diff --git a/docker-compose.yml b/docker-compose.yml index d61cab55..749adaf9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -266,8 +266,8 @@ services: CELERY_BROKER_URL: ${CELERY_BROKER_URL:-redis://redis} CELERY_RESULT_URL: ${CELERY_RESULT_URL:-redis://redis} CELERY_DEBUG: ${CELERY_DEBUG:-1} - SIGNER_SOCKET_PATH: ${SIGNER_SOCKET_PATH:-ipc:///run/crypto-dev-signer/jsonrpc.ipc} - SIGNER_PROVIDER: ${SIGNER_SOCKET_PATH:-ipc:///run/crypto-dev-signer/jsonrpc.ipc} + SIGNER_SOCKET_PATH: ${SIGNER_SOCKET_PATH:-http://cic-eth-signer:8000} + SIGNER_PROVIDER: ${SIGNER_SOCKET_PATH:-http://cic-eth-signer:8000} SIGNER_SECRET: ${SIGNER_SECRET:-deadbeef} ETH_ACCOUNT_ACCOUNTS_INDEX_WRITER: ${DEV_ETH_ACCOUNT_ACCOUNTS_INDEX_WRITER:-0xACB0BC74E1686D62dE7DC6414C999EA60C09F0eA} TASKS_TRACE_QUEUE_STATUS: ${TASKS_TRACE_QUEUE_STATUS:-1} @@ -280,14 +280,70 @@ services: restart_policy: condition: on-failure volumes: - - signer-data:/tmp/cic/signer + - signer-data:/run/crypto-dev-signer - contract-config:/tmp/cic/config/:ro + #command: ["/usr/local/bin/cic-eth-taskerd"] + #command: ["sleep", "3600"] command: - /bin/bash - -c - | if [[ -f /tmp/cic/config/.env ]]; then source /tmp/cic/config/.env; fi ./start_tasker.sh --aux-all -q cic-eth -vv + + cic-eth-signer: + image: registry.gitlab.com/grassrootseconomics/cic-internal-integration/cic-eth:${TAG:-latest} + build: + context: apps/cic-eth + dockerfile: docker/Dockerfile + target: dev + args: + EXTRA_INDEX_URL: ${EXTRA_INDEX_URL:-https://pip.grassrootseconomics.net:8433} + environment: + CIC_REGISTRY_ADDRESS: $CIC_REGISTRY_ADDRESS + ETH_GAS_PROVIDER_ADDRESS: $DEV_ETH_ACCOUNT_GAS_PROVIDER + ETH_PROVIDER: ${ETH_PROVIDER:-http://eth:8545} + RPC_HTTP_PROVIDER: ${ETH_PROVIDER:-http://eth:8545} + DATABASE_USER: ${DATABASE_USER:-grassroots} + DATABASE_HOST: ${DATABASE_HOST:-postgres} + DATABASE_PASSWORD: ${DATABASE_PASSWORD:-tralala} + DATABASE_NAME: ${DATABASE_NAME_CIC_ETH:-cic_eth} + DATABASE_PORT: ${DATABASE_PORT:-5432} + DATABASE_ENGINE: ${DATABASE_ENGINE:-postgres} + DATABASE_DRIVER: ${DATABASE_DRIVER:-psycopg2} + DATABASE_DEBUG: ${DATABASE_DEBUG:-0} + DATABASE_POOL_SIZE: 0 + REDIS_PORT: 6379 + REDIS_HOST: redis + PGPASSWORD: ${DATABASE_PASSWORD:-tralala} + CIC_CHAIN_SPEC: ${CIC_CHAIN_SPEC:-evm:bloxberg:8996} + CHAIN_SPEC: ${CIC_CHAIN_SPEC:-evm:bloxberg:8996} + CELERY_BROKER_URL: ${CELERY_BROKER_URL:-redis://redis} + CELERY_RESULT_URL: ${CELERY_RESULT_URL:-redis://redis} + CELERY_DEBUG: ${CELERY_DEBUG:-1} + SIGNER_SOCKET_PATH: ${SIGNER_SOCKET_PATH:-http://0.0.0.0:8000} + SIGNER_PROVIDER: ${SIGNER_SOCKET_PATH:-http://0.0.0.0:8000} + SIGNER_SECRET: ${SIGNER_SECRET:-deadbeef} + ETH_ACCOUNT_ACCOUNTS_INDEX_WRITER: ${DEV_ETH_ACCOUNT_ACCOUNTS_INDEX_WRITER:-0xACB0BC74E1686D62dE7DC6414C999EA60C09F0eA} + TASKS_TRACE_QUEUE_STATUS: ${TASKS_TRACE_QUEUE_STATUS:-1} + CIC_DEFAULT_TOKEN_SYMBOL: ${CIC_DEFAULT_TOKEN_SYMBOL:-GFT} + depends_on: + - eth + - postgres + - redis + deploy: + restart_policy: + condition: on-failure + volumes: + - signer-data:/run/crypto-dev-signer + - contract-config:/tmp/cic/config/:ro + command: ["python", "/usr/local/bin/crypto-dev-daemon", "-c", "/usr/local/etc/crypto-dev-signer", "-vv"] + #command: + # - /bin/bash + # - -c + # - | + # if [[ -f /tmp/cic/config/.env ]]; then source /tmp/cic/config/.env; fi + # ./start_tasker.sh --aux-all -q cic-eth -vv # command: [/bin/sh, "./start_tasker.sh", -q, cic-eth, -vv ] cic-eth-tracker: @@ -378,6 +434,7 @@ services: if [[ -f /tmp/cic/config/.env ]]; then source /tmp/cic/config/.env; fi ./start_dispatcher.sh -q cic-eth -vv # command: "/root/start_dispatcher.sh -q cic-eth -vv" + cic-eth-retrier: