From 7f0d88287b16cbf241f5c94676efb5b5b1aac3a7 Mon Sep 17 00:00:00 2001 From: Oleg Sheynin Date: Sun, 11 Aug 2024 00:17:54 -0400 Subject: [PATCH] progress --- build.sh | 13 ++++-- buildx.sh | 13 ++++-- market_data/md_portal/.creds | 7 +++ market_data/md_portal/Dockerfile | 23 +++++++++ market_data/md_portal/requirements.txt | 5 ++ market_data/md_portal/run_md_portal.sh | 64 ++++++++++++++++++++++++++ 6 files changed, 117 insertions(+), 8 deletions(-) create mode 100644 market_data/md_portal/.creds create mode 100644 market_data/md_portal/Dockerfile create mode 100644 market_data/md_portal/requirements.txt create mode 100755 market_data/md_portal/run_md_portal.sh diff --git a/build.sh b/build.sh index 2ee28e4..6a544d8 100755 --- a/build.sh +++ b/build.sh @@ -30,19 +30,22 @@ cd ${RootDir} Cmd="docker build -t ${ImageName} -t ${ImageName}:latest -t ${ImageName}:${Version} -f ${DockerDir}/Dockerfile ." echo ${Cmd} -eval ${Cmd} +eval ${Cmd} || exit Cmd="docker tag ${ImageName}:latest ${RegistryService}/${ImageName}:latest" echo ${Cmd} -eval ${Cmd} +eval ${Cmd} || exit Cmd="docker tag ${ImageName}:${Version} ${RegistryService}/${ImageName}:${Version}" echo ${Cmd} -eval ${Cmd} +eval ${Cmd} || exit Cmd="docker push ${RegistryService}/${ImageName}:latest" echo ${Cmd} -eval ${Cmd} - +eval ${Cmd} || exit + +Cmd="docker push ${RegistryService}/${ImageName}:${Version}" +echo ${Cmd} +eval ${Cmd} || exit diff --git a/buildx.sh b/buildx.sh index 982481a..afc818e 100755 --- a/buildx.sh +++ b/buildx.sh @@ -1,5 +1,7 @@ #!/bin/bash +echo "Script $0 does not work yet. Aborted" && exit + function usage { echo "Usage: ${0} " exit @@ -28,8 +30,13 @@ Version=$(cat ${RootDir}/cvttpy/release_version.txt | awk -F, '{print $1}') cd ${RootDir} -# Create and use a new builder instance -Cmd="docker buildx create --use --name ${AppName}_builder" +# Create a new builder instance +Cmd="docker buildx create --name ${AppName}_builder" +echo ${Cmd} +eval ${Cmd} || exit + +# Switch to the newly created builder +Cmd="docker buildx use ${AppName}_builder" echo ${Cmd} eval ${Cmd} @@ -38,7 +45,7 @@ Cmd="docker buildx inspect ${AppName}_builder --bootstrap" echo ${Cmd} eval ${Cmd} -# Build the image using buildx, tagging with both 'latest' and the version number +# Build the image using buildx, tagging with both 'latest' and the version number, and pushing directly Cmd="docker buildx build --platform linux/amd64,linux/arm64 -t ${ImageName}:latest -t ${ImageName}:${Version} -f ${DockerDir}/Dockerfile . --push" echo ${Cmd} eval ${Cmd} diff --git a/market_data/md_portal/.creds b/market_data/md_portal/.creds new file mode 100644 index 0000000..0a3b012 --- /dev/null +++ b/market_data/md_portal/.creds @@ -0,0 +1,7 @@ +{ + "__dummy__": null + , "ALPACA_SANDBOX": { + "api_key": "PKLZSLFZMFMN1R28K9HK" + , "secret_key": "SKbxwLWJNs4kpn618DgGaopN6x1xzKwLM4Z7aymA" + } +} diff --git a/market_data/md_portal/Dockerfile b/market_data/md_portal/Dockerfile new file mode 100644 index 0000000..79cd66d --- /dev/null +++ b/market_data/md_portal/Dockerfile @@ -0,0 +1,23 @@ +FROM python:3.10-slim + +ARG FROM_DIR=docker_dev/market_data/md_portal + +COPY ${FROM_DIR}/requirements.txt / +RUN pip install --upgrade pip --root-user-action=ignore +RUN pip install -r /requirements.txt --root-user-action=ignore + +COPY cvttpy /cvttpy +COPY ${FROM_DIR}/.creds /.creds + + +COPY ${FROM_DIR}/run_md_portal.sh /run_md_portal.sh +RUN chmod +x /run_md_portal.sh + +RUN mkdir /logs + + +WORKDIR / +SHELL ["/bin/bash", "-c"] +ENV PYTHONPATH=/ +ENTRYPOINT [ "/run_md_portal.sh" ] + diff --git a/market_data/md_portal/requirements.txt b/market_data/md_portal/requirements.txt new file mode 100644 index 0000000..0298656 --- /dev/null +++ b/market_data/md_portal/requirements.txt @@ -0,0 +1,5 @@ +aiohttp>=3.7.4.post0 +nest-asyncio>=1.5.5 +hjson>=3.1.0 +sortedcontainers>=2.4.0 +aioredis>=2.0.1 diff --git a/market_data/md_portal/run_md_portal.sh b/market_data/md_portal/run_md_portal.sh new file mode 100755 index 0000000..9946fa1 --- /dev/null +++ b/market_data/md_portal/run_md_portal.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +# runs in container + + + +# runs on host to start container +usage() { + echo -n "Usage: $0 -c " + echo -n " -e " + echo -n " -a " + echo -n " -n " + echo + exit 1 +} + + + +# ConfigServer=cloud16.cvtt.vpn +ConfigServer=cloud23.cvtt.vpn:6789 +ActiveExchanges=ALPACA_SNDBX +PortalName=MD_PORTAL_ALPACA +AdminPort=7220 + + +while getopts ":c:e:a:n:" opt; do + case ${opt} in + c ) + ConfigServer=$OPTARG + ;; + e ) + ActiveExchanges=$OPTARG + ;; + a ) + AdminPort=$OPTARG + ;; + n ) + PortalName=$OPTARG + ;; + \? ) + echo "Invalid option: -$OPTARG" >&2 + usage + ;; + : ) + echo "Option -$OPTARG requires an argument." >&2 + usage + ;; + esac +done + + +Cmd="python3.10" +Cmd="${Cmd} cvttpy/apps/md/md_portal.py" +Cmd="${Cmd} --config=http://${ConfigServer}/apps/md_recorder" +Cmd="${Cmd} --credentials_file=/.creds" +Cmd="${Cmd} --active_exchanges=${ActiveExchanges}" +Cmd="${Cmd} --portal_name=${PortalName}" +Cmd="${Cmd} --admin_port=${AdminPort}" +Cmd="${Cmd} --log_file=/logs/%T.${PortalName}.log" +# Cmd="${Cmd} --compress_log" +echo ${Cmd} +eval ${Cmd} + +