Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f0a639940b | |||
| 3fec261a46 | |||
| 618a7eb0cf | |||
| 512f5ce14d | |||
| 9a3215524e |
+42
-8
@@ -6,6 +6,8 @@ declare -A git_repo_arr
|
|||||||
git_repo_arr[cvttpy]=git@cloud21.cvtt.vpn:/opt/store/git/cvttpy.git
|
git_repo_arr[cvttpy]=git@cloud21.cvtt.vpn:/opt/store/git/cvttpy.git
|
||||||
git_repo_arr[ops]=git@cloud21.cvtt.vpn:/opt/store/git/ops.git
|
git_repo_arr[ops]=git@cloud21.cvtt.vpn:/opt/store/git/ops.git
|
||||||
git_repo_arr[research]=git@cloud21.cvtt.vpn:/opt/store/git/research.git
|
git_repo_arr[research]=git@cloud21.cvtt.vpn:/opt/store/git/research.git
|
||||||
|
git_repo_arr[cvtt-rust]=git@cloud21.cvtt.vpn:/opt/store/git/cvtt2/cvtt-rust.git
|
||||||
|
git_repo_arr[docker_dev]=git@cloud21.cvtt.vpn:/opt/store/git/docker_dev.git
|
||||||
|
|
||||||
dist_root=/home/cvttdist/software/cvtt2
|
dist_root=/home/cvttdist/software/cvtt2
|
||||||
dist_user=cvttdist
|
dist_user=cvttdist
|
||||||
@@ -48,13 +50,29 @@ while getopts ":p:b:i" opt; do
|
|||||||
done
|
done
|
||||||
# ---------------- cmdline
|
# ---------------- cmdline
|
||||||
|
|
||||||
function confirm {
|
confirm() {
|
||||||
if [ "${interactive}" == "Y" ]; then
|
if [ "${interactive}" == "Y" ]; then
|
||||||
echo "--------------------------------"
|
echo "--------------------------------"
|
||||||
echo -n "Press <Enter> to continue" && read
|
echo -n "Press <Enter> to continue" && read
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rust_binaries() {
|
||||||
|
res=()
|
||||||
|
for binname in $(cargo metadata --no-deps --format-version 1 | jq -r '.packages[].targets[] | select(.kind | index("bin")) | .name'); do
|
||||||
|
res+=("${binname}")
|
||||||
|
done
|
||||||
|
echo "${res[@]}"
|
||||||
|
}
|
||||||
|
|
||||||
|
rust_libraries() {
|
||||||
|
res=()
|
||||||
|
for libname in $(cargo metadata --no-deps --format-version 1 | jq -r '.packages[].targets[] | select(.kind | index("lib")) | .name'); do
|
||||||
|
res+=("lib${libname}.rlib")
|
||||||
|
done
|
||||||
|
echo "${res[@]}"
|
||||||
|
}
|
||||||
|
|
||||||
if [ "${interactive}" == "Y" ]; then
|
if [ "${interactive}" == "Y" ]; then
|
||||||
echo -n "Enter project [${prj}]: "
|
echo -n "Enter project [${prj}]: "
|
||||||
read project
|
read project
|
||||||
@@ -149,6 +167,26 @@ cmd_arr+=("${Cmd}")
|
|||||||
Cmd="rm -rf .git"
|
Cmd="rm -rf .git"
|
||||||
cmd_arr+=("${Cmd}")
|
cmd_arr+=("${Cmd}")
|
||||||
|
|
||||||
|
SourceLoc=../${project}
|
||||||
|
if [ "${project}" == "cvtt-rust" ]; then
|
||||||
|
|
||||||
|
cmd_arr+=("cd ${prj_dir}")
|
||||||
|
|
||||||
|
release_dir=${prj_dir}/dist/${project}
|
||||||
|
|
||||||
|
cmd_arr+=("mkdir -p ${release_dir}")
|
||||||
|
cmd_arr+=("cp release_version.txt ${release_dir}")
|
||||||
|
|
||||||
|
jq_cmd="jq '.packages[] | select(.targets[].kind[] == \"bin\") | .name'"
|
||||||
|
apps=$(cargo metadata --no-deps --format-version 1 --manifest-path=${prj_dir}/Cargo.toml | eval $jq_cmd | uniq)
|
||||||
|
for app in ${apps[@]}; do
|
||||||
|
app=${app//\"/} # remove quotes
|
||||||
|
cmd_arr+=("cargo install --root ${release_dir} --path ${prj_dir}/apps/${app}")
|
||||||
|
done
|
||||||
|
|
||||||
|
SourceLoc=${release_dir}
|
||||||
|
fi
|
||||||
|
|
||||||
dist_path="${dist_root}/${project}/${release_version}"
|
dist_path="${dist_root}/${project}/${release_version}"
|
||||||
|
|
||||||
for dist_loc in ${dist_locations}; do
|
for dist_loc in ${dist_locations}; do
|
||||||
@@ -156,9 +194,9 @@ for dist_loc in ${dist_locations}; do
|
|||||||
dist_host=${dhp[0]}
|
dist_host=${dhp[0]}
|
||||||
dist_port=${dhp[1]}
|
dist_port=${dhp[1]}
|
||||||
Cmd="rsync -avzh"
|
Cmd="rsync -avzh"
|
||||||
Cmd="${Cmd} --rsync-path=\"mkdir -p ${dist_path} && rsync\""
|
Cmd="${Cmd} --rsync-path=\"mkdir -p ${dist_path}"
|
||||||
Cmd="${Cmd} -e \"ssh -p ${dist_ssh_port}\""
|
Cmd="${Cmd} && rsync\" -e \"ssh -p ${dist_ssh_port}\""
|
||||||
Cmd="${Cmd} ../${project} ${dist_user}@${dist_host}:${dist_path}/"
|
Cmd="${Cmd} $SourceLoc ${dist_user}@${dist_host}:${dist_path}/"
|
||||||
cmd_arr+=("${Cmd}")
|
cmd_arr+=("${Cmd}")
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -179,8 +217,4 @@ do
|
|||||||
pwd && echo ${cmd} && eval ${cmd}
|
pwd && echo ${cmd} && eval ${cmd}
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "PROJECT ${project} **** P U L L N E W T A G S F R O M o r i g i n ****"
|
|
||||||
echo "----"
|
|
||||||
echo "(cd ${project}; git pull --tags; git pushall)"
|
|
||||||
echo "----"
|
|
||||||
echo "$0 Done ${project} ${release_version}"
|
echo "$0 Done ${project} ${release_version}"
|
||||||
|
|||||||
Executable
+136
@@ -0,0 +1,136 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo -n "Usage: ${0} <RootDir>"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
# --- Settings
|
||||||
|
RootDir=${1}
|
||||||
|
if [ -z "${RootDir}" ] ; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
RegistryService=cloud21.cvtt.vpn:5500
|
||||||
|
RegistryProtocol=http
|
||||||
|
|
||||||
|
ConfigUrl=http://cloud23.cvtt.vpn:6789/admin/docker_images
|
||||||
|
|
||||||
|
|
||||||
|
ReleaseHost="cloud21.cvtt.vpn"
|
||||||
|
ReleasePort="22"
|
||||||
|
ReleaseUser="cvttdist"
|
||||||
|
ReleaseDir="/home/cvttdist/software/cvtt2"
|
||||||
|
|
||||||
|
DIMAGES_CONFIG=$(curl -s ${ConfigUrl} | ${HOME}/bin/hjson -j)
|
||||||
|
|
||||||
|
# RootDir=/home/oleg/prod
|
||||||
|
SetVersionScript=/home/oleg/prod/ops/scripts/set_version.sh
|
||||||
|
|
||||||
|
|
||||||
|
# --------------- D E B U G
|
||||||
|
|
||||||
|
mkdir -p ${RootDir}
|
||||||
|
|
||||||
|
build_docker_image() {
|
||||||
|
title=${1}
|
||||||
|
image_name=${2}
|
||||||
|
docker_dev=${3}
|
||||||
|
project=${4}
|
||||||
|
|
||||||
|
echo "Building ${title}..."
|
||||||
|
echo "ImageName=${image_name}"
|
||||||
|
echo "DockerDev=${docker_dev}"
|
||||||
|
echo "BasedOnDist=${project}"
|
||||||
|
|
||||||
|
# Get Latest DIST version
|
||||||
|
echo "Checking for latest version of ${project} on ${ReleaseUser}@${ReleaseHost}:${ReleaseDir}"
|
||||||
|
image_version=$(get_latest_dist_version ${project})
|
||||||
|
if [ -z "${image_version}" ]; then
|
||||||
|
echo "No latest version found for ${project}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Latest version is ${image_version}"
|
||||||
|
|
||||||
|
if image_exists "${image_name}" "${image_version}"; then
|
||||||
|
echo "Image $image_name:$image_version exists in the registry. Building is not required."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
echo "Image $image_name:$image_version does not exist in the registry."
|
||||||
|
echo "getting lastest version of ${project} on ${ReleaseUser}@${ReleaseHost}:${ReleaseDir}"
|
||||||
|
${SetVersionScript} ${project} ${image_version}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
image_exists() {
|
||||||
|
image_name=${1}
|
||||||
|
version=${2}
|
||||||
|
response=$(curl -s -o /dev/null -w "%{http_code}" "${RegistryProtocol}://${RegistryService}/v2/${image_name}/manifests/${version}" -H "Accept: application/vnd.docker.distribution.manifest.v2+json")
|
||||||
|
if [ "$response" -eq 200 ]; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
get_latest_dist_version() {
|
||||||
|
project=${1}
|
||||||
|
|
||||||
|
Version=$(ssh -q -p ${ReleasePort} ${ReleaseUser}@${ReleaseHost} "ls -tr ${ReleaseDir}/${project} | tail -1" )
|
||||||
|
echo "${Version}"
|
||||||
|
}
|
||||||
|
|
||||||
|
echo RootDir=${RootDir}
|
||||||
|
|
||||||
|
cd ${RootDir}
|
||||||
|
echo "Getting latest version of docker_dev"
|
||||||
|
Cmd="${SetVersionScript} docker_dev latest"
|
||||||
|
echo ${Cmd}
|
||||||
|
eval ${Cmd}
|
||||||
|
|
||||||
|
echo "${DIMAGES_CONFIG}" | jq -c 'to_entries[]' | while IFS= read -r item; do
|
||||||
|
# Extract key (name) and values
|
||||||
|
title=$(echo "$item" | jq -r '.key')
|
||||||
|
image_name=$(echo "$item" | jq -r '.value.image_name')
|
||||||
|
docker_dev=$(echo "$item" | jq -r '.value.docker_dev')
|
||||||
|
project=$(echo "$item" | jq -r '.value.based_on_dist')
|
||||||
|
build_docker_image "$title" "$image_name" "$docker_dev" "$project"
|
||||||
|
done
|
||||||
|
|
||||||
|
exit
|
||||||
|
#===============================================================================
|
||||||
|
#===============================================================================
|
||||||
|
|
||||||
|
DockerDir=$(realpath $(dirname ${0})/${AppPath})
|
||||||
|
|
||||||
|
AppName=$(basename ${AppPath})
|
||||||
|
|
||||||
|
ImageName=${AppName}
|
||||||
|
ImageDir=${HOME}/docker_images
|
||||||
|
mkdir -p ${ImageDir}
|
||||||
|
|
||||||
|
Version=$(cat ${RootDir}/cvttpy/release_version.txt | awk -F, '{print $1}')
|
||||||
|
|
||||||
|
cd ${RootDir}
|
||||||
|
|
||||||
|
Cmd="docker build -t ${ImageName} -t ${ImageName}:latest -t ${ImageName}:${Version} -f ${DockerDir}/Dockerfile ."
|
||||||
|
echo ${Cmd}
|
||||||
|
eval ${Cmd} || exit
|
||||||
|
|
||||||
|
Cmd="docker tag ${ImageName}:latest ${RegistryService}/${ImageName}:latest"
|
||||||
|
echo ${Cmd}
|
||||||
|
eval ${Cmd} || exit
|
||||||
|
|
||||||
|
Cmd="docker tag ${ImageName}:${Version} ${RegistryService}/${ImageName}:${Version}"
|
||||||
|
echo ${Cmd}
|
||||||
|
eval ${Cmd} || exit
|
||||||
|
|
||||||
|
Cmd="docker push ${RegistryService}/${ImageName}:latest"
|
||||||
|
echo ${Cmd}
|
||||||
|
eval ${Cmd} || exit
|
||||||
|
|
||||||
|
Cmd="docker push ${RegistryService}/${ImageName}:${Version}"
|
||||||
|
echo ${Cmd}
|
||||||
|
eval ${Cmd} || exit
|
||||||
|
|
||||||
|
|
||||||
+1
-1
@@ -1 +1 @@
|
|||||||
1.7.8,case insensitive to_check parameter host and services avalability check
|
1.8.3,changes to build scripts
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ usage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
RootDir="${HOME}/prod"
|
RootDir="${HOME}/prod"
|
||||||
# RootDir=/home/oleg/develop/cvtt2 ###### D E B U G
|
|
||||||
|
|
||||||
export PYTHONPATH=${RootDir}
|
export PYTHONPATH=${RootDir}
|
||||||
|
|
||||||
@@ -15,28 +14,33 @@ StatusChannel="MD-Status"
|
|||||||
Sender=${RootDir}/ops/utils/send_mmost.sh
|
Sender=${RootDir}/ops/utils/send_mmost.sh
|
||||||
|
|
||||||
# ----- For DEBUGGING
|
# ----- For DEBUGGING
|
||||||
# Sender=cat
|
# RootDir=/home/oleg/develop/cvtt2 ###### D E B U G
|
||||||
# StatusChannel=
|
# Sender=cat #### D E B U G
|
||||||
|
# StatusChannel= #### D E B U G
|
||||||
|
|
||||||
run_checklist() {
|
run_checklist() {
|
||||||
|
|
||||||
|
|
||||||
yr=$(date -d 'yesterday' '+%Y')
|
yr=$(date -d 'yesterday' '+%Y')
|
||||||
|
CheckSymbols="A/AAPL N/NVDA M/META"
|
||||||
declare -A Commands
|
declare -A Commands
|
||||||
Commands["homestore"]="ssh cvtt@homestore.cvtt.vpn ls -l /works/cvtt/md_archive/equity/alpaca_md/A/AAPL/${yr} | tail -3"
|
Commands["homestore"]=""
|
||||||
Commands["homestore"]+="; echo"
|
for sym in ${CheckSymbols}; do
|
||||||
Commands["homestore"]+="; ssh cvtt@homestore.cvtt.vpn ls -l /works/cvtt/md_archive/equity/alpaca_md/N/NVDA/${yr} | tail -3"
|
Commands["homestore"]+="ssh cvtt@homestore.cvtt.vpn ls -l /works/cvtt/md_archive/equity/alpaca_md/${yr}/${sym} | tail -3; "
|
||||||
|
done
|
||||||
|
Commands["homestore"]+="echo"
|
||||||
|
|
||||||
Commands["cloud21"]="ssh cvtt@cloud21.cvtt.vpn ls -l /opt/store/cvtt/md_archive/equity/alpaca_md/A/AAPL/${yr} | tail -3"
|
Commands["cloud21"]=""
|
||||||
Commands["cloud21"]+="; echo"
|
for sym in ${CheckSymbols}; do
|
||||||
Commands["cloud21"]+="; ssh cvtt@cloud21.cvtt.vpn ls -l /opt/store/cvtt/md_archive/equity/alpaca_md/N/NVDA/${yr} | tail -3"
|
Commands["cloud21"]+="ssh cvtt@cloud21.cvtt.vpn ls -l /opt/store/cvtt/md_archive/equity/alpaca_md/${yr}/${sym} | tail -3; "
|
||||||
|
done
|
||||||
|
Commands["cloud21"]+="echo"
|
||||||
|
|
||||||
Commands["gpushnik"]="ssh oleg@gpushnik.cvtt.vpn 'ls -l /opt/jupyter_gpu/data/eqty_md | tail -10'"
|
Commands["gpushnik"]="ssh oleg@gpushnik.cvtt.vpn 'ls -l /opt/jupyter_gpu/data/eqty_md | tail -10'"
|
||||||
|
|
||||||
for name in $(printf "%s\n" "${!Commands[@]}" | sort); do
|
for name in $(printf "%s\n" "${!Commands[@]}" | sort); do
|
||||||
Cmd=${Commands[${name}]}
|
|
||||||
echo "------- ${name}"
|
echo "------- ${name}"
|
||||||
|
Cmd=${Commands[${name}]}
|
||||||
echo ${Cmd}
|
echo ${Cmd}
|
||||||
eval ${Cmd}
|
eval ${Cmd}
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
# ----- Settings
|
# ----- Settings
|
||||||
LocalSoftwareDir=${HOME}/software/cvtt2
|
LocalSoftwareDir=${HOME}/software/cvtt2
|
||||||
|
|
||||||
ProdDir=${HOME}/prod
|
ProdDir=$(pwd)
|
||||||
|
|
||||||
ReleaseHosts=("cloud21.cvtt.vpn")
|
ReleaseHosts=("cloud21.cvtt.vpn")
|
||||||
ReleasePorts=("22")
|
ReleasePorts=("22")
|
||||||
@@ -77,9 +77,9 @@ rsync_load_version
|
|||||||
Location="${LocalSoftwareDir}/${Project}/${Version}/${Project}"
|
Location="${LocalSoftwareDir}/${Project}/${Version}/${Project}"
|
||||||
|
|
||||||
Cmd="cd ${ProdDir}"
|
Cmd="cd ${ProdDir}"
|
||||||
Cmd="${Cmd} && rm -rf ${Project}"
|
Cmd+=" && rm -rf ${Project}"
|
||||||
Cmd="${Cmd} && ln -snf ${Location} ${Project}"
|
Cmd+=" && ln -snf ${Location} ${Project}"
|
||||||
|
|
||||||
echo ${Cmd} && eval ${Cmd}
|
echo ${Cmd} && eval ${Cmd}
|
||||||
|
|
||||||
echo "Done: $0 $*"
|
echo "Done: $0 ${*}"
|
||||||
|
|||||||
Reference in New Issue
Block a user