mirror of
https://gitlab.com/signalytic/client-external/streamline/streamline-emr.git
synced 2026-09-11 18:51:31 +00:00
bugfixes and cleanup from kenyaemr
- fix monitor script - fix to allow docker build-image script to run from outside folder - split instance configuration out of start script
This commit is contained in:
+6
-5
@@ -69,7 +69,7 @@ fi
|
|||||||
|
|
||||||
# if not specified, process all docker files
|
# if not specified, process all docker files
|
||||||
if [ ${#DOCKERFILES[@]} -eq 0 ]; then
|
if [ ${#DOCKERFILES[@]} -eq 0 ]; then
|
||||||
DOCKERFILES=($(find ${LOCATION} -maxdepth 1 -name "Dockerfile.*" -exec basename {} \;))
|
DOCKERFILES=($(find ${LOCATION} -maxdepth 1 -name "Dockerfile.*"))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# process dockerfiles one at a time
|
# process dockerfiles one at a time
|
||||||
@@ -78,9 +78,10 @@ for f in ${DOCKERFILES[@]}; do
|
|||||||
echo "Processing file '$f'"
|
echo "Processing file '$f'"
|
||||||
|
|
||||||
# extract remaining info from filename
|
# extract remaining info from filename
|
||||||
basename=${f%.*}
|
filename=$(basename $f)
|
||||||
|
basename=${filename%.*}
|
||||||
name=${basename:11}
|
name=${basename:11}
|
||||||
arch=${f##*.}
|
arch=${filename##*.}
|
||||||
platform="linux/${arch}"
|
platform="linux/${arch}"
|
||||||
tag=${TAG_BASENAME}/${name}/${arch}:${VERSION_NAME}
|
tag=${TAG_BASENAME}/${name}/${arch}:${VERSION_NAME}
|
||||||
echo " name: '${name}'"
|
echo " name: '${name}'"
|
||||||
@@ -88,8 +89,8 @@ for f in ${DOCKERFILES[@]}; do
|
|||||||
echo " tag: '${tag}'"
|
echo " tag: '${tag}'"
|
||||||
|
|
||||||
# build the image
|
# build the image
|
||||||
echo "docker build --platform ${platform} -f ${LOCATION}/${f} -t ${tag} ${LOCATION}"
|
echo "docker build --platform ${platform} -f $f -t ${tag} ${LOCATION}"
|
||||||
docker build --platform ${platform} -f ${LOCATION}/${f} -t ${tag} ${LOCATION}
|
docker build --platform ${platform} -f $f -t ${tag} ${LOCATION}
|
||||||
|
|
||||||
# push image if requested build was successful
|
# push image if requested build was successful
|
||||||
if [ $? -eq 0 ] && [ "${PUSH_IMAGES}" = "1" ];then
|
if [ $? -eq 0 ] && [ "${PUSH_IMAGES}" = "1" ];then
|
||||||
|
|||||||
+49
@@ -0,0 +1,49 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
LOCATION="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||||
|
|
||||||
|
CONF_FILE=${LOCATION}/instances.conf
|
||||||
|
INSTANCES_DIR=${LOCATION}/instances
|
||||||
|
COMPOSE_FILE=${LOCATION}/docker-compose.yml
|
||||||
|
SETUP_FILE=${LOCATION}/setup
|
||||||
|
ENV_TEMPLATE=${LOCATION}/template.env
|
||||||
|
VERSION_FILE=${LOCATION}/version
|
||||||
|
|
||||||
|
version=$(head -n 1 ${VERSION_FILE} 2>/dev/null)
|
||||||
|
if [ $? -ne 0 ];then
|
||||||
|
version="unknown version"
|
||||||
|
fi
|
||||||
|
echo "Configuring Kenya EMR: $version"
|
||||||
|
|
||||||
|
if [ ! -f "${CONF_FILE}" ]; then
|
||||||
|
echo "missing conf file: ${CONF_FILE}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "processing config file: ${CONF_FILE}"
|
||||||
|
|
||||||
|
# load instance names and port numbers from conf file
|
||||||
|
instances=($(sed -n "s/INSTANCES=//p" ${CONF_FILE}))
|
||||||
|
db_ports=($(sed -n "s/DB_PORTS=//p" ${CONF_FILE}))
|
||||||
|
http_ports=($(sed -n "s/HTTP_PORTS=//p" ${CONF_FILE}))
|
||||||
|
https_ports=($(sed -n "s/HTTPS_PORTS=//p" ${CONF_FILE}))
|
||||||
|
for ((i=0;i<${#instances[@]};i++)); do
|
||||||
|
|
||||||
|
# prepare directory and config files for instance
|
||||||
|
instance=$(echo ${instances[$i]} | tr -d '"')
|
||||||
|
db_port=$(echo ${db_ports[$i]} | tr -d '"')
|
||||||
|
http_port=$(echo ${http_ports[$i]} | tr -d '"')
|
||||||
|
https_port=$(echo ${https_ports[$i]} | tr -d '"')
|
||||||
|
echo
|
||||||
|
echo "configuring instance $((i+1)) / ${#instances[@]}"
|
||||||
|
echo " name: ${instance}"
|
||||||
|
echo " db_port: ${db_port}"
|
||||||
|
echo " http_port: ${http_port}"
|
||||||
|
echo " https_port: ${https_port}"
|
||||||
|
mkdir -p ${INSTANCES_DIR}/${instance}/data
|
||||||
|
sed -e "s/{{INSTANCE_NAME}}/${instance}/g" -e "s/{{INSTANCE_DB_PORT}}/${db_port}/g" -e "s/{{INSTANCE_HTTP_PORT}}/${http_port}/g" -e "s/{{INSTANCE_HTTPS_PORT}}/${https_port}/g" ${ENV_TEMPLATE} > ${INSTANCES_DIR}/${instance}/.env
|
||||||
|
cp ${COMPOSE_FILE} ${INSTANCES_DIR}/${instance}/
|
||||||
|
cp ${SETUP_FILE} ${INSTANCES_DIR}/${instance}/
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "done."
|
||||||
@@ -9,6 +9,9 @@ function cleanup {
|
|||||||
|
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
|
# configure instances
|
||||||
|
${LOCATION}/configure
|
||||||
|
|
||||||
# start all instances
|
# start all instances
|
||||||
${LOCATION}/start
|
${LOCATION}/start
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ for f in $(find ${LOCATION} -mindepth 2 -maxdepth 3 -name docker-compose.yml); d
|
|||||||
else
|
else
|
||||||
echo "no services found"
|
echo "no services found"
|
||||||
fi
|
fi
|
||||||
fi
|
done
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
done
|
done
|
||||||
echo "done."
|
echo "done."
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ LOCATION="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
|||||||
|
|
||||||
CONF_FILE=${LOCATION}/instances.conf
|
CONF_FILE=${LOCATION}/instances.conf
|
||||||
INSTANCES_DIR=${LOCATION}/instances
|
INSTANCES_DIR=${LOCATION}/instances
|
||||||
COMPOSE_FILE=${LOCATION}/docker-compose.yml
|
|
||||||
ENV_TEMPLATE=${LOCATION}/template.env
|
|
||||||
VERSION_FILE=${LOCATION}/version
|
VERSION_FILE=${LOCATION}/version
|
||||||
|
|
||||||
version=$(head -n 1 ${VERSION_FILE} 2>/dev/null)
|
version=$(head -n 1 ${VERSION_FILE} 2>/dev/null)
|
||||||
@@ -23,24 +21,21 @@ echo "processing config file: ${CONF_FILE}"
|
|||||||
|
|
||||||
# load instance names and port numbers from conf file
|
# load instance names and port numbers from conf file
|
||||||
instances=($(sed -n "s/INSTANCES=//p" ${CONF_FILE}))
|
instances=($(sed -n "s/INSTANCES=//p" ${CONF_FILE}))
|
||||||
ports=($(sed -n "s/APP_PORTS=//p" ${CONF_FILE}))
|
|
||||||
for ((i=0;i<${#instances[@]};i++)); do
|
for ((i=0;i<${#instances[@]};i++)); do
|
||||||
|
|
||||||
# prepare directory and config files for instance
|
# prepare directory and config files for instance
|
||||||
instance=$(echo ${instances[$i]} | tr -d '"')
|
instance=$(echo ${instances[$i]} | tr -d '"')
|
||||||
port=$(echo ${ports[$i]} | tr -d '"')
|
|
||||||
echo
|
echo
|
||||||
echo "configuring instance $((i+1)) / ${#instances[@]}"
|
echo "starting instance $((i+1)) / ${#instances[@]}"
|
||||||
echo " name: ${instance}"
|
|
||||||
echo " port: ${port}"
|
|
||||||
mkdir -p ${INSTANCES_DIR}/${instance}/data
|
|
||||||
sed -e "s/{{INSTANCE_NAME}}/${instance}/g" -e "s/{{INSTANCE_PORT}}/${port}/g" ${ENV_TEMPLATE} > ${INSTANCES_DIR}/${instance}/.env
|
|
||||||
cp ${COMPOSE_FILE} ${INSTANCES_DIR}/${instance}/
|
|
||||||
|
|
||||||
# start app
|
|
||||||
pushd ${INSTANCES_DIR}/${instance} > /dev/null
|
pushd ${INSTANCES_DIR}/${instance} > /dev/null
|
||||||
docker compose up -d --force-recreate
|
|
||||||
|
# setup instance
|
||||||
|
${INSTANCES_DIR}/${instance}/setup
|
||||||
|
|
||||||
|
# start app
|
||||||
|
docker compose up -d --force-recreate
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "done."
|
echo "done."
|
||||||
|
|||||||
Reference in New Issue
Block a user