From 4ad4763d8c9191998cc671a884d1af5da6ba8bb9 Mon Sep 17 00:00:00 2001 From: Instrumental Date: Fri, 13 Jul 2018 15:49:26 -0500 Subject: Make Container Config Strategy Issue-ID: AAF-378 Change-Id: I57186f66b9713262643e0f440f5b9eb78154c155 Signed-off-by: Instrumental --- auth/docker/.gitignore | 1 + auth/docker/Dockerfile | 24 ---------- auth/docker/Dockerfile.config | 2 +- auth/docker/Dockerfile.ms | 2 + auth/docker/README.txt | 31 +++++++++++++ auth/docker/agent.sh | 15 ++++--- auth/docker/dbounce.sh | 4 ++ auth/docker/dbuild.sh | 28 +++++------- auth/docker/dclean.sh | 9 ++-- auth/docker/dpush.sh | 4 +- auth/docker/drun.sh | 101 ++++++++++++++++++------------------------ auth/docker/dstart.sh | 9 ++-- auth/docker/dstop.sh | 8 ++-- 13 files changed, 119 insertions(+), 119 deletions(-) delete mode 100644 auth/docker/Dockerfile create mode 100644 auth/docker/README.txt create mode 100644 auth/docker/dbounce.sh (limited to 'auth/docker') diff --git a/auth/docker/.gitignore b/auth/docker/.gitignore index f08acc75..a03737d0 100644 --- a/auth/docker/.gitignore +++ b/auth/docker/.gitignore @@ -1 +1,2 @@ +local d.props diff --git a/auth/docker/Dockerfile b/auth/docker/Dockerfile deleted file mode 100644 index d744d69c..00000000 --- a/auth/docker/Dockerfile +++ /dev/null @@ -1,24 +0,0 @@ -FROM rmannfv/aaf-base:xenial -MAINTAINER AAF Team, AT&T 2018 -ENV VERSION=${AAF_VERSION} - -LABEL description="aaf ${AAF_COMPONENT}" -LABEL version=${AAF_VERSION} - - -COPY lib /opt/app/aaf/${AAF_COMPONENT}/lib -COPY theme /opt/app/aaf/${AAF_COMPONENT}/theme -COPY bin /opt/app/aaf/${AAF_COMPONENT}/bin - -CMD ["/bin/bash","-c","/opt/app/aaf/${AAF_COMPONENT}/bin/${AAF_COMPONENT}"] - -# For Debugging installation -# CMD ["/bin/bash","-c","pwd;cd /opt/app/osaaf;find /opt/app/osaaf -depth;df -k; cat /opt/app/aaf/${AAF_COMPONENT}/bin/${AAF_COMPONENT};cat /etc/hosts;/opt/app/aaf/${AAF_COMPONENT}/bin/${AAF_COMPONENT}"] -# Java Debugging VM Args -# "-Xdebug",\ -# "-Xnoagent",\ -# "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000",\ - -# TLS Debugging VM Args -# "-Djavax.net.debug","ssl", \ - diff --git a/auth/docker/Dockerfile.config b/auth/docker/Dockerfile.config index a5811e09..1855fae2 100644 --- a/auth/docker/Dockerfile.config +++ b/auth/docker/Dockerfile.config @@ -7,7 +7,7 @@ LABEL version=${AAF_VERSION} COPY data/sample.identities.dat /opt/app/aaf_config/data/ COPY etc /opt/app/aaf_config/etc -COPY local/*.props /opt/app/aaf_config/local/ +COPY local /opt/app/aaf_config/local COPY public /opt/app/aaf_config/public COPY logs /opt/app/aaf_config/logs COPY bin /opt/app/aaf_config/bin diff --git a/auth/docker/Dockerfile.ms b/auth/docker/Dockerfile.ms index 121bd06c..b8ef6d9a 100644 --- a/auth/docker/Dockerfile.ms +++ b/auth/docker/Dockerfile.ms @@ -5,6 +5,8 @@ ENV VERSION=${AAF_VERSION} LABEL description="aaf_${AAF_COMPONENT}" LABEL version=${AAF_VERSION} +COPY theme /opt/app/aaf/theme + CMD ["/bin/bash","-c","/opt/app/aaf/bin/${AAF_COMPONENT}"] # For Debugging installation diff --git a/auth/docker/README.txt b/auth/docker/README.txt new file mode 100644 index 00000000..32ed3489 --- /dev/null +++ b/auth/docker/README.txt @@ -0,0 +1,31 @@ +# Start the container in bash mode, so it stays up +sh agent.sh bash + + +# in another shell, find out your Container name +docker container ls | grep aaf_agent + +# copy keystore for this AAF Env +docker container cp -L org.osaaf.aaf.p12 :/opt/app/osaaf/local +# (in Agent Window) +agent encrypt cadi_keystore_password + +# If you intend to use Certman to sign certs, it is a "local" CA +# copy Signing Keystore into container +docker container cp -L org.osaaf.aaf.signer.p12 :/opt/app/osaaf/local +# (in Agent Window) +agent encrypt cm_ca.local + +# Add in Cassandra Password +agent encrypt cassandra.clusters.password + +# Check to make sure all passwords are set +grep "enc:" *.props + + +# When good, run AAF +bash drun.sh + +# watch logs in Agent Window +cd ../logs +sh taillog diff --git a/auth/docker/agent.sh b/auth/docker/agent.sh index 68027947..f734c629 100644 --- a/auth/docker/agent.sh +++ b/auth/docker/agent.sh @@ -1,9 +1,12 @@ #!/bin/bash . ./d.props + docker run \ - -it \ - --mount 'type=volume,src=aaf_config,dst=/opt/app/osaaf,volume-driver=local' \ - --name aaf_agent_$USER \ - ${ORG}/${PROJECT}/aaf_config:${VERSION} \ - /bin/bash $* -docker container rm aaf_agent_$USER > /dev/null + -it \ + --rm \ + --mount 'type=volume,src=aaf_config,dst='$CONF_ROOT_DIR',volume-driver=local' \ + --add-host="$HOSTNAME:$HOST_IP" \ + --add-host="aaf.osaaf.org:$HOST_IP" \ + --name aaf_agent_$USER \ + ${ORG}/${PROJECT}/aaf_config:${VERSION} \ + /bin/bash "$@" diff --git a/auth/docker/dbounce.sh b/auth/docker/dbounce.sh new file mode 100644 index 00000000..e6367957 --- /dev/null +++ b/auth/docker/dbounce.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +sh ./dstop.sh "$@" +sh ./dstart.sh "$@" diff --git a/auth/docker/dbuild.sh b/auth/docker/dbuild.sh index ec5cd5cb..ba7a8095 100755 --- a/auth/docker/dbuild.sh +++ b/auth/docker/dbuild.sh @@ -1,46 +1,42 @@ -#!/bin/bash +#!/bin/bash # # Docker Building Script. Reads all the components generated by install, on per-version basis # # Pull in Variables from d.props if [ ! -e ./d.props ]; then - cp d.props.init d.props + cp d.props.init d.props fi . ./d.props # Create the Config (Security) Image -sed -e 's/${AAF_VERSION}/'${VERSION}'/g' -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' Dockerfile.config > ../sample/Dockerfile +sed -e 's/${AAF_VERSION}/'${VERSION}'/g' -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' Dockerfile.config >../sample/Dockerfile cd .. cp ../cadi/aaf/target/aaf-cadi-aaf-${VERSION}-full.jar sample/bin docker build -t ${ORG}/${PROJECT}/aaf_config:${VERSION} sample rm sample/Dockerfile sample/bin/aaf-cadi-aaf-${VERSION}-full.jar cd - -exit - # Second, build a core Docker Image echo Building aaf_$AAF_COMPONENT... # Apply currrent Properties to Docker file, and put in place. -sed -e 's/${AAF_VERSION}/'${VERSION}'/g' -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' Dockerfile.core > ../aaf_${VERSION}/Dockerfile +sed -e 's/${AAF_VERSION}/'${VERSION}'/g' -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' Dockerfile.core >../aaf_${VERSION}/Dockerfile cd .. docker build -t ${ORG}/${PROJECT}/aaf_core:${VERSION} aaf_${VERSION} rm aaf_${VERSION}/Dockerfile cd - if ["$1" == ""]; then - AAF_COMPONENTS=`ls ../aaf_*HOT/bin | grep -v '\.'` + AAF_COMPONENTS=$(ls ../aaf_*HOT/bin | grep -v '\.') else - AAF_COMPONENTS=$1 + AAF_COMPONENTS=$1 fi for AAF_COMPONENT in ${AAF_COMPONENTS}; do - echo Building aaf_$AAF_COMPONENT... - sed -e 's/${AAF_VERSION}/'${VERSION}'/g' -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' Dockerfile.ms > ../aaf_${VERSION}/Dockerfile - cd .. - docker build -t ${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION} aaf_${VERSION} - rm aaf_${VERSION}/Dockerfile - cd - + echo Building aaf_$AAF_COMPONENT... + sed -e 's/${AAF_VERSION}/'${VERSION}'/g' -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' Dockerfile.ms >../aaf_${VERSION}/Dockerfile + cd .. + docker build -t ${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION} aaf_${VERSION} + rm aaf_${VERSION}/Dockerfile + cd - done - - diff --git a/auth/docker/dclean.sh b/auth/docker/dclean.sh index 163272d0..0bca9ef7 100644 --- a/auth/docker/dclean.sh +++ b/auth/docker/dclean.sh @@ -1,17 +1,18 @@ -#!/bin/bash +#!/bin/bash # Pull in Variables from d.props . ./d.props if [ "$1" == "" ]; then - AAF_COMPONENTS=`ls ../aaf_${VERSION}/bin | grep -v '\.'` + AAF_COMPONENTS=$(ls ../aaf_${VERSION}/bin | grep -v '\.') else - AAF_COMPONENTS=$1 + AAF_COMPONENTS=$1 fi +docker image rm $ORG/$PROJECT/aaf_config:${VERSION} docker image rm $ORG/$PROJECT/aaf_core:${VERSION} echo "Y" | docker container prune for AAF_COMPONENT in ${AAF_COMPONENTS}; do - docker image rm $ORG/$PROJECT/aaf_$AAF_COMPONENT:${VERSION} + docker image rm $ORG/$PROJECT/aaf_$AAF_COMPONENT:${VERSION} done echo "Y" | docker image prune diff --git a/auth/docker/dpush.sh b/auth/docker/dpush.sh index 78129796..761ae2a8 100644 --- a/auth/docker/dpush.sh +++ b/auth/docker/dpush.sh @@ -12,7 +12,7 @@ fi for AAF_COMPONENT in ${AAF_COMPONENTS}; do docker push ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${OLD_VERSION} - docker push ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION} - docker push ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${NEW_VERSION} + docker push ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION} + docker push ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${NEW_VERSION} done diff --git a/auth/docker/drun.sh b/auth/docker/drun.sh index a7378b75..c62adfc2 100644 --- a/auth/docker/drun.sh +++ b/auth/docker/drun.sh @@ -1,65 +1,52 @@ -#!/bin/bash +#!/bin/bash # Pull in Variables from d.props . ./d.props -# Create Volumes, if not exist already -for VOL in aaf_config aaf_cass_data; do - HAS_VOLUME=`docker volume ls | grep $VOL` - if [ "$HAS_VOLUME" = "" ]; then - docker volume create --name $VOL - fi -done - docker run \ - -d \ - --name aaf_config \ - --mount 'type=volume,src=aaf_config,dst=/opt/app/osaaf,volume-driver=local' \ - ${ORG}/${PROJECT}/aaf_agent:${VERSION} - if [ "$1" == "" ]; then - AAF_COMPONENTS=`ls -r ../aaf_${VERSION}/bin | grep -v '\.'` + AAF_COMPONENTS=$(ls -r ../aaf_${VERSION}/bin | grep -v '\.') else - AAF_COMPONENTS=$1 + AAF_COMPONENTS="$@" fi - -for AAF_COMPONENT in ${AAF_COMPONENTS}; do - case "$AAF_COMPONENT" in - "service") - PORTMAP="8100:8100" - LINKS="--link aaf_cass:cassandra --add-host=$CASS_HOST" - ;; - "locate") - PORTMAP="8095:8095" - LINKS="--link aaf_cass:cassandra --add-host=$CASS_HOST" - ;; - "oauth") - PORTMAP="8140:8140" - LINKS="--link aaf_cass:cassandra --add-host=$CASS_HOST" - ;; - "gui") - PORTMAP="8200:8200" - ;; - "cm") - PORTMAP="8150:8150" - LINKS="--link aaf_cass:cassandra --add-host=$CASS_HOST" - ;; - "hello") - PORTMAP="8130:8130" - ;; - "fs") - PORTMAP="80:8096" - ;; - esac - - echo Starting aaf_$AAF_COMPONENT... - docker run \ - -d \ - --name aaf_$AAF_COMPONENT \ - --hostname="${AAF_COMPONENT}.aaf.osaaf.org" \ - --add-host="$HOSTNAME:$HOST_IP" \ - --add-host="aaf.osaaf.org:$HOST_IP" \ - ${LINKS} \ - --publish $PORTMAP \ - --mount type=bind,source=$CONF_ROOT_DIR,target=/opt/app/osaaf \ - ${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION} +for AAF_COMPONENT in ${AAF_COMPONENTS}; do + case "$AAF_COMPONENT" in + "service") + PORTMAP="8100:8100" + LINKS="--link aaf_cass:cassandra --add-host=$CASS_HOST" + ;; + "locate") + PORTMAP="8095:8095" + LINKS="--link aaf_cass:cassandra --add-host=$CASS_HOST" + ;; + "oauth") + PORTMAP="8140:8140" + LINKS="--link aaf_cass:cassandra --add-host=$CASS_HOST" + ;; + "gui") + PORTMAP="8200:8200" + ;; + "cm") + PORTMAP="8150:8150" + LINKS="--link aaf_cass:cassandra --add-host=$CASS_HOST" + ;; + "hello") + PORTMAP="8130:8130" + ;; + "fs") + PORTMAP="80:8096" + ;; + esac + + echo Starting aaf_$AAF_COMPONENT... + + docker run \ + -d \ + --name aaf_$AAF_COMPONENT \ + --hostname="${AAF_COMPONENT}.aaf.osaaf.org" \ + --add-host="$HOSTNAME:$HOST_IP" \ + --add-host="aaf.osaaf.org:$HOST_IP" \ + ${LINKS} \ + --publish $PORTMAP \ + --mount 'type=volume,src=aaf_config,dst='$CONF_ROOT_DIR',volume-driver=local' \ + ${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION} done diff --git a/auth/docker/dstart.sh b/auth/docker/dstart.sh index ae6ed02d..4c0a46f4 100644 --- a/auth/docker/dstart.sh +++ b/auth/docker/dstart.sh @@ -1,14 +1,13 @@ -#!/bin/bash +#!/bin/bash # Pull in Props . ./d.props - if [ "$1" == "" ]; then - AAF_COMPONENTS=`ls -r ../aaf_${VERSION}/bin | grep -v '\.'` + AAF_COMPONENTS=$(ls -r ../aaf_${VERSION}/bin | grep -v '\.') else - AAF_COMPONENTS=$1 + AAF_COMPONENTS="$@" fi for AAF_COMPONENT in ${AAF_COMPONENTS}; do - docker start aaf_$AAF_COMPONENT + docker start aaf_$AAF_COMPONENT done diff --git a/auth/docker/dstop.sh b/auth/docker/dstop.sh index 4c8d4425..c6e1cfeb 100644 --- a/auth/docker/dstop.sh +++ b/auth/docker/dstop.sh @@ -1,13 +1,13 @@ -#!/bin/bash +#!/bin/bash # Pull in Properties . ./d.props if [ "$1" == "" ]; then - AAF_COMPONENTS=`ls ../aaf_${VERSION}/bin | grep -v '\.'` + AAF_COMPONENTS=$(ls ../aaf_${VERSION}/bin | grep -v '\.') else - AAF_COMPONENTS=$1 + AAF_COMPONENTS="$@" fi for AAF_COMPONENT in ${AAF_COMPONENTS}; do - docker stop aaf_$AAF_COMPONENT + docker stop aaf_$AAF_COMPONENT done -- cgit