From e1dd060929cc7e65b6e6265361d01f4edd71f142 Mon Sep 17 00:00:00 2001 From: Oleg Sheynin Date: Tue, 15 Apr 2025 21:13:42 -0400 Subject: [PATCH] progress (UNTESTED) --- microservices/.env | 10 +++ microservices/bookkeeper/.dockerignore | 3 + microservices/bookkeeper/Dockerfile | 25 ++++++ microservices/bookkeeper/entrypoint.sh | 16 ++++ microservices/bookkeeper/requirements.txt | 11 +++ microservices/build.sh | 10 ++- microservices/docker-compose.yml | 87 ++++++++++++++++++++- microservices/quant/.dockerignore | 3 + microservices/quant/Dockerfile | 19 +++++ microservices/quant/entrypoint.sh | 14 ++++ microservices/quant/requirements.txt | 9 +++ microservices/risk_manager/.dockerignore | 3 + microservices/risk_manager/Dockerfile | 19 +++++ microservices/risk_manager/entrypoint.sh | 14 ++++ microservices/risk_manager/requirements.txt | 9 +++ microservices/trader/.dockerignore | 3 + microservices/trader/Dockerfile | 19 +++++ microservices/trader/entrypoint.sh | 14 ++++ microservices/trader/requirements.txt | 9 +++ 19 files changed, 293 insertions(+), 4 deletions(-) create mode 100644 microservices/bookkeeper/.dockerignore create mode 100644 microservices/bookkeeper/Dockerfile create mode 100755 microservices/bookkeeper/entrypoint.sh create mode 100644 microservices/bookkeeper/requirements.txt create mode 100644 microservices/quant/.dockerignore create mode 100644 microservices/quant/Dockerfile create mode 100755 microservices/quant/entrypoint.sh create mode 100644 microservices/quant/requirements.txt create mode 100644 microservices/risk_manager/.dockerignore create mode 100644 microservices/risk_manager/Dockerfile create mode 100755 microservices/risk_manager/entrypoint.sh create mode 100644 microservices/risk_manager/requirements.txt create mode 100644 microservices/trader/.dockerignore create mode 100644 microservices/trader/Dockerfile create mode 100755 microservices/trader/entrypoint.sh create mode 100644 microservices/trader/requirements.txt diff --git a/microservices/.env b/microservices/.env index ddac212..03e4033 100644 --- a/microservices/.env +++ b/microservices/.env @@ -23,3 +23,13 @@ PXER_ADD_ARGS= COORD_LOG_FILE=%T.coordinator.log COORD_ADD_ARGS= + +BKPR_CREDS_FILE= +BKPR_LOG_FILE=%T.bookkeeper.log +BKPR_ADD_ARGS= + +RMGR_LOG_FILE=%T.riskmrg.log +RMGR_ADD_ARGS= + +QUANT_LOG_FILE=%T.quant.log +QUANT_ADD_ARGS= diff --git a/microservices/bookkeeper/.dockerignore b/microservices/bookkeeper/.dockerignore new file mode 100644 index 0000000..a4f7c14 --- /dev/null +++ b/microservices/bookkeeper/.dockerignore @@ -0,0 +1,3 @@ +.git +**/__pycache__ +.pipenv \ No newline at end of file diff --git a/microservices/bookkeeper/Dockerfile b/microservices/bookkeeper/Dockerfile new file mode 100644 index 0000000..c20dda4 --- /dev/null +++ b/microservices/bookkeeper/Dockerfile @@ -0,0 +1,25 @@ +FROM python:3.12-slim + +# libpq needed for Timescale +RUN apt-get update && apt-get install -y \ + apt-utils \ + libpq-dev \ + build-essential + + COPY requirements.txt / + +RUN pip install --upgrade pip --root-user-action=ignore +RUN pip install -r /requirements.txt --root-user-action=ignore + +COPY cvttpy /cvttpy + +RUN mkdir -p /logs /config + +SHELL ["/bin/bash", "-c"] + +ENV PYTHONPATH=/ + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/microservices/bookkeeper/entrypoint.sh b/microservices/bookkeeper/entrypoint.sh new file mode 100755 index 0000000..65638ed --- /dev/null +++ b/microservices/bookkeeper/entrypoint.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +LogDir=/logs + +Cmd="python3.12" +Cmd+=" cvttpy/apps/microservices/book_keeper/book_keeper.py" + +Cmd+=" --config=${CONFIG_FILE}" +Cmd+=" --log_file=${LogDir}/${BKPR_LOG_FILE}" +Cmd+=" --credentials_file=${BKPR_CREDS_FILE:-/config/.creds}" + + +Cmd+=" ${BKPR_ADD_ARGS}" +echo ${Cmd} +exec ${Cmd} + diff --git a/microservices/bookkeeper/requirements.txt b/microservices/bookkeeper/requirements.txt new file mode 100644 index 0000000..3bc6254 --- /dev/null +++ b/microservices/bookkeeper/requirements.txt @@ -0,0 +1,11 @@ +aiohttp>=3.7.4.post0 +nest-asyncio>=1.5.5 +hjson>=3.1.0 +sortedcontainers>=2.4.0 +redis>=5.0.8 +python-dateutil>=2.8.2 +types-python-dateutil>=2.8.19.6 +cryptography>=43.0.0 +PyJWT>=2.10.1 +psycopg>=3.2.1 +pandas>=1.5.3 diff --git a/microservices/build.sh b/microservices/build.sh index 95dc895..30e7db9 100755 --- a/microservices/build.sh +++ b/microservices/build.sh @@ -2,7 +2,15 @@ # --- Settings RegistryService=cloud21.cvtt.vpn:5500 -ValidImages=(md_gateway oe_gateway ac_gateway pricer coordinator) +ValidImages=(md_gateway) +ValidImages=(oe_gateway) +ValidImages=(ac_gateway) +ValidImages=(pricer) +ValidImages=(coordinator) +ValidImages=(bookkeeper) +ValidImages+=(risk_manager) +ValidImages+=(quant) +ValidImages+=(trader) BashFunctionCode=$(realpath $(dirname ${0}))/../dckr_bld_functions.sh # --- Settings diff --git a/microservices/docker-compose.yml b/microservices/docker-compose.yml index 0d8324e..83c7ba3 100644 --- a/microservices/docker-compose.yml +++ b/microservices/docker-compose.yml @@ -1,5 +1,46 @@ # CVTT Microservices services: + trader: + image: cloud21.cvtt.vpn:5500/trader:${CVTT_VERSION} + container_name: cvtt-trader + pull_policy: always + user: ${CVTT_USER:-1001:1001} + environment: + CONFIG_SERVICE: ${CONFIG_SERVICE:-cloud16.cvtt.vpn:6789} + CONFIG_COMM_SETTINGS: ${CONFIG_COMM_SETTINGS:-comm/pubsub/redis/docker_microservices} + CONFIG_FILE: ${CONFIG_FILE:-http://${CONFIG_SERVICE}/apps/cvtt_musvc} + TRDR_LOG_FILE: ${TRDR_LOG_FILE:-%T.trader.log} + TRDR_ADD_ARGS: ${TRDR_ADD_ARGS:-} + volumes: + - ./config:/config + - ./logs:/logs + depends_on: + - md_gateway + - oe_gateway + - quant + - bookkeeper + - risk_manager + - redis + + quant: + image: cloud21.cvtt.vpn:5500/quant:${CVTT_VERSION} + container_name: cvtt-quant + pull_policy: always + user: ${CVTT_USER:-1001:1001} + environment: + CONFIG_SERVICE: ${CONFIG_SERVICE:-cloud16.cvtt.vpn:6789} + CONFIG_COMM_SETTINGS: ${CONFIG_COMM_SETTINGS:-comm/pubsub/redis/docker_microservices} + CONFIG_FILE: ${CONFIG_FILE:-http://${CONFIG_SERVICE}/apps/cvtt_musvc} + QUANT_LOG_FILE: ${QUANT_LOG_FILE:-%T.quant.log} + QUANT_ADD_ARGS: ${QUANT_ADD_ARGS:-} + volumes: + - ./config:/config + - ./logs:/logs + depends_on: + - md_gateway + - bookkeeper + - redis + coordinator: image: cloud21.cvtt.vpn:5500/coordinator:${CVTT_VERSION} container_name: cvtt-coordinator @@ -18,7 +59,7 @@ services: - pricer # - quant # - trader - # - riskmgr + - risk_manager - redis pricer: @@ -30,8 +71,8 @@ services: CONFIG_SERVICE: ${CONFIG_SERVICE:-cloud16.cvtt.vpn:6789} CONFIG_COMM_SETTINGS: ${CONFIG_COMM_SETTINGS:-comm/pubsub/redis/docker_microservices} CONFIG_FILE: ${CONFIG_FILE:-http://${CONFIG_SERVICE}/apps/cvtt_musvc} - COORD_LOG_FILE: ${COORD_LOG_FILE:-%T.pricer.log} - COORD_ADD_ARGS: ${COORD_ADD_ARGS:-} + PXER_LOG_FILE: ${PXER_LOG_FILE:-%T.pricer.log} + PXER_ADD_ARGS: ${PXER_ADD_ARGS:-} volumes: - ./config:/config - ./logs:/logs @@ -39,6 +80,46 @@ services: - md_gateway - redis + risk_manager: + image: cloud21.cvtt.vpn:5500/risk_manager:${CVTT_VERSION} + container_name: cvtt-risk_manager + pull_policy: always + user: ${CVTT_USER:-1001:1001} + environment: + CONFIG_SERVICE: ${CONFIG_SERVICE:-cloud16.cvtt.vpn:6789} + CONFIG_COMM_SETTINGS: ${CONFIG_COMM_SETTINGS:-comm/pubsub/redis/docker_microservices} + CONFIG_FILE: ${CONFIG_FILE:-http://${CONFIG_SERVICE}/apps/cvtt_musvc} + RMGR_LOG_FILE: ${RMGR_LOG_FILE:-%T.riskmrg.log} + RMGR_ADD_ARGS: ${RMGR_ADD_ARGS:-} + volumes: + - ./config:/config + - ./logs:/logs + depends_on: + - md_gateway + - ac_gateway + - bookkeeper + - redis + + + bookkeeper: + image: cloud21.cvtt.vpn:5500/bookkeeper:${CVTT_VERSION} + container_name: cvtt-bookkeeper + pull_policy: always + user: ${CVTT_USER:-1001:1001} + environment: + CONFIG_SERVICE: ${CONFIG_SERVICE:-cloud16.cvtt.vpn:6789} + CONFIG_COMM_SETTINGS: ${CONFIG_COMM_SETTINGS:-comm/pubsub/redis/docker_microservices} + CONFIG_FILE: ${CONFIG_FILE:-http://${CONFIG_SERVICE}/apps/cvtt_musvc} + BKPR_LOG_FILE: ${BKPR_LOG_FILE:-%T.bookkeeper.log} + BKPR_ADD_ARGS: ${BKPR_ADD_ARGS:-} + volumes: + - ./config:/config + - ./logs:/logs + depends_on: + - ac_gateway + #- trader + - redis + md_gateway: image: cloud21.cvtt.vpn:5500/md_gateway:${CVTT_VERSION} container_name: md_gateway diff --git a/microservices/quant/.dockerignore b/microservices/quant/.dockerignore new file mode 100644 index 0000000..a4f7c14 --- /dev/null +++ b/microservices/quant/.dockerignore @@ -0,0 +1,3 @@ +.git +**/__pycache__ +.pipenv \ No newline at end of file diff --git a/microservices/quant/Dockerfile b/microservices/quant/Dockerfile new file mode 100644 index 0000000..33e3bc2 --- /dev/null +++ b/microservices/quant/Dockerfile @@ -0,0 +1,19 @@ +FROM python:3.12-slim + +COPY requirements.txt / + +RUN pip install --upgrade pip --root-user-action=ignore +RUN pip install -r /requirements.txt --root-user-action=ignore + +COPY cvttpy /cvttpy + +RUN mkdir -p /logs /config + +SHELL ["/bin/bash", "-c"] + +ENV PYTHONPATH=/ + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/microservices/quant/entrypoint.sh b/microservices/quant/entrypoint.sh new file mode 100755 index 0000000..7b402d9 --- /dev/null +++ b/microservices/quant/entrypoint.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +LogDir=/logs + +Cmd="python3.12" +Cmd+=" cvttpy/apps/microservices/quant/quant.py" + +Cmd+=" --config=${CONFIG_FILE:-/config/cvtt_musvc.cfg}" +Cmd+=" --log_file=${LogDir}/${QUANT_LOG_FILE}" + +Cmd+=" ${QUANT_ADD_ARGS}" +echo ${Cmd} +exec ${Cmd} + diff --git a/microservices/quant/requirements.txt b/microservices/quant/requirements.txt new file mode 100644 index 0000000..e840a84 --- /dev/null +++ b/microservices/quant/requirements.txt @@ -0,0 +1,9 @@ +aiohttp>=3.7.4.post0 +nest-asyncio>=1.5.5 +hjson>=3.1.0 +sortedcontainers>=2.4.0 +redis>=5.0.8 +python-dateutil>=2.8.2 +types-python-dateutil>=2.8.19.6 +cryptography>=43.0.0 +PyJWT>=2.10.1 diff --git a/microservices/risk_manager/.dockerignore b/microservices/risk_manager/.dockerignore new file mode 100644 index 0000000..a4f7c14 --- /dev/null +++ b/microservices/risk_manager/.dockerignore @@ -0,0 +1,3 @@ +.git +**/__pycache__ +.pipenv \ No newline at end of file diff --git a/microservices/risk_manager/Dockerfile b/microservices/risk_manager/Dockerfile new file mode 100644 index 0000000..33e3bc2 --- /dev/null +++ b/microservices/risk_manager/Dockerfile @@ -0,0 +1,19 @@ +FROM python:3.12-slim + +COPY requirements.txt / + +RUN pip install --upgrade pip --root-user-action=ignore +RUN pip install -r /requirements.txt --root-user-action=ignore + +COPY cvttpy /cvttpy + +RUN mkdir -p /logs /config + +SHELL ["/bin/bash", "-c"] + +ENV PYTHONPATH=/ + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/microservices/risk_manager/entrypoint.sh b/microservices/risk_manager/entrypoint.sh new file mode 100755 index 0000000..5c68875 --- /dev/null +++ b/microservices/risk_manager/entrypoint.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +LogDir=/logs + +Cmd="python3.12" +Cmd+=" cvttpy/apps/microservices/risk_manager/risk_manager.py" + +Cmd+=" --config=${CONFIG_FILE}" +Cmd+=" --log_file=${LogDir}/${RMGR_LOG_FILE}" + +Cmd+=" ${RMGR_ADD_ARGS}" +echo ${Cmd} +exec ${Cmd} + diff --git a/microservices/risk_manager/requirements.txt b/microservices/risk_manager/requirements.txt new file mode 100644 index 0000000..e840a84 --- /dev/null +++ b/microservices/risk_manager/requirements.txt @@ -0,0 +1,9 @@ +aiohttp>=3.7.4.post0 +nest-asyncio>=1.5.5 +hjson>=3.1.0 +sortedcontainers>=2.4.0 +redis>=5.0.8 +python-dateutil>=2.8.2 +types-python-dateutil>=2.8.19.6 +cryptography>=43.0.0 +PyJWT>=2.10.1 diff --git a/microservices/trader/.dockerignore b/microservices/trader/.dockerignore new file mode 100644 index 0000000..a4f7c14 --- /dev/null +++ b/microservices/trader/.dockerignore @@ -0,0 +1,3 @@ +.git +**/__pycache__ +.pipenv \ No newline at end of file diff --git a/microservices/trader/Dockerfile b/microservices/trader/Dockerfile new file mode 100644 index 0000000..33e3bc2 --- /dev/null +++ b/microservices/trader/Dockerfile @@ -0,0 +1,19 @@ +FROM python:3.12-slim + +COPY requirements.txt / + +RUN pip install --upgrade pip --root-user-action=ignore +RUN pip install -r /requirements.txt --root-user-action=ignore + +COPY cvttpy /cvttpy + +RUN mkdir -p /logs /config + +SHELL ["/bin/bash", "-c"] + +ENV PYTHONPATH=/ + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/microservices/trader/entrypoint.sh b/microservices/trader/entrypoint.sh new file mode 100755 index 0000000..872c3e7 --- /dev/null +++ b/microservices/trader/entrypoint.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +LogDir=/logs + +Cmd="python3.12" +Cmd+=" cvttpy/apps/microservices/trader/trader.py" + +Cmd+=" --config=${CONFIG_FILE:-/config/cvtt_musvc.cfg}" +Cmd+=" --log_file=${LogDir}/${TRDR_LOG_FILE}" + +Cmd+=" ${TRDR_ADD_ARGS}" +echo ${Cmd} +exec ${Cmd} + diff --git a/microservices/trader/requirements.txt b/microservices/trader/requirements.txt new file mode 100644 index 0000000..e840a84 --- /dev/null +++ b/microservices/trader/requirements.txt @@ -0,0 +1,9 @@ +aiohttp>=3.7.4.post0 +nest-asyncio>=1.5.5 +hjson>=3.1.0 +sortedcontainers>=2.4.0 +redis>=5.0.8 +python-dateutil>=2.8.2 +types-python-dateutil>=2.8.19.6 +cryptography>=43.0.0 +PyJWT>=2.10.1