Mercurial > public > ssdt-docker
changeset 85:8f45c43ea7a4 feature/djs-DEP-12-docker
DEP-12: start upgrading scripts and compose files for RC and docker 1.12
author | Dave Smith <smith@nwoca.org> |
---|---|
date | Wed, 21 Sep 2016 19:00:41 -0400 |
parents | 36d4c33e43a3 |
children | bd1f900972ed |
files | .hgignore compose/rc/import.yml compose/rc/training.yml compose/rc/usas-template.yml compose/rc/usas.yml compose/rc/usps.yml init.sh scripts/.functions.sh scripts/capture.sh scripts/console.sh scripts/info.sh scripts/send.sh |
diffstat | 12 files changed, 359 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Wed Sep 21 19:00:11 2016 -0400 +++ b/.hgignore Wed Sep 21 19:00:41 2016 -0400 @@ -1,5 +1,5 @@ syntax: regexp -^\.DS_Store +\.DS_Store .*~$ \.orig$ \.orig\..*$
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/compose/rc/import.yml Wed Sep 21 19:00:41 2016 -0400 @@ -0,0 +1,222 @@ +uspsimport: + image: docker.ssdt.io/usps-import:preview + command: -i ${IMP_IRN} -u ${IMP_URL} -r ${IMP_PATH} ${IMP_ANON} ${IMP_EM} + links: + - uspsdb:database + environment: + - DB_HOST=database + - DB_NAME=$${DATABASE_ENV_DB_NAME} + - DB_USER=$${DATABASE_ENV_DB_USER} + - DB_PASS=$${DATABASE_ENV_DB_PASS} +usasimport: + image: docker.ssdt.io/usas-import:preview + command: -i ${IMP_IRN} -u ${IMP_URL} -r ${IMP_PATH} ${IMP_ANON} ${IMP_EM} + links: + - usasdb:database + environment: + - DB_HOST=database + - DB_NAME=$${DATABASE_ENV_DB_NAME} + - DB_USER=$${DATABASE_ENV_DB_USER} + - DB_PASS=$${DATABASE_ENV_DB_PASS} +diff -r 5fae3adac2af compose/rc/usas.template.yml +--- /dev/null Thu Jan 01 00:00:00 1970 +0000 ++++ b/compose/rc/usas.template.yml Wed Sep 21 21:04:33 2016 +0000 +@@ -0,0 +1,12 @@ ++version: "2" ++services: ++ usasdb: ++ extends: ++ file: /ssdt/compose/preview/usas.yml ++ service: usasdb ++ volumes: ++ - |volumeName|:/var/lib/postgresql/data ++ usasapp: ++ extends: ++ file: /ssdt/compose/preview/usas.yml ++ service: usasapp +diff -r 5fae3adac2af compose/rc/usas.yml +--- /dev/null Thu Jan 01 00:00:00 1970 +0000 ++++ b/compose/rc/usas.yml Wed Sep 21 21:04:33 2016 +0000 +@@ -0,0 +1,25 @@ ++# base compose file for USAS Release Candidate release ++version: "2" ++services: ++ usasdb: ++ restart: unless-stopped ++ image: docker.ssdt.io/ssdt-postgres:3 ++ volumes: ++ - ${PWD}/backup:/backup ++ environment: ++ - DB_NAME=usasdb ++ - DB_USER=usas ++ - DB_PASS=usasdefault ++ usasapp: ++ restart: unless-stopped ++ image: docker.ssdt.io/usas-app:preview ++ volumes: ++ - ${PWD}/config:/config ++ environment: ++ - DB_HOST=usasdb ++ - DB_NAME=usasdb ++ - DB_USER=usas ++ - DB_PASS=usasdefault ++ - ORG_SSDT_OHIO_USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_SERVERHOST=uspsapp ++ - ORG_SSDT_OHIO_USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_SERVERDNSLOOKUP=true ++ +diff -r 5fae3adac2af compose/rc/usps.template.yml +--- /dev/null Thu Jan 01 00:00:00 1970 +0000 ++++ b/compose/rc/usps.template.yml Wed Sep 21 21:04:33 2016 +0000 +@@ -0,0 +1,12 @@ ++uspsdb: ++ extends: ++ file: /ssdt/compose/preview/usps.yml ++ service: uspsdb ++ volumes: ++ - |volumeName|:/var/lib/postgresql/data ++uspsapp: ++ extends: ++ file: /ssdt/compose/preview/usps.yml ++ service: uspsapp ++ links: ++ - uspsdb:database +diff -r 5fae3adac2af compose/rc/usps.yml +--- /dev/null Thu Jan 01 00:00:00 1970 +0000 ++++ b/compose/rc/usps.yml Wed Sep 21 21:04:33 2016 +0000 +@@ -0,0 +1,24 @@ ++# base compose file for usps Release Candidate release ++version: "2" ++services: ++ uspsdb: ++ restart: unless-stopped ++ image: docker.ssdt.io/ssdt-postgres:3 ++ volumes: ++ - ${PWD}/backup:/backup ++ environment: ++ - DB_NAME=uspsdb ++ - DB_USER=usps ++ - DB_PASS=uspsdefault ++ uspsapp: ++ restart: unless-stopped ++ image: docker.ssdt.io/usps-app:preview ++ volumes: ++ - ${PWD}/config:/config ++ environment: ++ - DB_HOST=uspsdb ++ - DB_NAME=uspsdb ++ - DB_USER=usps ++ - DB_PASS=uspsdefault ++ - ORG_SSDT_OHIO_USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_SERVERHOST=usasapp ++ - ORG_SSDT_OHIO_USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_SERVERDNSLOOKUP=true +diff -r 5fae3adac2af init.sh +--- a/init.sh Tue Aug 30 16:37:52 2016 +0100 ++++ b/init.sh Wed Sep 21 21:04:33 2016 +0000 +@@ -1,3 +1,5 @@ + #!/bin/bash +-alias utils='docker run -it -v ${PWD}:/tmp -v /ssdt:/ssdt --rm docker.ssdt.io/ssdt-utils' +-alias send2ssdt='/ssdt/scripts/send.sh' +\ No newline at end of file ++source "$( dirname "${BASH_SOURCE[0]}")/scripts/.functions.sh" ++alias utils='docker run -it -v ${PWD}:/tmp -v $SSDT_HOME:/ssdt --rm docker.ssdt.io/ssdt-utils' ++alias send2ssdt='/ssdt/scripts/send.sh' ++export PATH=$PATH:$SSDT_HOME/scripts +diff -r 5fae3adac2af scripts/.functions.sh +--- a/scripts/.functions.sh Tue Aug 30 16:37:52 2016 +0100 ++++ b/scripts/.functions.sh Wed Sep 21 21:04:33 2016 +0000 +@@ -1,5 +1,8 @@ + #!/bin/bash + ++export SSDT_SCRIPTS=$(dirname "${BASH_SOURCE[0]}") ++export SSDT_HOME=$(dirname $SSDT_SCRIPTS) ++ + # deletes psql data from specified service + resetDbVolume() { + # Works for named and unnamed volumes and custom $PGDATA. +@@ -26,4 +29,11 @@ + container=$(composeGetContainer $service) + + echo "$2" | docker exec -i $container sh -c "gosu postgres psql \$DB_NAME" +-} +\ No newline at end of file ++} ++ ++composeGetProject() { ++ service=${1?"Must supply service from current project"} ++ container=$(composeGetContainer $service) ++ echo $(docker inspect -f '{{index .Config.Labels "com.docker.compose.project" }}' $container) ++ ++} +diff -r 5fae3adac2af scripts/capture.sh +--- a/scripts/capture.sh Tue Aug 30 16:37:52 2016 +0100 ++++ b/scripts/capture.sh Wed Sep 21 21:04:33 2016 +0000 +@@ -1,3 +1,3 @@ + #!/bin/bash + # writes tail of current logs to standard out from running containers in compose project. +-docker-compose ps -q | xargs -I ID docker inspect --format='{{.LogPath}}' ID | xargs tail -n${1-8000} ++docker-compose logs --no-color $1 +diff -r 5fae3adac2af scripts/console.sh +--- a/scripts/console.sh Tue Aug 30 16:37:52 2016 +0100 ++++ b/scripts/console.sh Wed Sep 21 21:04:33 2016 +0000 +@@ -1,11 +1,22 @@ + #!/bin/bash ++# connects to the telnet console of the application for the specified service of the current project + +-# connects to the telnet console of the application for the specified service of the current project + source "$( dirname "${BASH_SOURCE[0]}")/.functions.sh" + + container=$(composeGetContainer ${1?"Must specify the app service of the console to connect to"} ) + + ip=$(docker inspect -f '{{.NetworkSettings.IPAddress}}' $container) + +-docker run -it -v ${PWD}:/tmp -v /ssdt:/ssdt --rm docker.ssdt.io/ssdt-utils telnet $ip 2000 | tee console.log + ++if [ "$ip" == "" ] ++then ++ ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $container) ++ project=$(composeGetProject ${1} ) ++fi ++ ++if [ "$project" == "" ] ++then ++ docker run -it -v ${PWD}:/tmp -v ${SSDT_HOME}:/ssdt --rm docker.ssdt.io/ssdt-utils telnet $ip 2000 | tee console.log ++else ++ docker run -it --network ${project}_default --rm docker.ssdt.io/ssdt-utils telnet $ip 2000 | tee console.log ++fi +diff -r 5fae3adac2af scripts/info.sh +--- a/scripts/info.sh Tue Aug 30 16:37:52 2016 +0100 ++++ b/scripts/info.sh Wed Sep 21 21:04:33 2016 +0000 +@@ -1,13 +1,14 @@ + #!/bin/bash ++source "$( dirname "${BASH_SOURCE[0]}")/.functions.sh" + echo $BASH_VERSION + docker version + docker-compose version + echo "------- Docker info-------------" + docker info + echo "------- Images -----------------" +-/ssdt/scripts/d-images.sh ++. $SSDT_HOME/scripts/d-images.sh + echo "------- Containers------" +-/ssdt/scripts/d-ps.sh ++. $SSDT_HOME/scripts/d-ps.sh + echo "------- OS Processes------------" + top -b -n 1 + +diff -r 5fae3adac2af scripts/send.sh +--- a/scripts/send.sh Tue Aug 30 16:37:52 2016 +0100 ++++ b/scripts/send.sh Wed Sep 21 21:04:33 2016 +0000 +@@ -1,10 +1,12 @@ + #!/bin/bash ++source "$( dirname "${BASH_SOURCE[0]}")/.functions.sh" + file=${1?"Usage: $0 filename [name]\n specify the filename relative to the current directory or - for stdin.\noptionally specify a short name (default to base directory)"} ++ + if [ "$file" != "-" ] + then + file="/tmp/${file}" + fi + name=${2:-$(basename $PWD)} + source=$(hostname) +-docker run -i -v /ssdt:/ssdt -v ${PWD}:/tmp --rm docker.ssdt.io/ssdt-utils \ +- curl -F source=$source -F name=$name -F file=@$file https://upload.ssdt.io/upload +\ No newline at end of file ++docker run -i -v $SSDT_HOME:/ssdt -v ${PWD}:/tmp --rm docker.ssdt.io/ssdt-utils \ ++ curl -F source=$source -F name=$name -F file=@$file https://upload.ssdt.io/upload \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/compose/rc/training.yml Wed Sep 21 19:00:41 2016 -0400 @@ -0,0 +1,41 @@ +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:preview + 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:preview + 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 +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/compose/rc/usas-template.yml Wed Sep 21 19:00:41 2016 -0400 @@ -0,0 +1,12 @@ +version: "2" +services: + usasdb: + extends: + file: /ssdt/compose/preview/usas.yml + service: usasdb + volumes: + - |volumeName|:/var/lib/postgresql/data + usasapp: + extends: + file: /ssdt/compose/preview/usas.yml + service: usasapp \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/compose/rc/usas.yml Wed Sep 21 19:00:41 2016 -0400 @@ -0,0 +1,20 @@ +version: "2" +services: + usasdb: + restart: unless-stopped + image: docker.ssdt.io/ssdt-postgres:3 + environment: + - DB_NAME=usasdb + - DB_USER=usas + - DB_PASS=usasdefault + usasapp: + restart: unless-stopped + image: docker.ssdt.io/usas-app:preview + environment: + - DB_HOST=usasdb + - DB_NAME=usasdb + - DB_USER=usas + - DB_PASS=usasdefault + - ORG_SSDT_OHIO_USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_SERVERHOST=uspsapp + - ORG_SSDT_OHIO_USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_SERVERDNSLOOKUP=true +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/compose/rc/usps.yml Wed Sep 21 19:00:41 2016 -0400 @@ -0,0 +1,20 @@ +# base compose file for usps Release Candidate release +version: "2" +services: + uspsdb: + restart: unless-stopped + image: docker.ssdt.io/ssdt-postgres:3 + environment: + - DB_NAME=uspsdb + - DB_USER=usps + - DB_PASS=uspsdefault + uspsapp: + restart: unless-stopped + image: docker.ssdt.io/usps-app:preview + environment: + - DB_HOST=uspsdb + - DB_NAME=uspsdb + - DB_USER=usps + - DB_PASS=uspsdefault + - ORG_SSDT_OHIO_USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_SERVERHOST=usasapp + - ORG_SSDT_OHIO_USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_SERVERDNSLOOKUP=true
--- a/init.sh Wed Sep 21 19:00:11 2016 -0400 +++ b/init.sh Wed Sep 21 19:00:41 2016 -0400 @@ -1,3 +1,6 @@ #!/bin/bash -alias utils='docker run -it -v ${PWD}:/tmp -v /ssdt:/ssdt --rm docker.ssdt.io/ssdt-utils' -alias send2ssdt='/ssdt/scripts/send.sh' \ No newline at end of file +source "$( dirname "${BASH_SOURCE[0]}")/scripts/.functions.sh" +alias utils='docker run -it -v ${PWD}:/tmp -v $SSDT_HOME:/ssdt --rm docker.ssdt.io/ssdt-utils' +alias send2ssdt='/ssdt/scripts/send.sh' + +export PATH=$PATH:$SSDT_HOME/scripts
--- a/scripts/.functions.sh Wed Sep 21 19:00:11 2016 -0400 +++ b/scripts/.functions.sh Wed Sep 21 19:00:41 2016 -0400 @@ -1,4 +1,6 @@ #!/bin/bash +export SSDT_SCRIPTS=$(dirname "${BASH_SOURCE[0]}") +export SSDT_HOME=$(dirname $SSDT_SCRIPTS) # deletes psql data from specified service resetDbVolume() { @@ -26,4 +28,10 @@ container=$(composeGetContainer $service) echo "$2" | docker exec -i $container sh -c "gosu postgres psql \$DB_NAME" -} \ No newline at end of file +} + +composeGetProject() { + service=${1?"Must supply service from current project"} + container=$(composeGetContainer $service) + echo $(docker inspect -f '{{index .Config.Labels "com.docker.compose.project" }}' $container) +}
--- a/scripts/capture.sh Wed Sep 21 19:00:11 2016 -0400 +++ b/scripts/capture.sh Wed Sep 21 19:00:41 2016 -0400 @@ -1,3 +1,3 @@ #!/bin/bash -# writes tail of current logs to standard out from running containers in compose project. -docker-compose ps -q | xargs -I ID docker inspect --format='{{.LogPath}}' ID | xargs tail -n${1-8000} +# writes tail of current logs to standard out from containers in compose project. +docker-compose logs --no-color $1 \ No newline at end of file
--- a/scripts/console.sh Wed Sep 21 19:00:11 2016 -0400 +++ b/scripts/console.sh Wed Sep 21 19:00:41 2016 -0400 @@ -1,11 +1,23 @@ #!/bin/bash +# connects to the telnet console of the application for the specified service of the current project +# For docker 1.12 and compose 1.9 (and higher) assume project is assigned to a network +# named "${project}_default" per SSDT templates. -# connects to the telnet console of the application for the specified service of the current project source "$( dirname "${BASH_SOURCE[0]}")/.functions.sh" container=$(composeGetContainer ${1?"Must specify the app service of the console to connect to"} ) ip=$(docker inspect -f '{{.NetworkSettings.IPAddress}}' $container) -docker run -it -v ${PWD}:/tmp -v /ssdt:/ssdt --rm docker.ssdt.io/ssdt-utils telnet $ip 2000 | tee console.log +if [ "$ip" == "" ] +then + ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $container) + project=$(composeGetProject ${1} ) +fi +if [ "$project" == "" ] +then + docker run -it -v ${PWD}:/tmp -v ${SSDT_HOME}:/ssdt --rm docker.ssdt.io/ssdt-utils telnet $ip 2000 | tee console.log +else + docker run -it --network ${project}_default --rm docker.ssdt.io/ssdt-utils telnet $ip 2000 | tee console.log +fi
--- a/scripts/info.sh Wed Sep 21 19:00:11 2016 -0400 +++ b/scripts/info.sh Wed Sep 21 19:00:41 2016 -0400 @@ -1,13 +1,13 @@ #!/bin/bash + source "$( dirname "${BASH_SOURCE[0]}")/.functions.sh" echo $BASH_VERSION docker version docker-compose version echo "------- Docker info-------------" docker info echo "------- Images -----------------" -/ssdt/scripts/d-images.sh + $SSDT_HOME/scripts/d-images.sh echo "------- Containers------" -/ssdt/scripts/d-ps.sh + $SSDT_HOME/scripts/d-ps.sh echo "------- OS Processes------------" top -b -n 1 -
--- a/scripts/send.sh Wed Sep 21 19:00:11 2016 -0400 +++ b/scripts/send.sh Wed Sep 21 19:00:41 2016 -0400 @@ -1,4 +1,12 @@ #!/bin/bash +# +# Securely sends a file or standard input to a SSDT web server. +# e.g: +# capture.sh | send.sh - # sends log files to ssdt server for the current project +# send.sh docker-compose.yml # sends the compose file +# +source "$( dirname "${BASH_SOURCE[0]}")/.functions.sh" + file=${1?"Usage: $0 filename [name]\n specify the filename relative to the current directory or - for stdin.\noptionally specify a short name (default to base directory)"} if [ "$file" != "-" ] then @@ -6,5 +14,6 @@ fi name=${2:-$(basename $PWD)} source=$(hostname) -docker run -i -v /ssdt:/ssdt -v ${PWD}:/tmp --rm docker.ssdt.io/ssdt-utils \ + +docker run -i -v $SSDT_HOME:/ssdt -v ${PWD}:/tmp --rm docker.ssdt.io/ssdt-utils \ curl -F source=$source -F name=$name -F file=@$file https://upload.ssdt.io/upload \ No newline at end of file