This commit is contained in:
Oleg Sheynin 2024-08-11 00:17:54 -04:00
parent d915a0dfd4
commit 7f0d88287b
6 changed files with 117 additions and 8 deletions

View File

@ -30,19 +30,22 @@ cd ${RootDir}
Cmd="docker build -t ${ImageName} -t ${ImageName}:latest -t ${ImageName}:${Version} -f ${DockerDir}/Dockerfile ." Cmd="docker build -t ${ImageName} -t ${ImageName}:latest -t ${ImageName}:${Version} -f ${DockerDir}/Dockerfile ."
echo ${Cmd} echo ${Cmd}
eval ${Cmd} eval ${Cmd} || exit
Cmd="docker tag ${ImageName}:latest ${RegistryService}/${ImageName}:latest" Cmd="docker tag ${ImageName}:latest ${RegistryService}/${ImageName}:latest"
echo ${Cmd} echo ${Cmd}
eval ${Cmd} eval ${Cmd} || exit
Cmd="docker tag ${ImageName}:${Version} ${RegistryService}/${ImageName}:${Version}" Cmd="docker tag ${ImageName}:${Version} ${RegistryService}/${ImageName}:${Version}"
echo ${Cmd} echo ${Cmd}
eval ${Cmd} eval ${Cmd} || exit
Cmd="docker push ${RegistryService}/${ImageName}:latest" Cmd="docker push ${RegistryService}/${ImageName}:latest"
echo ${Cmd} echo ${Cmd}
eval ${Cmd} eval ${Cmd} || exit
Cmd="docker push ${RegistryService}/${ImageName}:${Version}"
echo ${Cmd}
eval ${Cmd} || exit

View File

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
echo "Script $0 does not work yet. Aborted" && exit
function usage { function usage {
echo "Usage: ${0} <app_path (e.g. market_data/md_recorder_monitor)> <version>" echo "Usage: ${0} <app_path (e.g. market_data/md_recorder_monitor)> <version>"
exit exit
@ -28,8 +30,13 @@ Version=$(cat ${RootDir}/cvttpy/release_version.txt | awk -F, '{print $1}')
cd ${RootDir} cd ${RootDir}
# Create and use a new builder instance # Create a new builder instance
Cmd="docker buildx create --use --name ${AppName}_builder" 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} echo ${Cmd}
eval ${Cmd} eval ${Cmd}
@ -38,7 +45,7 @@ Cmd="docker buildx inspect ${AppName}_builder --bootstrap"
echo ${Cmd} echo ${Cmd}
eval ${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" Cmd="docker buildx build --platform linux/amd64,linux/arm64 -t ${ImageName}:latest -t ${ImageName}:${Version} -f ${DockerDir}/Dockerfile . --push"
echo ${Cmd} echo ${Cmd}
eval ${Cmd} eval ${Cmd}

View File

@ -0,0 +1,7 @@
{
"__dummy__": null
, "ALPACA_SANDBOX": {
"api_key": "PKLZSLFZMFMN1R28K9HK"
, "secret_key": "SKbxwLWJNs4kpn618DgGaopN6x1xzKwLM4Z7aymA"
}
}

View File

@ -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" ]

View File

@ -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

View File

@ -0,0 +1,64 @@
#!/bin/bash
# runs in container
# runs on host to start container
usage() {
echo -n "Usage: $0 -c <config_server (dflt: cloud23.cvtt.vpn:6789)>"
echo -n " -e <active_exchanges (ALPACA_SNBOX)>"
echo -n " -a <admin_port (7220)>"
echo -n " -n <portal_name (MD_PORTAL_ALPACA)>"
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}