diff --git a/docker/build-image b/docker/build-image index 8e6952e3..d27465c1 100755 --- a/docker/build-image +++ b/docker/build-image @@ -69,7 +69,7 @@ fi # if not specified, process all docker files if [ ${#DOCKERFILES[@]} -eq 0 ]; then - DOCKERFILES=($(find ${LOCATION} -maxdepth 1 -name "Dockerfile.*" -exec basename {} \;)) + DOCKERFILES=($(find ${LOCATION} -maxdepth 1 -name "Dockerfile.*")) fi # process dockerfiles one at a time @@ -78,9 +78,10 @@ for f in ${DOCKERFILES[@]}; do echo "Processing file '$f'" # extract remaining info from filename - basename=${f%.*} + filename=$(basename $f) + basename=${filename%.*} name=${basename:11} - arch=${f##*.} + arch=${filename##*.} platform="linux/${arch}" tag=${TAG_BASENAME}/${name}/${arch}:${VERSION_NAME} echo " name: '${name}'" @@ -88,8 +89,8 @@ for f in ${DOCKERFILES[@]}; do echo " tag: '${tag}'" # build the image - echo "docker build --platform ${platform} -f ${LOCATION}/${f} -t ${tag} ${LOCATION}" - 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 $f -t ${tag} ${LOCATION} # push image if requested build was successful if [ $? -eq 0 ] && [ "${PUSH_IMAGES}" = "1" ];then diff --git a/root/var/signalytic/clientapps/streamline/streamline-emr/configure b/root/var/signalytic/clientapps/streamline/streamline-emr/configure new file mode 100755 index 00000000..773379b3 --- /dev/null +++ b/root/var/signalytic/clientapps/streamline/streamline-emr/configure @@ -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." diff --git a/root/var/signalytic/clientapps/streamline/streamline-emr/entry b/root/var/signalytic/clientapps/streamline/streamline-emr/entry index 66237eb5..4bdd69ea 100755 --- a/root/var/signalytic/clientapps/streamline/streamline-emr/entry +++ b/root/var/signalytic/clientapps/streamline/streamline-emr/entry @@ -9,6 +9,9 @@ function cleanup { trap cleanup EXIT +# configure instances +${LOCATION}/configure + # start all instances ${LOCATION}/start diff --git a/root/var/signalytic/clientapps/streamline/streamline-emr/monitor b/root/var/signalytic/clientapps/streamline/streamline-emr/monitor index c061e371..b7e9ac94 100755 --- a/root/var/signalytic/clientapps/streamline/streamline-emr/monitor +++ b/root/var/signalytic/clientapps/streamline/streamline-emr/monitor @@ -15,7 +15,7 @@ for f in $(find ${LOCATION} -mindepth 2 -maxdepth 3 -name docker-compose.yml); d else echo "no services found" fi - fi + done popd > /dev/null done -echo "done." \ No newline at end of file +echo "done." diff --git a/root/var/signalytic/clientapps/streamline/streamline-emr/start b/root/var/signalytic/clientapps/streamline/streamline-emr/start index 2234c699..6095b061 100755 --- a/root/var/signalytic/clientapps/streamline/streamline-emr/start +++ b/root/var/signalytic/clientapps/streamline/streamline-emr/start @@ -4,8 +4,6 @@ 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 -ENV_TEMPLATE=${LOCATION}/template.env VERSION_FILE=${LOCATION}/version 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 instances=($(sed -n "s/INSTANCES=//p" ${CONF_FILE})) -ports=($(sed -n "s/APP_PORTS=//p" ${CONF_FILE})) for ((i=0;i<${#instances[@]};i++)); do # prepare directory and config files for instance instance=$(echo ${instances[$i]} | tr -d '"') - port=$(echo ${ports[$i]} | tr -d '"') echo - echo "configuring 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}/ + echo "starting instance $((i+1)) / ${#instances[@]}" - # start app 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 done -echo "done." \ No newline at end of file +echo "done."