move labels to bottom, update postgres container

Change-Id: Id1d09ff54bdeb8f315d255756a78086fb91844d3
diff --git a/containers/chameleon/Dockerfile.chameleon b/containers/chameleon/Dockerfile.chameleon
index 97c4c92..e00bc5e 100644
--- a/containers/chameleon/Dockerfile.chameleon
+++ b/containers/chameleon/Dockerfile.chameleon
@@ -1,10 +1,15 @@
 # xosproject/chameleon
 FROM xosproject/xos-base
 
-MAINTAINER Scott Baker    <scottb@onlab.us>
-MAINTAINER Zsolt Haraszti <zharaszt@ciena.com>
-MAINTAINER Ali Al-Shabibi <ali.al-shabibi@onlab.us>
-MAINTAINER Nathan Knuth   <nathan.knuth@tibitcom.com>
+# xos-base already has protoc and dependencies installed
+
+# Bundle app source
+RUN mkdir /chameleon && touch /chameleon/__init__.py
+ENV PYTHONPATH=/chameleon
+COPY tmp.chameleon /chameleon/chameleon
+
+# Build the protos
+RUN chdir chameleon/chameleon/protos && VOLTHA_BASE=anything make
 
 # Label image
 ARG org_label_schema_schema_version=1.0
@@ -29,15 +34,6 @@
       org.opencord.component.chameleon.vcs-url=$org_opencord_component_chameleon_vcs_url \
       org.opencord.component.chameleon.vcs-ref=$org_opencord_component_chameleon_vcs_ref
 
-# xos-base already has protoc and dependencies installed
-
-# Bundle app source
-RUN mkdir /chameleon && touch /chameleon/__init__.py
-ENV PYTHONPATH=/chameleon
-COPY tmp.chameleon /chameleon/chameleon
-
-# Build the protos
-RUN chdir chameleon/chameleon/protos && VOLTHA_BASE=anything make
-
 # Exposing process and default entry point
 CMD ["python", "chameleon/chameleon/main.py"]
+
diff --git a/containers/postgresql/Dockerfile b/containers/postgresql/Dockerfile
index 68cd4ad..691ac71 100644
--- a/containers/postgresql/Dockerfile
+++ b/containers/postgresql/Dockerfile
@@ -1,6 +1,43 @@
 # xosproject/xos-postgres
 FROM ubuntu:14.04.5
 
+# Version of PostgreSQL to install
+ENV PGSQL_VERSION 9.6
+
+RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
+
+RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" \
+    > /etc/apt/sources.list.d/pgdg.list
+
+RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --force-yes\
+    python-software-properties \
+    software-properties-common \
+    postgresql-$PGSQL_VERSION \
+    postgresql-client-$PGSQL_VERSION \
+    postgresql-contrib-$PGSQL_VERSION \
+ && rm -rf /var/lib/apt/lists/*
+
+# Workaround for AUFS issue
+# https://github.com/docker/docker/issues/783#issuecomment-56013588
+RUN mkdir /etc/ssl/private-copy; mv /etc/ssl/private/* /etc/ssl/private-copy/; rm -r /etc/ssl/private; mv /etc/ssl/private-copy /etc/ssl/private; chmod -R 0700 /etc/ssl/private; chown -R postgres /etc/ssl/private
+
+USER postgres
+
+RUN /etc/init.d/postgresql start && \
+    psql --command "ALTER USER postgres WITH SUPERUSER PASSWORD 'password' " && \
+    psql --command "CREATE DATABASE xos"
+
+# Allow remote connections.
+RUN echo "host all  all    0.0.0.0/0  md5" >> /etc/postgresql/$PGSQL_VERSION/main/pg_hba.conf
+RUN echo "host all  all    0.0.0.0/0  password" >> /etc/postgresql/$PGSQL_VERSION/main/pg_hba.conf
+
+RUN echo "listen_addresses='*'" >> /etc/postgresql/$PGSQL_VERSION/main/postgresql.conf
+
+# Expose the PostgreSQL port
+EXPOSE 5432
+
+VOLUME  ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"]
+
 # Label image
 ARG org_label_schema_schema_version=1.0
 ARG org_label_schema_name=xos-postgres
@@ -18,36 +55,4 @@
       org.label-schema.build-date=$org_label_schema_build_date \
       org.opencord.vcs-commit-date=$org_opencord_vcs_commit_date
 
-RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
-
-RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list
-
-RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --force-yes\
-    python-software-properties \
-    software-properties-common \
-    postgresql-9.3 \
-    postgresql-client-9.3 \
-    postgresql-contrib-9.3
-
-# Workaround for AUFS issue
-# https://github.com/docker/docker/issues/783#issuecomment-56013588
-RUN mkdir /etc/ssl/private-copy; mv /etc/ssl/private/* /etc/ssl/private-copy/; rm -r /etc/ssl/private; mv /etc/ssl/private-copy /etc/ssl/private; chmod -R 0700 /etc/ssl/private; chown -R postgres /etc/ssl/private
-
-USER postgres
-
-RUN /etc/init.d/postgresql start && \
-    psql --command "ALTER USER postgres WITH SUPERUSER PASSWORD 'password' " && \
-    psql --command "CREATE DATABASE xos"
-
-# Allow remote connections. 
-RUN echo "host all  all    0.0.0.0/0  md5" >> /etc/postgresql/9.3/main/pg_hba.conf
-RUN echo "host all  all    0.0.0.0/0  password" >> /etc/postgresql/9.3/main/pg_hba.conf
-
-RUN echo "listen_addresses='*'" >> /etc/postgresql/9.3/main/postgresql.conf
-
-# Expose the PostgreSQL port
-EXPOSE 5432
-
-VOLUME  ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"]
-
-CMD ["/usr/lib/postgresql/9.3/bin/postgres", "-D", "/var/lib/postgresql/9.3/main", "-c", "config_file=/etc/postgresql/9.3/main/postgresql.conf"]
+CMD ["/usr/lib/postgresql/$PGSQL_VERSION/bin/postgres", "-D", "/var/lib/postgresql/$PGSQL_VERSION/main", "-c", "config_file=/etc/postgresql/$PGSQL_VERSION/main/postgresql.conf"]
diff --git a/containers/xos/Dockerfile b/containers/xos/Dockerfile
deleted file mode 100644
index e19b40c..0000000
--- a/containers/xos/Dockerfile
+++ /dev/null
@@ -1,36 +0,0 @@
-FROM xosproject/xos-base
-
-# Include certificates from Openstack
-ADD local_certs.crt /usr/local/share/ca-certificates/local_certs.crt
-RUN update-ca-certificates
-
-# Install and boostrap XOS and Tosca
-ENV XOS_GIT_REPO https://github.com/opencord/xos.git
-ENV XOS_GIT_BRANCH master
-
-RUN git clone $XOS_GIT_REPO -b $XOS_GIT_BRANCH /tmp/xos && \
-    mv /tmp/xos/xos /opt/ && \
-    chmod +x /opt/xos/tools/xos-manage && \
-    /opt/xos/tools/xos-manage genkeys
-
-# ng-xos-lib download
-
-ENV NG_XOS_LIB_URL https://github.com/opencord/ng-xos-lib.git
-ENV NG_XOS_LIB_VERSION 1.0.0
-
-RUN git clone $NG_XOS_LIB_URL /tmp/ng-xos-lib 
-RUN cd /tmp/ng-xos-lib && git checkout tags/$NG_XOS_LIB_VERSION
-RUN cp /tmp/ng-xos-lib/dist/ngXosHelpers.min.js /opt/xos/core/xoslib/static/vendor/ 
-RUN cp /tmp/ng-xos-lib/dist/ngXosVendor.min.js /opt/xos/core/xoslib/static/vendor/
-
-EXPOSE 8000
-
-# Set environment variables
-ENV HOME /root
-
-# Define working directory
-WORKDIR /opt/xos
-
-# Define default command
-CMD python /opt/xos/manage.py runserver 0.0.0.0:8000 --insecure --makemigrations
-
diff --git a/containers/xos/Dockerfile.UI b/containers/xos/Dockerfile.UI
index 979d67b..f494397 100644
--- a/containers/xos/Dockerfile.UI
+++ b/containers/xos/Dockerfile.UI
@@ -1,6 +1,9 @@
 # xosproject/xos-ui
 FROM xosproject/xos:candidate
 
+# Install file from corebuilder
+ADD containers/xos/BUILD /
+
 # Label image
 ARG org_label_schema_schema_version=1.0
 ARG org_label_schema_name=xos-corebuilder
@@ -18,5 +21,3 @@
       org.label-schema.build-date=$org_label_schema_build_date \
       org.opencord.vcs-commit-date=$org_opencord_vcs_commit_date
 
-# Install file from corebuilder
-ADD containers/xos/BUILD /
diff --git a/containers/xos/Dockerfile.base b/containers/xos/Dockerfile.base
index 6e7f102..9ea3553 100644
--- a/containers/xos/Dockerfile.base
+++ b/containers/xos/Dockerfile.base
@@ -1,24 +1,6 @@
 # Dockerfile.base
 # This image isn't used, but installs the prereqs for the other XOS images
 FROM ubuntu:14.04.5
-MAINTAINER Zack Williams <zdw@cs.arizona.edu>
-
-# Label image
-ARG org_label_schema_schema_version=1.0
-ARG org_label_schema_name=xos-base
-ARG org_label_schema_version=unknown
-ARG org_label_schema_vcs_url=unknown
-ARG org_label_schema_vcs_ref=unknown
-ARG org_label_schema_build_date=unknown
-ARG org_opencord_vcs_commit_date=unknown
-
-LABEL org.label-schema.schema-version=$org_label_schema_schema_version \
-      org.label-schema.name=$org_label_schema_name \
-      org.label-schema.version=$org_label_schema_version \
-      org.label-schema.vcs-url=$org_label_schema_vcs_url \
-      org.label-schema.vcs-ref=$org_label_schema_vcs_ref \
-      org.label-schema.build-date=$org_label_schema_build_date \
-      org.opencord.vcs-commit-date=$org_opencord_vcs_commit_date
 
 # Install apt packages, including docker
 RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y \
@@ -95,3 +77,20 @@
     mv jquery-ui-themes-*/themes/smoothness/jquery-ui.min.css /usr/local/lib/python2.7/dist-packages/suit/static/suit/css/ && \
     rm -rf jquery-ui-themes.zip jquery-ui-themes-*
 
+# Label image
+ARG org_label_schema_schema_version=1.0
+ARG org_label_schema_name=xos-base
+ARG org_label_schema_version=unknown
+ARG org_label_schema_vcs_url=unknown
+ARG org_label_schema_vcs_ref=unknown
+ARG org_label_schema_build_date=unknown
+ARG org_opencord_vcs_commit_date=unknown
+
+LABEL org.label-schema.schema-version=$org_label_schema_schema_version \
+      org.label-schema.name=$org_label_schema_name \
+      org.label-schema.version=$org_label_schema_version \
+      org.label-schema.vcs-url=$org_label_schema_vcs_url \
+      org.label-schema.vcs-ref=$org_label_schema_vcs_ref \
+      org.label-schema.build-date=$org_label_schema_build_date \
+      org.opencord.vcs-commit-date=$org_opencord_vcs_commit_date
+
diff --git a/containers/xos/Dockerfile.client b/containers/xos/Dockerfile.client
index 10baa0e..f3db714 100644
--- a/containers/xos/Dockerfile.client
+++ b/containers/xos/Dockerfile.client
@@ -1,6 +1,18 @@
 # xosproject/xos-client
 FROM xosproject/xos-base:candidate
 
+# Install XOS client
+ADD xos/xos_client /tmp/xos_client
+
+# Install chameleon
+ADD containers/xos/tmp.chameleon /tmp/xos_client/xosapi/chameleon
+
+#ENV HOME /root
+#WORKDIR /opt/xos
+
+# install the client library and xossh
+RUN chdir /tmp/xos_client && make
+
 # Label image
 ARG org_label_schema_schema_version=1.0
 ARG org_label_schema_name=xos-client
@@ -24,16 +36,5 @@
       org.opencord.component.chameleon.vcs-url=$org_opencord_component_chameleon_vcs_url \
       org.opencord.component.chameleon.vcs-ref=$org_opencord_component_chameleon_vcs_ref
 
-# Install XOS client
-ADD xos/xos_client /tmp/xos_client
-
-# Install chameleon
-ADD containers/xos/tmp.chameleon /tmp/xos_client/xosapi/chameleon
-
-#ENV HOME /root
-#WORKDIR /opt/xos
-
-# install the client library and xossh
-RUN chdir /tmp/xos_client && make
 
 ENTRYPOINT ["xossh"]
diff --git a/containers/xos/Dockerfile.corebuilder b/containers/xos/Dockerfile.corebuilder
index 62d4952..f1e16a8 100644
--- a/containers/xos/Dockerfile.corebuilder
+++ b/containers/xos/Dockerfile.corebuilder
@@ -1,6 +1,13 @@
 # xosproject/xos-corebuilder
 FROM xosproject/xos-base:candidate
 
+# Install the corebuilder tools and the tosca custom_types that it needs
+ADD xos/tools/corebuilder /opt/xos/tools/corebuilder
+ADD xos/tosca/custom_types /opt/xos/tools/corebuilder/custom_types
+
+ENV HOME /root
+WORKDIR /opt/xos/tools/corebuilder
+
 # Label image
 ARG org_label_schema_schema_version=1.0
 ARG org_label_schema_name=xos-corebuilder
@@ -18,12 +25,5 @@
       org.label-schema.build-date=$org_label_schema_build_date \
       org.opencord.vcs-commit-date=$org_opencord_vcs_commit_date
 
-# Install the corebuilder tools and the tosca custom_types that it needs
-ADD xos/tools/corebuilder /opt/xos/tools/corebuilder
-ADD xos/tosca/custom_types /opt/xos/tools/corebuilder/custom_types
-
-ENV HOME /root
-WORKDIR /opt/xos/tools/corebuilder
-
 ENTRYPOINT ["/usr/bin/python", "corebuilder.py"]
 
diff --git a/containers/xos/Dockerfile.devel b/containers/xos/Dockerfile.devel
index c9fa9d8..11a6815 100644
--- a/containers/xos/Dockerfile.devel
+++ b/containers/xos/Dockerfile.devel
@@ -1,6 +1,20 @@
 # xosproject/xos (devel)
 FROM xosproject/xos-base
 
+# Install XOS
+ADD xos /opt/xos
+
+RUN chmod +x /opt/xos/tools/xos-manage \
+ && mkdir -p /opt/cord_profile /opt/xos_services /opt/xos_libraries \
+ && sync \
+ && /opt/xos/tools/xos-manage genkeys
+
+# Set environment variables
+ENV HOME /root
+
+# Define working directory
+WORKDIR /opt/xos
+
 # Label image
 ARG org_label_schema_schema_version=1.0
 ARG org_label_schema_name=xos
@@ -18,16 +32,3 @@
       org.label-schema.build-date=$org_label_schema_build_date \
       org.opencord.vcs-commit-date=$org_opencord_vcs_commit_date
 
-# Install XOS
-ADD xos /opt/xos
-
-RUN chmod +x /opt/xos/tools/xos-manage \
- && mkdir -p /opt/cord_profile /opt/xos_services /opt/xos_libraries \
- && sync \
- && /opt/xos/tools/xos-manage genkeys
-
-# Set environment variables
-ENV HOME /root
-
-# Define working directory
-WORKDIR /opt/xos
diff --git a/containers/xos/Dockerfile.synchronizer-base b/containers/xos/Dockerfile.synchronizer-base
index 33a42a3..7474693 100644
--- a/containers/xos/Dockerfile.synchronizer-base
+++ b/containers/xos/Dockerfile.synchronizer-base
@@ -1,6 +1,13 @@
 # xosproject/xos-synchronizer-base
 FROM xosproject/xos-client:candidate
 
+ADD xos/synchronizers/new_base /opt/xos/synchronizers/new_base
+ADD xos/xos/config.py /opt/xos/xos/config.py
+ADD xos/xos/logger.py /opt/xos/xos/logger.py
+ADD xos/xos/xml_util.py /opt/xos/xos/xml_util.py
+ADD xos/xos/__init__.py /opt/xos/xos/__init__.py
+ADD xos/synchronizers/__init__.py /opt/xos/synchronizers/__init__.py
+
 # Label image
 ARG org_label_schema_schema_version=1.0
 ARG org_label_schema_name=xos-synchronizer-base
@@ -18,11 +25,5 @@
       org.label-schema.build-date=$org_label_schema_build_date \
       org.opencord.vcs-commit-date=$org_opencord_vcs_commit_date
 
-ADD xos/synchronizers/new_base /opt/xos/synchronizers/new_base
-ADD xos/xos/config.py /opt/xos/xos/config.py
-ADD xos/xos/logger.py /opt/xos/xos/logger.py
-ADD xos/xos/xml_util.py /opt/xos/xos/xml_util.py
-ADD xos/xos/__init__.py /opt/xos/xos/__init__.py
-ADD xos/synchronizers/__init__.py /opt/xos/synchronizers/__init__.py
-
 ENTRYPOINT ["bash"]
+
diff --git a/containers/xos/Dockerfile.test b/containers/xos/Dockerfile.test
index 6bd9c62..36edcbc 100644
--- a/containers/xos/Dockerfile.test
+++ b/containers/xos/Dockerfile.test
@@ -1,6 +1,20 @@
 # xosproject/xos-test
 FROM xosproject/xos:candidate
 
+# install nodejs
+COPY containers/xos/nodesource.gpg.key /tmp/nodesource.gpg.key
+
+RUN apt-key add /tmp/nodesource.gpg.key \
+ && echo "deb https://deb.nodesource.com/node_4.x trusty main" \
+    > /etc/apt/sources.list.d/nodesource.list \
+ && apt-get update \
+ && apt-get install -y --force-yes \
+    nodejs \
+ && rm -rf /var/lib/apt/lists/* \
+ && node -v \
+ && pip install selenium \
+ && npm install -g phantomjs
+
 # Label image
 ARG org_label_schema_schema_version=1.0
 ARG org_label_schema_name=xos-test
@@ -18,20 +32,3 @@
       org.label-schema.build-date=$org_label_schema_build_date \
       org.opencord.vcs-commit-date=$org_opencord_vcs_commit_date
 
-# install nodejs
-COPY containers/xos/nodesource.gpg.key /tmp/nodesource.gpg.key
-
-RUN apt-key add /tmp/nodesource.gpg.key \
- && echo "deb https://deb.nodesource.com/node_4.x trusty main" \
-    > /etc/apt/sources.list.d/nodesource.list
-
-RUN apt-get update \
- && apt-get install -y --force-yes \
-    nodejs \
- && rm -rf /var/lib/apt/lists/*
-
-RUN node -v
-
-RUN pip install selenium
-
-RUN npm install -g phantomjs
diff --git a/containers/xos/Dockerfile.xos b/containers/xos/Dockerfile.xos
index a92560e..7b2f9dd 100644
--- a/containers/xos/Dockerfile.xos
+++ b/containers/xos/Dockerfile.xos
@@ -1,6 +1,20 @@
 # xosproject/xos
 FROM xosproject/xos-base:candidate
 
+# Install XOS
+ADD xos /opt/xos
+
+RUN chmod +x /opt/xos/tools/xos-manage \
+ && mkdir -p /opt/cord_profile /opt/xos_services /opt/xos_libraries \
+ && sync \
+ && /opt/xos/tools/xos-manage genkeys
+
+# Set environment variables
+ENV HOME /root
+
+# Define working directory
+WORKDIR /opt/xos
+
 # Label image
 ARG org_label_schema_schema_version=1.0
 ARG org_label_schema_name=xos
@@ -18,16 +32,3 @@
       org.label-schema.build-date=$org_label_schema_build_date \
       org.opencord.vcs-commit-date=$org_opencord_vcs_commit_date
 
-# Install XOS
-ADD xos /opt/xos
-
-RUN chmod +x /opt/xos/tools/xos-manage \
- && mkdir -p /opt/cord_profile /opt/xos_services /opt/xos_libraries \
- && sync \
- && /opt/xos/tools/xos-manage genkeys
-
-# Set environment variables
-ENV HOME /root
-
-# Define working directory
-WORKDIR /opt/xos
diff --git a/containers/xos/pip_requirements.txt b/containers/xos/pip_requirements.txt
index 80a882d..b47ae86 100644
--- a/containers/xos/pip_requirements.txt
+++ b/containers/xos/pip_requirements.txt
@@ -1,19 +1,18 @@
-pytz==2016.6.1
+pytz==2017.2
 Babel==2.3.4
-Django==1.8.17
-Jinja2==2.8
-Markdown==2.6.6
-MarkupSafe==0.23
+Django==1.8.18
+Jinja2==2.9.6
+Markdown==2.6.8
+MarkupSafe==1.0
 Paste==2.0.3
 PasteDeploy==1.5.2
 PyYAML==3.12
 Routes==2.3.1
 WebOb==1.6.1
 amqp==1.4.9
-ansible==2.2.1.0
+ansible==2.2.2.0
 anyjson==0.3.3
 appdirs==1.4.0
-argparse==1.2.1
 backports.ssl-match-hostname==3.5.0.1
 ca-certs-locater==1.0
 cachetools==1.1.6
@@ -101,7 +100,7 @@
 pika-pool==0.1.3
 positional==1.1.1
 prettytable==0.7.2
-protobuf==3.1.0.post1
+protobuf==3.2.0
 psycopg2==2.6.2
 pyOpenSSL==16.1.0
 pyasn1==0.1.9