# HG changeset patch # User smith@nwoca.org # Date 1515545045 0 # Node ID 2ae65177f74e67ceda79364dd2ed9bb69b1905bb # Parent 3133ce0016039e72561eab24be5a253996733e4b DEP-14: copy pilot scripts to prod diff -r 3133ce001603 -r 2ae65177f74e prod/import-usas.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/prod/import-usas.sh Wed Jan 10 00:44:05 2018 +0000 @@ -0,0 +1,23 @@ +#!/bin/bash + +source "$( dirname "${BASH_SOURCE[0]}")/../scripts/.functions.sh" + +docker-compose stop usasapp usasdb +resetDbVolume usasdb +docker-compose rm -vf usasapp usasdb + +export IMP_IRN=${IMP_IRN} +export IMP_URL=${IMP_URL-ftp://username:password@nwoca.org} +export IMP_PATH=${IMP_PATH} + +[ -f "docker-compose.override.yml" ] && export OVERRIDE=" -f docker-compose.override.yml" +[ -f "docker-compose.usasimport.override.yml" ] && export OVERRIDE2=" -f docker-compose.usasimport.override.yml" +# +docker-compose -f docker-compose.yml -f ${SSDT_HOME}/pilot/import-usas.yml $OVERRIDE rm -f usasimport +# start import and wait for completion +docker-compose -f docker-compose.yml -f ${SSDT_HOME}/pilot/import-usas.yml $OVERRIDE $OVERRIDE2 up usasimport | tee usasimport.log +# remove temporary container +docker-compose -f docker-compose.yml -f ${SSDT_HOME}/pilot/import-usas.yml $OVERRIDE rm -f usasimport +# start application +docker-compose up -d usasapp + diff -r 3133ce001603 -r 2ae65177f74e prod/import-usas.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/prod/import-usas.yml Wed Jan 10 00:44:05 2018 +0000 @@ -0,0 +1,12 @@ +version: "3.3" +services: + usasimport: + image: docker.ssdt.io/usas-import:${USAS_TAG:-pilot} + command: -i ${IMP_IRN- } -u ${IMP_URL- } -r ${IMP_PATH- } + depends_on: + - usasdb + environment: + - DB_HOST=usasdb + - DB_NAME=usasdb + - DB_USER=usas + - DB_PASS=${USAS_DB_PASSWORD:-usasdefault} \ No newline at end of file diff -r 3133ce001603 -r 2ae65177f74e prod/import-usps.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/prod/import-usps.sh Wed Jan 10 00:44:05 2018 +0000 @@ -0,0 +1,23 @@ +#!/bin/bash + +source "$( dirname "${BASH_SOURCE[0]}")/../scripts/.functions.sh" + +docker-compose stop uspsapp uspsdb +resetDbVolume uspsdb +docker-compose rm -vf uspsapp uspsdb + +export IMP_IRN=${IMP_IRN} +export IMP_URL=${IMP_URL-ftp://username:password@nwoca.org} +export IMP_PATH=${IMP_PATH} +export IMP_ANON=${IMP_ANON:--a false} +export IMP_EM=${IMP_EM-} + +[ -f "docker-compose.override.yml" ] && export OVERRIDE=" -f docker-compose.override.yml" + +docker-compose -f docker-compose.yml -f ${SSDT_HOME}/pilot/import-usps.yml $OVERRIDE rm -f uspsimport +# start import and wait for completion +docker-compose -f docker-compose.yml -f ${SSDT_HOME}/pilot/import-usps.yml $OVERRIDE up uspsimport | tee uspsimport.log +# remove temporary container +docker-compose -f docker-compose.yml -f ${SSDT_HOME}/pilot/import-usps.yml $OVERRIDE rm -f uspsimport +# start application +docker-compose up -d uspsapp diff -r 3133ce001603 -r 2ae65177f74e prod/import-usps.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/prod/import-usps.yml Wed Jan 10 00:44:05 2018 +0000 @@ -0,0 +1,13 @@ +version: "3.3" +services: + uspsimport: + image: docker.ssdt.io/usps-import:${USPS_TAG:-pilot} + command: -i ${IMP_IRN- } -u ${IMP_URL- } -r ${IMP_PATH- } ${IMP_ANON- } ${IMP_EM- } + depends_on: + - uspsdb + environment: + - DB_HOST=uspsdb + - DB_NAME=uspsdb + - DB_USER=usps + - DB_PASS=${USPS_DB_PASSWORD:-uspsdefault} + \ No newline at end of file diff -r 3133ce001603 -r 2ae65177f74e prod/nginx-override.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/prod/nginx-override.yml Wed Jan 10 00:44:05 2018 +0000 @@ -0,0 +1,29 @@ +version: "3.3" +services: + usasapp: + networks: + - proxy + environment: + - APPLICATION_ADMIN_PASSWORD=test + - APPLICATION_ADMIN_RESET=true + - VIRTUAL_HOST=${COMPOSE_PROJECT_NAME}-usas.demo2.ssdt.io + - VIRTUAL_PORT=8080 + - LETSENCRYPT_HOST=${COMPOSE_PROJECT_NAME}-usas.demo2.ssdt.io + - LETSENCRYPT_EMAIL=smith@nwoca.org + - JAVA_OPTS=-Xmx840m + uspsapp: + networks: + - proxy + environment: + - APPLICATION_ADMIN_PASSWORD=test + - APPLICATION_ADMIN_RESET=true + - VIRTUAL_HOST=${COMPOSE_PROJECT_NAME}-usps.demo2.ssdt.io + - VIRTUAL_PORT=8080 + - LETSENCRYPT_HOST=${COMPOSE_PROJECT_NAME}-usps.demo2.ssdt.io + - LETSENCRYPT_EMAIL=smith@nwoca.org + - JAVA_OPTS=-Xmx840m +networks: + proxy: + external: + name: proxy_default + diff -r 3133ce001603 -r 2ae65177f74e prod/setup.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/prod/setup.sh Wed Jan 10 00:44:05 2018 +0000 @@ -0,0 +1,143 @@ +#!/bin/bash +# Sets up a new district project based on SSDT default configuration in the current working directory. +# +# Usage: +# +# /data/preview/sampletown $ /ssdt/compose2/preview/setup.sh [usas,usps...] +# +# Will create a docker-compose.yml and .env file with default settings. +# +# +source "$(dirname "${BASH_SOURCE[0]}")/../scripts/.functions.sh" + +md5calc() { + md5sum ${1} ; +} + +md5verify() { + md5sum -c --status ${1} ; +} + +genDBHash() { + echo $(date +%s%N | sha256sum | base64 | head -c 32 ; echo) +} + +base=$(dirname "${BASH_SOURCE[0]}") +default_name=$(basename $PWD) + +args="$1$2" + +usas="" +usps="" + +if [ "$args" == "" ] || [ -z "${args##*usas*}" ] +then + usas=1 +fi + +if [ "$args" == "" ] || [ -z "${args##*usps*}" ] +then + usps=1 +fi + +echo "Preparing '$(basename $PWD)' with default USxS configuration" + +touch .env +source .env + +if [ "$COMPOSE_PROJECT_NAME" == "" ] +then + read -e -p "Enter project name: <${default_name}> " answer + project_name=${answer:-$default_name} + echo "COMPOSE_PROJECT_NAME=${project_name}" >> .env + echo "set project name in .env file" + source .env +fi + +if [ ! -e "docker-compose.yml" ] +then + create="OK" +elif [ -e ".docker-compose.md5" ]; then + md5verify ./.docker-compose.md5 && create="OK" +fi + +if [ "$create" == "OK" ] +then + echo "# **** DO NOT MODIFY THIS FILE. ****" > ./docker-compose.yml + echo "# Place customizations in docker-compose.override.yml and .env" >> ./docker-compose.yml + echo "version: \"3.3\"" >> ./docker-compose.yml + echo "services:" >> ./docker-compose.yml + + [ ! "$usas" == "" ] && cat $base/usas-services.yml >> ./docker-compose.yml + echo "" >> ./docker-compose.yml + + [ ! "$usps" == "" ] && cat $base/usps-services.yml >> ./docker-compose.yml + echo "" >> ./docker-compose.yml + + echo "volumes:" >> ./docker-compose.yml + + if [ ! "$usas" == "" ] + then + echo " usasdata:" >> ./docker-compose.yml + [ "$USAS_DB_PASSWORD" == "" ] && echo "USAS_DB_PASSWORD=$(genDBHash)" >> ./.env + fi + + if [ ! "$usps" == "" ] + then + echo " uspsdata:" >> ./docker-compose.yml + [ "$USPS_DB_PASSWORD" == "" ] && echo "USPS_DB_PASSWORD=$(genDBHash)" >> ./.env + fi + + echo "" >> ./docker-compose.yml + + md5calc ./docker-compose.yml > .docker-compose.md5 + + echo "created docker-compose.yml" + +else + echo " + + Error! docker-compose.yml file has been modified or checksum missing. Can not auto-apply update(s). + Move customizations to docker-compose.override.yml then delete the docker-compose.yml +" +fi + +if [ ! -e "docker-compose.override.yml" ] +then + echo 'version: "3.3"' >> docker-compose.override.yml +fi + +if [ "$USAS_APPLICATIONID" == "" ] +then + read -e -p "Generate USAS and USPS integration config? " answer + case $answer in + y | Y | yes | YES ) answer="y";; + n | N | no | NO ) answer="n";; + *) answer="y" + esac + if [ "$answer" == "y" ] + then + usas_id=${COMPOSE_PROJECT_NAME}-usas + usas_key=$(openssl rand -hex 32) + usps_id=${COMPOSE_PROJECT_NAME}-usps + usps_key=$(openssl rand -hex 32) + echo "USAS_APPLICATIONID=${usas_id}" >> .env + echo "USAS_APIKEY=$usas_key" >> .env + echo "USPS_APPLICATIONID=${usps_id}" >> .env + echo "USPS_APIKEY=$usps_key" >> .env + echo "Created integration API keys. Enable integration modules after applications start" + fi +fi + +if [ "$USAS_APP_HOST" == "" ] +then + echo "USAS_APP_HOST=usasapp-svr" >> .env +fi + +if [ "$USPS_APP_HOST" == "" ] +then + echo "USPS_APP_HOST=uspsapp-svr" >> .env +fi + +echo "Review or create a docker-compose.override.yml for custom settings." + diff -r 3133ce001603 -r 2ae65177f74e prod/training.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/prod/training.sh Wed Jan 10 00:44:05 2018 +0000 @@ -0,0 +1,117 @@ +#!/bin/bash +# Sets up a new Training project based on SSDT default configuration in the current working directory. +# +# Usage: +# +# /data/preview/training-01 $ /ssdt/compose2/preview/training.sh +# +# Will create a docker-compose.yml and .env file with default settings using the SSDT +# supplied training database +# +# These are special database images which recreates the database each time the container is created. +# Therefore, it is very easy to reset the training database simply by deleting the +# project containers and restarting them. for example: +# +# docker-compose down +# docker-compose up -d +# +source "$(dirname "${BASH_SOURCE[0]}")/../scripts/.functions.sh" + +md5calc() { + md5sum ${1} ; +} + +md5verify() { + md5sum -c --status ${1} ; +} + +genDBHash() { + echo $(date +%s%N | sha256sum | base64 | head -c 32 ; echo) +} + +base=$(dirname "${BASH_SOURCE[0]}") +default_name=$(basename $PWD) + +args="$1$2" + +usas="" +usps="" + +if [ "$args" == "" ] || [ -z "${args##*usas*}" ] +then + usas=1 +fi + +if [ "$args" == "" ] || [ -z "${args##*usps*}" ] +then + usps=1 +fi + +echo "Preparing training project '$(basename $PWD)' with default USxS configuration" + +touch .env +source .env + +project_name=${default_name} + +if [ "$COMPOSE_PROJECT_NAME" == "" ] +then + echo "COMPOSE_PROJECT_NAME=${project_name}" >> .env + source .env +fi + +if [ ! -e "docker-compose.yml" ] +then + create="OK" +elif [ -e ".docker-compose.md5" ]; then + md5verify ./.docker-compose.md5 && create="OK" +fi + +if [ "$create" == "OK" ] +then + + cat $base/training.yml > ./docker-compose.yml + echo "" >> ./docker-compose.yml + + md5calc ./docker-compose.yml > .docker-compose.md5 + + echo "created docker-compose.yml for training instance ${project_name}" + +else + echo " + + Error! docker-compose.yml file has been modified or checksum missing. Can not auto-apply update(s). + Move customizations to docker-compose.override.yml then delete the docker-compose.yml +" +fi + +if [ ! -e "docker-compose.override.yml" ] +then + echo 'version: "3.3"' >> docker-compose.override.yml +fi + +if [ "$USAS_APPLICATIONID" == "" ] +then + usas_id=${COMPOSE_PROJECT_NAME}-usas + usas_key=$(openssl rand -hex 32) + usps_id=${COMPOSE_PROJECT_NAME}-usps + usps_key=$(openssl rand -hex 32) + echo "USAS_APPLICATIONID=${usas_id}" >> .env + echo "USAS_APIKEY=$usas_key" >> .env + echo "USPS_APPLICATIONID=${usps_id}" >> .env + echo "USPS_APIKEY=$usps_key" >> .env + echo "Created integration API keys. Enable integration modules after applications start" +fi + +if [ "$USAS_APP_HOST" == "" ] +then + echo "USAS_APP_HOST=usasapp-svr" >> .env +fi + +if [ "$USPS_APP_HOST" == "" ] +then + echo "USPS_APP_HOST=uspsapp-svr" >> .env +fi + +echo "Review or create docker-compose.override.yml for custom settings." + diff -r 3133ce001603 -r 2ae65177f74e prod/training.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/prod/training.yml Wed Jan 10 00:44:05 2018 +0000 @@ -0,0 +1,74 @@ +# **** DO NOT MODIFY THIS FILE. ****" +# Place customizations in docker-compose.override.yml and .env +version: "3.3" +services: + usasdb: + restart: unless-stopped + image: docker.ssdt.io/trainingdb-usas:pilot + networks: + - default + environment: + - DB_NAME=usasdb + - DB_USER=usas + - DB_PASS=${USAS_DB_PASSWORD:-usasdefault} + usasapp: + restart: unless-stopped + image: docker.ssdt.io/usas-app:${USAS_TAG:-pilot} + depends_on: + - usasdb + networks: + default: + aliases: + - ${USAS_APP_HOST:-usasapp-svr} + environment: + - APPLICATION_ADMIN_PASSWORD=training + - APPLICATION_ADMIN_RESET=true + - DB_HOST=usasdb + - DB_NAME=usasdb + - DB_USER=usas + - DB_PASS=${USAS_DB_PASSWORD:-usasdefault} + - DB_POOL_LEAKDETECTIONTHRESHOLD=300000 + - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_CLIENTHOST=${USPS_APP_HOST:-uspsapp-svr} + - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_CLIENTDNSLOOKUP=true + - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_SERVERHOST=0.0.0.0 + - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_SERVERHOSTDNSLOOKUP=false + - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_APPLICATIONID=${USAS_APPLICATIONID:- } + - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_APIKEY=${USAS_APIKEY:- } + - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_REMOTEAPPLICATIONID=${USPS_APPLICATIONID:- } + - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_REMOTEAPIKEY=${USPS_APIKEY:- } + - JAVA_OPTS=-Xmx840m + uspsdb: + restart: unless-stopped + image: docker.ssdt.io/trainingdb-usps:pilot + networks: + - default + environment: + - DB_NAME=uspsdb + - DB_USER=usps + - DB_PASS=${USPS_DB_PASSWORD:-uspsdefault} + uspsapp: + restart: unless-stopped + image: docker.ssdt.io/usps-app:${USPS_TAG:-pilot} + depends_on: + - uspsdb + networks: + default: + aliases: + - ${USPS_APP_HOST:-uspsapp-svr} + environment: + - APPLICATION_ADMIN_PASSWORD=training + - APPLICATION_ADMIN_RESET=true + - DB_HOST=uspsdb + - DB_NAME=uspsdb + - DB_USER=usps + - DB_PASS=${USPS_DB_PASSWORD:-uspsdefault} + - DB_POOL_LEAKDETECTIONTHRESHOLD=300000 + - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_CLIENTHOST=${USAS_APP_HOST:-usasapp-svr} + - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_CLIENTDNSLOOKUP=true + - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_SERVERHOST=0.0.0.0 + - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_SERVERHOSTDNSLOOKUP=false + - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_APPLICATIONID=${USPS_APPLICATIONID:- } + - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_APIKEY=${USPS_APIKEY:- } + - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_REMOTEAPPLICATIONID=${USAS_APPLICATIONID:- } + - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_REMOTEAPIKEY=${USAS_APIKEY:- } + - JAVA_OPTS=-Xmx840m diff -r 3133ce001603 -r 2ae65177f74e prod/usas-services.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/prod/usas-services.yml Wed Jan 10 00:44:05 2018 +0000 @@ -0,0 +1,34 @@ + usasdb: + restart: unless-stopped + image: docker.ssdt.io/ssdt-postgres:5 + volumes: + - usasdata:/var/lib/postgresql/data + networks: + - default + environment: + - DB_NAME=usasdb + - DB_USER=usas + - DB_PASS=${USAS_DB_PASSWORD:-usasdefault} + usasapp: + restart: unless-stopped + image: docker.ssdt.io/usas-app:${USAS_TAG:-pilot} + depends_on: + - usasdb + networks: + default: + aliases: + - ${USAS_APP_HOST:-usasapp-svr} + environment: + - DB_HOST=usasdb + - DB_NAME=usasdb + - DB_USER=usas + - DB_PASS=${USAS_DB_PASSWORD:-usasdefault} + - DB_POOL_LEAKDETECTIONTHRESHOLD=300000 + - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_CLIENTHOST=${USPS_APP_HOST:-uspsapp-svr} + - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_CLIENTDNSLOOKUP=true + - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_SERVERHOST=0.0.0.0 + - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_SERVERHOSTDNSLOOKUP=false + - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_APPLICATIONID=${USAS_APPLICATIONID:- } + - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_APIKEY=${USAS_APIKEY:- } + - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_REMOTEAPPLICATIONID=${USPS_APPLICATIONID:- } + - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_REMOTEAPIKEY=${USPS_APIKEY:- } diff -r 3133ce001603 -r 2ae65177f74e prod/usps-services.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/prod/usps-services.yml Wed Jan 10 00:44:05 2018 +0000 @@ -0,0 +1,34 @@ + uspsdb: + restart: unless-stopped + image: docker.ssdt.io/ssdt-postgres:5 + volumes: + - uspsdata:/var/lib/postgresql/data + networks: + - default + environment: + - DB_NAME=uspsdb + - DB_USER=usps + - DB_PASS=${USPS_DB_PASSWORD:-uspsdefault} + uspsapp: + restart: unless-stopped + image: docker.ssdt.io/usps-app:${USPS_TAG:-pilot} + depends_on: + - uspsdb + networks: + default: + aliases: + - ${USPS_APP_HOST:-uspsapp-svr} + environment: + - DB_HOST=uspsdb + - DB_NAME=uspsdb + - DB_USER=usps + - DB_PASS=${USPS_DB_PASSWORD:-uspsdefault} + - DB_POOL_LEAKDETECTIONTHRESHOLD=300000 + - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_CLIENTHOST=${USAS_APP_HOST:-usasapp-svr} + - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_CLIENTDNSLOOKUP=true + - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_SERVERHOST=0.0.0.0 + - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_SERVERHOSTDNSLOOKUP=false + - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_APPLICATIONID=${USPS_APPLICATIONID:- } + - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_APIKEY=${USPS_APIKEY:- } + - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_REMOTEAPPLICATIONID=${USAS_APPLICATIONID:- } + - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_REMOTEAPIKEY=${USAS_APIKEY:- }