# HG changeset patch # User smith@nwoca.org # Date 1507321495 -3600 # Node ID 4de5e1a4637caa64113ed28730b1ccaf0d250e01 # Parent df5822269cdb83231bbbe7f52ff6bca79a6a5e27 DEP-12: add training.yml and training.sh setup script for pilot training instances diff -r df5822269cdb -r 4de5e1a4637c pilot/training.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pilot/training.sh Fri Oct 06 21:24:55 2017 +0100 @@ -0,0 +1,115 @@ +#!/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 + +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 df5822269cdb -r 4de5e1a4637c pilot/training.yml --- a/pilot/training.yml Tue Sep 26 20:52:22 2017 +0100 +++ b/pilot/training.yml Fri Oct 06 21:24:55 2017 +0100 @@ -1,41 +1,70 @@ -usasdb: - restart: unless-stopped - image: docker.ssdt.io/trainingdb-usas - environment: - - DB_NAME=usasdb - - DB_USER=usas - - DB_PASS=usasdefault -usasapp: - restart: unless-stopped - image: docker.ssdt.io/usas-app:${USAS_TAG:-pilot} - volumes: - - ${PWD}/config:/config - environment: - - DB_HOST=usas-database - - DB_NAME=usasdb - - DB_USER=usas - - DB_PASS=usasdefault - - JAVA_OPTS=-Xmx640m - links: - - usasdb:usas-database -uspsdb: - restart: unless-stopped - image: docker.ssdt.io/trainingdb-usps - environment: - - DB_NAME=uspsdb - - DB_USER=usps - - DB_PASS=uspsdefault -uspsapp: - restart: unless-stopped - image: docker.ssdt.io/usps-app:${USPS_TAG:-pilot} - volumes: - - ${PWD}/config:/config - environment: - - DB_HOST=usps-database - - DB_NAME=uspsdb - - DB_USER=usps - - DB_PASS=uspsdefault - - JAVA_OPTS=-Xmx640m - links: - - uspsdb:usps-database - +# **** 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: + - 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: + - 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