# HG changeset patch # User smith@nwoca.org # Date 1497629656 -3600 # Node ID 923c2b21fac7f494668e38627e409f91721917d5 # Parent 72f15ffc9ad29f5f18c8694140644b2e1a505b43# Parent 9aabd0f7d16560f55de7ca789f0bc910dd483e46 flow: Merged 'v1.1.1' to ('default'). diff -r 9aabd0f7d165 -r 923c2b21fac7 .hgignore --- a/.hgignore Fri Jun 16 17:14:15 2017 +0100 +++ b/.hgignore Fri Jun 16 17:14:16 2017 +0100 @@ -1,5 +1,5 @@ syntax: regexp -^\.DS_Store +\.DS_Store .*~$ \.orig$ \.orig\..*$ diff -r 9aabd0f7d165 -r 923c2b21fac7 compose3/preview/import-usas.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/compose3/preview/import-usas.yml Fri Jun 16 17:14:16 2017 +0100 @@ -0,0 +1,12 @@ +version: "3.1" +services: + usasimport: + 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 diff -r 9aabd0f7d165 -r 923c2b21fac7 compose3/preview/import-usps.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/compose3/preview/import-usps.yml Fri Jun 16 17:14:16 2017 +0100 @@ -0,0 +1,13 @@ +version: "3.1" +services: + uspsimport: + 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 diff -r 9aabd0f7d165 -r 923c2b21fac7 compose3/preview/setup.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/compose3/preview/setup.sh Fri Jun 16 17:14:16 2017 +0100 @@ -0,0 +1,113 @@ +#!/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} ; +} + +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 "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? " 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 + +echo "Review or create a docker-compose.override.yml for custom settings." + diff -r 9aabd0f7d165 -r 923c2b21fac7 compose3/preview/training.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/compose3/preview/training.yml Fri Jun 16 17:14:16 2017 +0100 @@ -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 + diff -r 9aabd0f7d165 -r 923c2b21fac7 compose3/preview/usas-services.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/compose3/preview/usas-services.yml Fri Jun 16 17:14:16 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:- } diff -r 9aabd0f7d165 -r 923c2b21fac7 compose3/preview/usps-services.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/compose3/preview/usps-services.yml Fri Jun 16 17:14:16 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:- } diff -r 9aabd0f7d165 -r 923c2b21fac7 init.sh --- a/init.sh Fri Jun 16 17:14:15 2017 +0100 +++ b/init.sh Fri Jun 16 17:14:16 2017 +0100 @@ -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 diff -r 9aabd0f7d165 -r 923c2b21fac7 java/Dockerfile --- a/java/Dockerfile Fri Jun 16 17:14:15 2017 +0100 +++ b/java/Dockerfile Fri Jun 16 17:14:16 2017 +0100 @@ -1,11 +1,15 @@ -FROM docker.ssdt.io/java:8-jre +FROM openjdk:8u121-jdk MAINTAINER Dave Smith -RUN echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" | debconf-set-selections \ - && echo 'deb http://httpredir.debian.org/debian jessie contrib' > /etc/apt/sources.list.d/jessie-contrib.list \ - && apt-get update \ - && apt-get install -y ttf-mscorefonts-installer +RUN echo "deb http://httpredir.debian.org/debian jessie main contrib" > /etc/apt/sources.list \ + && echo "deb http://security.debian.org/ jessie/updates main contrib" >> /etc/apt/sources.list \ + && echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" | debconf-set-selections \ + && apt-get update \ + && apt-get install -y ttf-mscorefonts-installer \ + && apt-get clean \ + && apt-get autoremove -y \ + && rm -rf /var/lib/apt/lists/* ENV TZ=America/New_York diff -r 9aabd0f7d165 -r 923c2b21fac7 postgres/Dockerfile --- a/postgres/Dockerfile Fri Jun 16 17:14:15 2017 +0100 +++ b/postgres/Dockerfile Fri Jun 16 17:14:16 2017 +0100 @@ -1,7 +1,7 @@ # # Docker file to create postgres image for ssdt applications -FROM postgres:9.4.5 +FROM postgres:9.4.11 MAINTAINER Dave Smith smith@nwoca.org @@ -21,3 +21,12 @@ RUN echo $TZ > /etc/timezone \ && dpkg-reconfigure --frontend noninteractive tzdata + +COPY ssdt-entrypoint.sh /usr/local/bin/ + +RUN chmod 755 /usr/local/bin/ssdt-entrypoint.sh + +ENTRYPOINT ["ssdt-entrypoint.sh"] + +CMD ["postgres"] + \ No newline at end of file diff -r 9aabd0f7d165 -r 923c2b21fac7 postgres/ssdt-entrypoint.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/postgres/ssdt-entrypoint.sh Fri Jun 16 17:14:16 2017 +0100 @@ -0,0 +1,6 @@ +#!/bin/bash +if [ ! "$POSTGRES_PASSWORD" ]; then + export POSTGRES_PASSWORD=$(date +%s | sha256sum | base64 | head -c 32 ; echo) +fi + +docker-entrypoint.sh "$@" \ No newline at end of file diff -r 9aabd0f7d165 -r 923c2b21fac7 scripts/.functions.sh --- a/scripts/.functions.sh Fri Jun 16 17:14:15 2017 +0100 +++ b/scripts/.functions.sh Fri Jun 16 17:14:16 2017 +0100 @@ -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) +} diff -r 9aabd0f7d165 -r 923c2b21fac7 scripts/capture.sh --- a/scripts/capture.sh Fri Jun 16 17:14:15 2017 +0100 +++ b/scripts/capture.sh Fri Jun 16 17:14:16 2017 +0100 @@ -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 diff -r 9aabd0f7d165 -r 923c2b21fac7 scripts/console.sh --- a/scripts/console.sh Fri Jun 16 17:14:15 2017 +0100 +++ b/scripts/console.sh Fri Jun 16 17:14:16 2017 +0100 @@ -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 diff -r 9aabd0f7d165 -r 923c2b21fac7 scripts/info.sh --- a/scripts/info.sh Fri Jun 16 17:14:15 2017 +0100 +++ b/scripts/info.sh Fri Jun 16 17:14:16 2017 +0100 @@ -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 - diff -r 9aabd0f7d165 -r 923c2b21fac7 scripts/send.sh --- a/scripts/send.sh Fri Jun 16 17:14:15 2017 +0100 +++ b/scripts/send.sh Fri Jun 16 17:14:16 2017 +0100 @@ -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 diff -r 9aabd0f7d165 -r 923c2b21fac7 tomcat/Dockerfile --- a/tomcat/Dockerfile Fri Jun 16 17:14:15 2017 +0100 +++ b/tomcat/Dockerfile Fri Jun 16 17:14:16 2017 +0100 @@ -1,11 +1,21 @@ -FROM tomcat:8.5.5-jre8 +FROM tomcat:8.5.14-jre8 MAINTAINER Dave Smith -RUN echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" | debconf-set-selections \ - && echo 'deb http://httpredir.debian.org/debian jessie contrib' > /etc/apt/sources.list.d/jessie-contrib.list \ - && apt-get update \ - && apt-get install -y ttf-mscorefonts-installer +RUN echo "deb http://httpredir.debian.org/debian jessie main contrib" > /etc/apt/sources.list \ + && echo "deb http://security.debian.org/ jessie/updates main contrib" >> /etc/apt/sources.list \ + && echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" | debconf-set-selections \ + && apt-get update \ + && apt-get install -y ttf-mscorefonts-installer \ + && apt-get clean \ + && apt-get autoremove -y \ + && rm -rf /var/lib/apt/lists/* + +RUN apt-get update \ + && apt-get install -y postgresql-client \ + && apt-get clean \ + && apt-get autoremove -y \ + && rm -rf /var/lib/apt/lists/* WORKDIR /usr/local/tomcat @@ -16,7 +26,3 @@ && chmod +x bin/setenv.sh ENV TZ=America/New_York - -ENV LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/usr/lib/x86_64-linux-gnu/ - -RUN apt-get install -y libtcnative-1