changeset 136:72f15ffc9ad2

DEP-12: convert compose files to 3.1. remove template. update bash script to create composite docker-files without extends. prevent overwriting manual changes to docker-comose.yml
author smith@nwoca.org
date Mon, 15 May 2017 23:07:10 +0100
parents 03e39b95d904
children 923c2b21fac7
files compose3/preview/import-usas.yml compose3/preview/import-usps.yml compose3/preview/setup.sh compose3/preview/usas-services.yml compose3/preview/usps-services.yml compose3/preview/usxs-services.yml compose3/preview/usxs-template.yml
diffstat 7 files changed, 126 insertions(+), 121 deletions(-) [+]
line wrap: on
line diff
--- a/compose3/preview/import-usas.yml	Mon May 15 21:33:24 2017 +0100
+++ b/compose3/preview/import-usas.yml	Mon May 15 23:07:10 2017 +0100
@@ -1,6 +1,12 @@
 version: "3.1"
 services:
   usasimport:
-    extends:
-     file: /ssdt/compose2/preview/usxs-services.yml
-     service: usasimport-base
+    image: docker.ssdt.io/usas-import:preview
+    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
--- a/compose3/preview/import-usps.yml	Mon May 15 21:33:24 2017 +0100
+++ b/compose3/preview/import-usps.yml	Mon May 15 23:07:10 2017 +0100
@@ -1,6 +1,13 @@
 version: "3.1"
 services:
   uspsimport:
-    extends:
-     file: /ssdt/compose2/preview/usxs-services.yml
-     service: uspsimport-base
+    image: docker.ssdt.io/usps-import:preview
+    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
--- a/compose3/preview/setup.sh	Mon May 15 21:33:24 2017 +0100
+++ b/compose3/preview/setup.sh	Mon May 15 23:07:10 2017 +0100
@@ -12,13 +12,21 @@
 # 
 source "$(dirname "${BASH_SOURCE[0]}")/../../scripts/.functions.sh"
 
+md5calc() {
+   md5sum ${1} ;
+}
+
+md5verify() {
+   md5sum -c --status ${1} ;
+}
+
 base=$(dirname "${BASH_SOURCE[0]}")
 default_name=$(basename $PWD)
 
 args="$1$2"
 
-usas=0
-usps=0
+usas=""
+usps=""
 
 if [ "$args" == "" ] || [ -z "${args##*usas*}" ]
 then
@@ -30,11 +38,6 @@
    usps=1
 fi
 
-echo "args: $args usas: $usas usps: $usps"
-
-exit 
-
-
 echo "Preparing '$(basename $PWD)' with default USxS configuration" 
 
 touch .env
@@ -49,11 +52,41 @@
    source .env
 fi
 
-if [ ! -e "docker-compose.yml" ] ; then
-    cp $base/usxs-template.yml ./docker-compose.yml
-    echo "created default docker-compose.yml"
+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 "version: \"3.1\""     > ./docker-compose.yml
+    echo "services:"            >> ./docker-compose.yml
+
+    [ ! "$usas" == "" ] &&  cat $base/usas-services.yml >> ./docker-compose.yml
+
+    [ ! "$usps" == "" ] &&  cat $base/usps-services.yml >> ./docker-compose.yml
+
+    echo "volumes:" >> ./docker-compose.yml
+
+    [ ! "$usas" == "" ] &&  echo "  usasdata:" >> ./docker-compose.yml
+    [ ! "$usps" == "" ] &&  echo "  uspsdata:" >> ./docker-compose.yml
+
+    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 auto-apply update(s).
+           Move customizations to docker-compose.override.yml then delete the docker-compose.yml
+"
+fi
+   
 if [ "$USAS_APPLICATIONID" == "" ]
 then
    read -e -p "Generate USAS and USPS integration config? <Y/n> " answer
@@ -72,9 +105,9 @@
      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 startup"
+     echo "Created integration API keys.  Enable integration modules after applications start"
    fi
 fi
 
-echo "project '$COMPOSE_PROJECT_NAME' ready with default values.  Review or create a docker-compose.override.yml for custom settings."
+echo "Review or create a docker-compose.override.yml for custom settings."
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/compose3/preview/usas-services.yml	Mon May 15 23:07:10 2017 +0100
@@ -0,0 +1,31 @@
+  usasdb:
+    restart: unless-stopped
+    image: docker.ssdt.io/ssdt-postgres:4
+    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:preview
+    depends_on:
+      - usasdb
+    networks:
+      - default
+    environment:
+      - DB_HOST=usasdb
+      - DB_NAME=usasdb
+      - DB_USER=usas
+      - DB_PASS=${USAS_DB_PASSWORD:-usasdefault}
+      - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_CLIENTHOST=uspsapp
+      - 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:- }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/compose3/preview/usps-services.yml	Mon May 15 23:07:10 2017 +0100
@@ -0,0 +1,31 @@
+  uspsdb:
+    restart: unless-stopped
+    image: docker.ssdt.io/ssdt-postgres:4
+    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:preview
+    depends_on:
+      - uspsdb
+    networks:
+      - default
+    environment:
+      - DB_HOST=uspsdb
+      - DB_NAME=uspsdb
+      - DB_USER=usps
+      - DB_PASS=${USPS_DB_PASSWORD:-uspsdefault}
+      - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_CLIENTHOST=usasapp
+      - 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:- }
--- a/compose3/preview/usxs-services.yml	Mon May 15 21:33:24 2017 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-# base compose file for USxS Preview releases
-version: "3.1"
-services:
-  usasdb-base:
-    restart: unless-stopped
-    image: docker.ssdt.io/ssdt-postgres:4
-    volumes:
-      - usasdata:/var/lib/postgresql/data
-    networks:
-      - default
-    environment:
-      - DB_NAME=usasdb
-      - DB_USER=usas
-      - DB_PASS=${USAS_DB_PASSWORD:-usasdefault}
-  usasapp-base:
-    restart: unless-stopped
-    image: docker.ssdt.io/usas-app:preview
-    networks:
-      - default
-    environment:
-      - DB_HOST=usasdb
-      - DB_NAME=usasdb
-      - DB_USER=usas
-      - DB_PASS=${USAS_DB_PASSWORD:-usasdefault}
-      - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_CLIENTHOST=uspsapp
-      - 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:- }
-  usasimport-base:
-    image: docker.ssdt.io/usas-import:preview
-    command: -i ${IMP_IRN- } -u ${IMP_URL- } -r ${IMP_PATH- }
-    environment:
-      - DB_HOST=usasdb
-      - DB_NAME=usasdb
-      - DB_USER=usas
-      - DB_PASS=${USAS_DB_PASSWORD:-usasdefault}
-  uspsdb-base:
-    restart: unless-stopped
-    image: docker.ssdt.io/ssdt-postgres:4
-    volumes:
-      - uspsdata:/var/lib/postgresql/data
-    networks:
-      - default
-    environment:
-      - DB_NAME=uspsdb
-      - DB_USER=usps
-      - DB_PASS=${USPS_DB_PASSWORD:-uspsdefault}
-  uspsapp-base:
-    restart: unless-stopped
-    image: docker.ssdt.io/usps-app:preview
-    networks:
-      - default
-    environment:
-      - DB_HOST=uspsdb
-      - DB_NAME=uspsdb
-      - DB_USER=usps
-      - DB_PASS=${USPS_DB_PASSWORD:-uspsdefault}
-      - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_CLIENTHOST=usasapp
-      - 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:- }
-  uspsimport-base:
-    image: docker.ssdt.io/usps-import:preview
-    command: -i ${IMP_IRN- } -u ${IMP_URL- } -r ${IMP_PATH- } ${IMP_ANON- } ${IMP_EM- }
-    environment:
-      - DB_HOST=uspsdb
-      - DB_NAME=uspsdb
-      - DB_USER=usps
-      - DB_PASS=${USPS_DB_PASSWORD:-uspsdefault}
-      
\ No newline at end of file
--- a/compose3/preview/usxs-template.yml	Mon May 15 21:33:24 2017 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-version: "3.1"
-services:
-  usasdb:
-    extends:
-      file: /ssdt/compose2/preview/usxs-services.yml
-      service: usasdb-base
-  usasapp:
-    extends:
-       file: /ssdt/compose2/preview/usxs-services.yml
-       service: usasapp-base
-    depends_on:
-      - usasdb
-  uspsdb:
-    extends:
-      file: /ssdt/compose2/preview/usxs-services.yml
-      service: uspsdb-base
-  uspsapp:
-    extends:
-       file: /ssdt/compose2/preview/usxs-services.yml
-       service: uspsapp-base
-    depends_on:
-      - uspsdb
-volumes:
-  usasdata:
-  uspsdata:
\ No newline at end of file