mirror of
https://github.com/storytold/storyteller-ml.git
synced 2026-10-25 08:40:31 +00:00
55 lines
1.7 KiB
Bash
Executable File
55 lines
1.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
export PYTHONUNBUFFERED=1
|
|
export TMPDIR=/workspace/tmp
|
|
export APP="hallo"
|
|
DOCKER_IMAGE_VERSION_FILE="/workspace/${APP}/docker_image_version"
|
|
|
|
echo "Template version: ${TEMPLATE_VERSION}"
|
|
|
|
if [[ -e ${DOCKER_IMAGE_VERSION_FILE} ]]; then
|
|
EXISTING_VERSION=$(cat ${DOCKER_IMAGE_VERSION_FILE})
|
|
else
|
|
EXISTING_VERSION="0.0.0"
|
|
fi
|
|
|
|
rsync_with_progress() {
|
|
stdbuf -i0 -o0 -e0 rsync -au --info=progress2 "$@" | stdbuf -i0 -o0 -e0 tr '\r' '\n' | stdbuf -i0 -o0 -e0 grep -oP '\d+%|\d+.\d+[mMgG]' | tqdm --bar-format='{l_bar}{bar}' --total=100 --unit='%' > /dev/null
|
|
}
|
|
|
|
sync_apps() {
|
|
# Only sync if the DISABLE_SYNC environment variable is not set
|
|
if [ -z "${DISABLE_SYNC}" ]; then
|
|
# Sync application to workspace to support Network volumes
|
|
echo "Syncing ${APP} to workspace, please wait..."
|
|
rsync_with_progress --remove-source-files /${APP}/ /workspace/${APP}/
|
|
|
|
echo "${TEMPLATE_VERSION}" > ${DOCKER_IMAGE_VERSION_FILE}
|
|
fi
|
|
}
|
|
|
|
if [ "$(printf '%s\n' "$EXISTING_VERSION" "$TEMPLATE_VERSION" | sort -V | head -n 1)" = "$EXISTING_VERSION" ]; then
|
|
if [ "$EXISTING_VERSION" != "$TEMPLATE_VERSION" ]; then
|
|
sync_apps
|
|
|
|
# Create directories
|
|
mkdir -p /workspace/logs /workspace/tmp
|
|
else
|
|
echo "Existing version is the same as the template version, no syncing required."
|
|
fi
|
|
else
|
|
echo "Existing version is newer than the template version, not syncing!"
|
|
fi
|
|
|
|
if [[ ${DISABLE_AUTOLAUNCH} ]]
|
|
then
|
|
echo "Auto launching is disabled so the application will not be started automatically"
|
|
echo "You can launch it manually:"
|
|
echo ""
|
|
echo " /start_hallo.sh"
|
|
else
|
|
/start_hallo.sh
|
|
fi
|
|
|
|
echo "All services have been started"
|