blob: b76de4e33d15d113af9cc5bc0d084d4ae504d2bf [file] [log] [blame]
#!/usr/bin/env bash
# source colors
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "${dir}/colorizer-lib/colorizer.sh"
function run_apps(){
if [ "$UID" -ne 0 ]; then
colorize "<red>Please run as root</red>"
exit 1
fi
# TODO: make this use jq (this is dumb)
apps=( node python ruby go blog )
# make sure clean
/var/presentation/scripts/clean-docker --hard
# loop through apps
# run and publish
for app in "${apps[@]}"; do
local app_conf=$(cat ${dir}/apps.json | jq .[] | jq 'select(.publish == "'${app}'")')
local lang=$(echo ${app_conf} | jq --raw-output '.lang')
local port=$(echo ${app_conf} | jq '.port')
local name=$(echo ${app_conf} | jq --raw-output '.name')
local app_name=$(echo ${app_conf} | jq --raw-output '.publish')
colorize "Running <cyan>${app}</cyan> as <yellow>${name}</yellow>"
local container_id=$(docker run --name ${name} -p ${port} -d ${lang}/base)
local container_port=$(docker ps | grep ${name} | awk ' { print ( $(NF-1) ) }')
local clean_port=${container_port%-*}
/var/presentation/scripts/publish ${app_name} ${clean_port}
done
}
run_apps