.
This commit is contained in:
Executable
+74
@@ -0,0 +1,74 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "Script $0 does not work yet. Aborted" && exit
|
||||
|
||||
function usage {
|
||||
echo "Usage: ${0} <app_path (e.g. market_data/md_recorder_monitor)> <version>"
|
||||
exit
|
||||
}
|
||||
|
||||
AppPath=${1}
|
||||
CvttpyVersion=${2}
|
||||
|
||||
if [ "${AppPath}" == "" ]
|
||||
then
|
||||
usage
|
||||
fi
|
||||
|
||||
# --- Settings
|
||||
DockerDir=$(realpath $(dirname ${0})/${AppPath})
|
||||
RootDir=$(realpath $(dirname ${0})/..)
|
||||
RegistryService=cloud21.cvtt.vpn:5500
|
||||
|
||||
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}
|
||||
|
||||
# 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}
|
||||
|
||||
# Ensure buildx is bootstrapped
|
||||
Cmd="docker buildx inspect ${AppName}_builder --bootstrap"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
|
||||
# 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}
|
||||
|
||||
# Tagging the images with the registry
|
||||
Cmd="docker tag ${ImageName}:latest ${RegistryService}/${ImageName}:latest"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
|
||||
Cmd="docker tag ${ImageName}:${Version} ${RegistryService}/${ImageName}:${Version}"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
|
||||
# Push the images to the registry
|
||||
Cmd="docker push ${RegistryService}/${ImageName}:latest"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
|
||||
Cmd="docker push ${RegistryService}/${ImageName}:${Version}"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
|
||||
# Optionally, remove the builder to clean up
|
||||
Cmd="docker buildx rm ${AppName}_builder"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
Reference in New Issue
Block a user