You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by de...@apache.org on 2018/06/14 18:05:12 UTC

[trafficcontrol] branch master updated (0a37234 -> a40a35a)

This is an automated email from the ASF dual-hosted git repository.

dewrich pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git.


    from 0a37234  Validate that STEERING_GEO targets are only used in CLIENT_STEERING DSes
     new a95758d  start with docker
     new 98d6027  separate perl and go containers
     new e068e34  straighten out vars; write configs
     new 4b9b589  setup db
     new c65ea06  clean up dockerfile
     new 43d86b5  use one network; better readiness check
     new b9f8784  add rpm to .gitignore
     new 581bf6b  create dbconf.yml
     new a14fef8  config fixes
     new 36d86a9  perl script to create sql for new user with encrypted password.
     new 48fa05b  reset, seed, add admin user
     new 138c562  add README.md for cdn-in-a-box
     new 48241e0  move adduser.pl to where docker can pick up
     new a71c1c5  expose TO perl portto docker host
     new 7b58548  update comments
     new 2d1b8eb  move compose file up
     new d5992b2  add missing license text
     new 81e0b34  remove unused profile (for now)
     new 840d27e  add basic usage
     new a40a35a  fix issues from review

The 20 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../cdn-in-a-box}/README.md                        |  22 ++--
 infrastructure/cdn-in-a-box/docker-compose.yml     |  92 +++++++++++++++
 infrastructure/cdn-in-a-box/traffic_ops/.gitignore |   1 +
 .../traffic_ops/Dockerfile                         |  52 ++++-----
 .../traffic_ops/Dockerfile-go}                     |  26 +++--
 infrastructure/cdn-in-a-box/traffic_ops/adduser.pl |  48 ++++++++
 infrastructure/cdn-in-a-box/traffic_ops/config.sh  | 128 +++++++++++++++++++++
 .../cdn-in-a-box/traffic_ops/run-go.sh             |  56 ++++++---
 infrastructure/cdn-in-a-box/traffic_ops/run.sh     |  74 ++++++++++++
 .../cdn-in-a-box/variables.env                     |  25 +++-
 10 files changed, 450 insertions(+), 74 deletions(-)
 copy {traffic_server/plugins/astats_over_http => infrastructure/cdn-in-a-box}/README.md (60%)
 create mode 100644 infrastructure/cdn-in-a-box/docker-compose.yml
 create mode 100644 infrastructure/cdn-in-a-box/traffic_ops/.gitignore
 copy infrastructure/{docker => cdn-in-a-box}/traffic_ops/Dockerfile (52%)
 copy infrastructure/{docker/traffic_ops/dbInit.sh => cdn-in-a-box/traffic_ops/Dockerfile-go} (66%)
 mode change 100755 => 100644
 create mode 100755 infrastructure/cdn-in-a-box/traffic_ops/adduser.pl
 create mode 100755 infrastructure/cdn-in-a-box/traffic_ops/config.sh
 copy traffic_ops/testing/api/docker/run_api_tests.sh => infrastructure/cdn-in-a-box/traffic_ops/run-go.sh (51%)
 create mode 100755 infrastructure/cdn-in-a-box/traffic_ops/run.sh
 copy traffic_ops/testing/api/docker/traffic-ops-test.env => infrastructure/cdn-in-a-box/variables.env (71%)

-- 
To stop receiving notification emails like this one, please contact
dewrich@apache.org.

[trafficcontrol] 14/20: expose TO perl portto docker host

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit a71c1c58d3bc14d9e6307616723142f5e01cb5df
Author: Dan Kirkwood <da...@gmail.com>
AuthorDate: Tue Jun 12 22:40:51 2018 +0000

    expose TO perl portto docker host
---
 infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml b/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml
index 04435ac..50ba196 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml
+++ b/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml
@@ -63,8 +63,9 @@ services:
       - tcnet
     env_file:
       - variables.env
-    expose: 
-      - "60443"
+    # TODO: change to expose: "60443" to limit to containers
+    ports: 
+      - "60443:60443"
     build:
       context: .
       args:

-- 
To stop receiving notification emails like this one, please contact
dewrich@apache.org.

[trafficcontrol] 08/20: create dbconf.yml

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit 581bf6b7200423876dc349276a5956dbaa89d303
Author: Dan Kirkwood <da...@gmail.com>
AuthorDate: Mon Jun 4 20:55:29 2018 +0000

    create dbconf.yml
---
 .../cdn-in-a-box/traffic_ops/Dockerfile-dbinit     | 34 ----------------------
 infrastructure/cdn-in-a-box/traffic_ops/config.sh  | 22 +++++++++-----
 infrastructure/cdn-in-a-box/traffic_ops/dbInit.sh  | 31 --------------------
 .../cdn-in-a-box/traffic_ops/docker-compose.yml    | 17 ++++-------
 infrastructure/cdn-in-a-box/traffic_ops/run-go.sh  |  3 ++
 infrastructure/cdn-in-a-box/traffic_ops/run.sh     | 11 +++----
 .../cdn-in-a-box/traffic_ops/variables.env         |  1 +
 7 files changed, 29 insertions(+), 90 deletions(-)

diff --git a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-dbinit b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-dbinit
deleted file mode 100644
index 8c92b79..0000000
--- a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-dbinit
+++ /dev/null
@@ -1,34 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-############################################################
-# Dockerfile to initialized Traffic Ops Database container 
-# Based on CentOS 7.2
-############################################################
-
-FROM centos/systemd
-
-RUN yum install -y https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-redhat96-9.6-3.noarch.rpm
-
-RUN yum -y install \
-  postgresql96 \
-  nmap-ncat \
-  cpanminus && \
-  yum clean all
-
-ADD dbInit.sh /
-CMD /dbInit.sh
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/config.sh b/infrastructure/cdn-in-a-box/traffic_ops/config.sh
index dfccc23..3c2efe0 100755
--- a/infrastructure/cdn-in-a-box/traffic_ops/config.sh
+++ b/infrastructure/cdn-in-a-box/traffic_ops/config.sh
@@ -42,13 +42,6 @@ do
 	if [[ -z $$v ]]; then echo "$v is unset"; exit 1; fi
 done
 
-key=/server.key
-crt=/server.crt
-
-useradd -M trafops
-openssl req -newkey rsa:2048 -nodes -keyout $key -x509 -days 365 -out $crt -subj "/C=$CERT_COUNTRY/ST=$CERT_STATE/L=$CERT_CITY/O=$CERT_COMPANY"
-chown trafops:trafops $key $crt
-
 cat <<-EOF >/opt/traffic_ops/app/conf/cdn.conf
 {
     "hypnotoad" : {
@@ -117,3 +110,18 @@ cat <<-EOF >/opt/traffic_ops/app/conf/production/database.conf
         "type": "Pg"
 }
 EOF
+
+cat <<-EOF >/opt/traffic_ops/app/db/dbconf.yml
+version: "1.0"
+name: dbconf.yml
+
+production:
+  driver: postgres
+  open: host=$DB_SERVER port=$DB_PORT user=$DB_USER password=$DB_USER_PASS dbname=$DB_NAME sslmode=disable
+EOF
+
+key=/server.key
+crt=/server.crt
+
+openssl req -newkey rsa:2048 -nodes -keyout $key -x509 -days 365 -out $crt -subj "/C=$CERT_COUNTRY/ST=$CERT_STATE/L=$CERT_CITY/O=$CERT_COMPANY"
+chown trafops:trafops $key $crt
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/dbInit.sh b/infrastructure/cdn-in-a-box/traffic_ops/dbInit.sh
deleted file mode 100755
index 2398f0c..0000000
--- a/infrastructure/cdn-in-a-box/traffic_ops/dbInit.sh
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-############################################################
-# Script for creating the database user account for traffic
-# ops. 
-# Used while the Docker Image is initializing itself
-############################################################
-
-while ! nc $DB_SERVER $DB_PORT </dev/null; do # &>/dev/null; do
-        echo "waiting for $DB_SERVER:$DB_PORT"
-        sleep 3
-done
-
-psql -h $DB_SERVER -U postgres -c "CREATE USER $DB_USER WITH ENCRYPTED PASSWORD '$DB_USER_PASS'"
-createdb $DB_NAME -h $DB_SERVER -U postgres --owner $DB_USER
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml b/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml
index 579403c..04435ac 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml
+++ b/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml
@@ -44,6 +44,8 @@ networks:
 
 services:
   db:
+    hostname: db
+    domainname: cdn.local
     image: postgres:9.6.6
     networks:
       - tcnet
@@ -53,18 +55,9 @@ services:
     ports: 
       - "5432:5432"
 
-  dbinit:
-    networks:
-      - tcnet
-    env_file:
-      - variables.env
-    build:
-      context: .
-      dockerfile: Dockerfile-dbinit
-    depends_on: 
-      - db
-
   trafficops-perl:
+    hostname: trafficops-perl
+    domainname: cdn.local
     image: trafficops-perl
     networks:
       - tcnet
@@ -80,6 +73,8 @@ services:
       - db
 
   trafficops:
+    hostname: trafficops
+    domainname: cdn.local
     image: trafficops-go
     networks:
       - tcnet
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/run-go.sh b/infrastructure/cdn-in-a-box/traffic_ops/run-go.sh
index 284ba60..fe5af6a 100755
--- a/infrastructure/cdn-in-a-box/traffic_ops/run-go.sh
+++ b/infrastructure/cdn-in-a-box/traffic_ops/run-go.sh
@@ -62,3 +62,6 @@ CDNCONF=/opt/traffic_ops/app/conf/cdn.conf
 DBCONF=/opt/traffic_ops/app/conf/production/database.conf
 mkdir -p /var/log/traffic_ops
 ./bin/traffic_ops_golang -cfg $CDNCONF -dbcfg $DBCONF
+
+cat /var/log/traffic_ops/*
+tail -f /dev/null
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/run.sh b/infrastructure/cdn-in-a-box/traffic_ops/run.sh
index c635ae3..46821c5 100755
--- a/infrastructure/cdn-in-a-box/traffic_ops/run.sh
+++ b/infrastructure/cdn-in-a-box/traffic_ops/run.sh
@@ -55,17 +55,14 @@ while ! nc $DB_SERVER $DB_PORT </dev/null; do # &>/dev/null; do
         sleep 3
 done
 
-while true; do
-	echo "Checking for existence of role $DB_USER"
-	psql -U postgres -h $DB_SERVER -p $DB_PORT postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='$DB_USER'" | grep -q 1 && break
-	sleep 3
-done
-
 TO_DIR=/opt/traffic_ops/app
 cat conf/production/database.conf
 
 export PERL5LIB=$TO_DIR/lib:$TO_DIR/local/lib/perl5
-cd $TO_DIR && ./db/admin.pl -env production reset
+export PATH=/usr/local/go/bin:/opt/traffic_ops/go/bin:$PATH
+export GOPATH=/opt/traffic_ops/go
+
+cd $TO_DIR && ./db/admin.pl --env=production reset || echo "DB reset failed!"
 
 cd $TO_DIR && $TO_DIR/local/bin/hypnotoad script/cdn
 exec tail -f /var/log/traffic_ops/traffic_ops.log
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/variables.env b/infrastructure/cdn-in-a-box/traffic_ops/variables.env
index 1ca486b..bde6dc3 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops/variables.env
+++ b/infrastructure/cdn-in-a-box/traffic_ops/variables.env
@@ -4,6 +4,7 @@ CERT_COMPANY=NotComcast
 CERT_COUNTRY=US
 CERT_STATE=CO
 DB_NAME=traffic_ops
+DB_ROOT_PASS=twelve
 DB_USER_PASS=twelve
 DB_PORT=5432
 DB_SERVER=db

-- 
To stop receiving notification emails like this one, please contact
dewrich@apache.org.

[trafficcontrol] 04/20: setup db

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit 4b9b5895b3edd3f05aeae3f488b742cf1382dde4
Author: Dan Kirkwood <da...@gmail.com>
AuthorDate: Fri Jun 1 18:26:50 2018 +0000

    setup db
---
 infrastructure/cdn-in-a-box/traffic_ops/config.sh |  4 +---
 infrastructure/cdn-in-a-box/traffic_ops/run.sh    | 16 ++++++----------
 2 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/infrastructure/cdn-in-a-box/traffic_ops/config.sh b/infrastructure/cdn-in-a-box/traffic_ops/config.sh
index a7217fd..dfccc23 100755
--- a/infrastructure/cdn-in-a-box/traffic_ops/config.sh
+++ b/infrastructure/cdn-in-a-box/traffic_ops/config.sh
@@ -45,6 +45,7 @@ done
 key=/server.key
 crt=/server.crt
 
+useradd -M trafops
 openssl req -newkey rsa:2048 -nodes -keyout $key -x509 -days 365 -out $crt -subj "/C=$CERT_COUNTRY/ST=$CERT_STATE/L=$CERT_CITY/O=$CERT_COMPANY"
 chown trafops:trafops $key $crt
 
@@ -116,6 +117,3 @@ cat <<-EOF >/opt/traffic_ops/app/conf/production/database.conf
         "type": "Pg"
 }
 EOF
-
-cat /opt/traffic_ops/app/conf/cdn.conf
-cat /opt/traffic_ops/app/conf/production/database.conf
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/run.sh b/infrastructure/cdn-in-a-box/traffic_ops/run.sh
index 14cc836..b56d6f4 100755
--- a/infrastructure/cdn-in-a-box/traffic_ops/run.sh
+++ b/infrastructure/cdn-in-a-box/traffic_ops/run.sh
@@ -55,12 +55,12 @@ while true; do
 	sleep 3
 done
 
-start() {
-	TO_DIR=/opt/traffic_ops/app
-	export PERL5LIB=$TO_DIR/lib:$TO_DIR/local/lib/perl5
-	cd $TO_DIR && $TO_DIR/local/bin/hypnotoad script/cdn
-	exec tail -f /var/log/traffic_ops/traffic_ops.log
-}
+TO_DIR=/opt/traffic_ops/app
+export PERL5LIB=$TO_DIR/lib:$TO_DIR/local/lib/perl5
+cd $TO_DIR && ./db/admin.pl -env production reset
+
+cd $TO_DIR && $TO_DIR/local/bin/hypnotoad script/cdn
+exec tail -f /var/log/traffic_ops/traffic_ops.log
 
 init() {
 	TRAFFIC_OPS_URI="https://localhost"
@@ -101,7 +101,3 @@ init() {
 
 	echo "INITIALIZED=1" >> /etc/environment
 }
-
-source /etc/environment
-#if [ -z "$INITIALIZED" ]; then init; fi
-start

-- 
To stop receiving notification emails like this one, please contact
dewrich@apache.org.

[trafficcontrol] 18/20: remove unused profile (for now)

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit 81e0b34c8b5c0d266ca854a961e92c759ce3593a
Author: Dan Kirkwood <da...@apache.org>
AuthorDate: Thu Jun 14 10:49:34 2018 -0600

    remove unused profile (for now)
---
 infrastructure/cdn-in-a-box/traffic_ops/Dockerfile |  1 -
 .../traffic_ops/profile.origin.traffic_ops         | 18 ----------
 infrastructure/cdn-in-a-box/traffic_ops/run.sh     | 40 ----------------------
 3 files changed, 59 deletions(-)

diff --git a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
index dd4ea75..36b3c06 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
+++ b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
@@ -65,7 +65,6 @@ RUN echo "{\"user\": \"riakuser\",\"password\": \"$TRAFFIC_VAULT_PASS\"}" > /opt
 EXPOSE 443
 WORKDIR /opt/traffic_ops/app
 ENV MOJO_MODE production
-ADD profile.origin.traffic_ops /
 
 ADD adduser.pl /
 ADD config.sh /
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/profile.origin.traffic_ops b/infrastructure/cdn-in-a-box/traffic_ops/profile.origin.traffic_ops
deleted file mode 100644
index f655f89..0000000
--- a/infrastructure/cdn-in-a-box/traffic_ops/profile.origin.traffic_ops
+++ /dev/null
@@ -1,18 +0,0 @@
-{
-    "parameters": [
-        {
-            "config_file": "CRConfig.json",
-            "name": "domain_name",
-            "value": "{{.Domain}}"
-        },
-        {
-            "config_file": "parent.config",
-            "name": "weight",
-            "value": "1.0"
-        }
-    ],
-    "profile": {
-        "description": "Multi site origin profile 1",
-        "name": "ORG1_CDN1"
-    }
-}
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/run.sh b/infrastructure/cdn-in-a-box/traffic_ops/run.sh
index 7897d02..7126ac7 100755
--- a/infrastructure/cdn-in-a-box/traffic_ops/run.sh
+++ b/infrastructure/cdn-in-a-box/traffic_ops/run.sh
@@ -70,43 +70,3 @@ cd $TO_DIR && \
 
 cd $TO_DIR && $TO_DIR/local/bin/hypnotoad script/cdn
 exec tail -f /var/log/traffic_ops/traffic_ops.log
-
-init() {
-	TRAFFIC_OPS_URI="https://localhost"
-
-	COOKIE="$(curl -v -s -k -X POST --data '{ "u":"'"$ADMIN_USER"'", "p":"'"$ADMIN_PASS"'" }' $TRAFFIC_OPS_URI/api/1.2/user/login 2>&1 | grep 'Set-Cookie' | sed -e 's/.*mojolicious=\(.*\); expires.*/\1/')"
-	echo "Got cookie: $COOKIE"
-
-	TMP_DOMAIN=$DOMAIN
-	sed -i -- "s/{{.Domain}}/$TMP_DOMAIN/g" /profile.origin.traffic_ops
-	echo "Got domain: $TMP_DOMAIN"
-
-	echo "Importing origin"
-	curl -v -k -X POST -H "Cookie: mojolicious=$COOKIE" -F "filename=profile.origin.traffic_ops" -F "profile_to_import=@/profile.origin.traffic_ops" $TRAFFIC_OPS_URI/profile/doImport
-
-	curl -v -k -X POST -H "Cookie: mojolicious=$COOKIE" --data-urlencode "division.name=East" $TRAFFIC_OPS_URI/division/create
-	TMP_DIVISION_ID="$(curl -s -k -X GET -H "Cookie: mojolicious=$COOKIE" $TRAFFIC_OPS_URI/region/add | grep --color=never -oE "<option value=\"[0-9]+\">East</option>" | grep --color=never -oE "[0-9]+")"
-	echo "Got division ID: $TMP_DIVISION_ID"
-
-	curl -v -k -X POST -H "Cookie: mojolicious=$COOKIE" --data-urlencode "region.name=Eastish" --data-urlencode "region.division_id=$TMP_DIVISION_ID" $TRAFFIC_OPS_URI/region/create
-	TMP_REGION_ID="$(curl -s -k -X GET -H "Cookie: mojolicious=$COOKIE" $TRAFFIC_OPS_URI/api/1.2/regions.json | python -c 'import json,sys;obj=json.load(sys.stdin);match=[x["id"] for x in obj["response"] if x["name"]=="Eastish"]; print match[0]')"
-	echo "Got region ID: $TMP_REGION_ID"
-
-	TMP_CACHEGROUP_TYPE="$(curl -s -k -X GET -H "Cookie: mojolicious=$COOKIE" $TRAFFIC_OPS_URI/api/1.2/types.json | python -c 'import json,sys;obj=json.load(sys.stdin);match=[x["id"] for x in obj["response"] if x["name"]=="MID_LOC"]; print match[0]')"
-	echo "Got cachegroup type ID: $TMP_CACHEGROUP_TYPE"
-
-	curl -v -k -X POST -H "Cookie: mojolicious=$COOKIE" --data-urlencode "cg_data.name=mid-east" --data-urlencode "cg_data.short_name=east" --data-urlencode "cg_data.latitude=0" --data-urlencode "cg_data.longitude=0" --data-urlencode "cg_data.parent_cachegroup_id=-1" --data-urlencode "cg_data.type=$TMP_CACHEGROUP_TYPE" $TRAFFIC_OPS_URI/cachegroup/create
-	TMP_CACHEGROUP_ID="$(curl -s -k -X GET -H "Cookie: mojolicious=$COOKIE" $TRAFFIC_OPS_URI/api/1.2/cachegroups.json | python -c 'import json,sys;obj=json.load(sys.stdin);match=[x["id"] for x in obj["response"] if x["name"]=="mid-east"]; print match[0]')"
-	echo "Got cachegroup ID: $TMP_CACHEGROUP_ID"
-
-	TMP_CACHEGROUP_EDGE_TYPE="$(curl -s -k -X GET -H "Cookie: mojolicious=$COOKIE" $TRAFFIC_OPS_URI/api/1.2/types.json | python -c 'import json,sys;obj=json.load(sys.stdin);match=[x["id"] for x in obj["response"] if x["name"]=="EDGE_LOC"]; print match[0]')"
-	echo "Got cachegroup type ID: $TMP_CACHEGROUP_EDGE_TYPE"
-
-	curl -v -k -X POST -H "Cookie: mojolicious=$COOKIE" --data-urlencode "cg_data.name=edge-east" --data-urlencode "cg_data.short_name=eeast" --data-urlencode "cg_data.latitude=0" --data-urlencode "cg_data.longitude=0" --data-urlencode "cg_data.parent_cachegroup_id=$TMP_CACHEGROUP_ID" --data-urlencode "cg_data.type=$TMP_CACHEGROUP_EDGE_TYPE" $TRAFFIC_OPS_URI/cachegroup/create
-	TMP_CACHEGROUP_EDGE_ID="$(curl -s -k -X GET -H "Cookie: mojolicious=$COOKIE" $TRAFFIC_OPS_URI/api/1.2/cachegroups.json | python -c 'import json,sys;obj=json.load(sys.stdin);match=[x["id"] for x in obj["response"] if x["name"]=="edge-east"]; print match[0]')"
-	echo "Got cachegroup edge ID: $TMP_CACHEGROUP_EDGE_ID"
-
-	curl -v -k -X POST -H "Cookie: mojolicious=$COOKIE" --data-urlencode "location.name=plocation-nyc-1" --data-urlencode "location.short_name=nyc" --data-urlencode "location.address=1 Main Street" --data-urlencode "location.city=nyc" --data-urlencode "location.state=NY" --data-urlencode "location.zip=12345" --data-urlencode "location.poc=" --data-urlencode "location.phone=" --data-urlencode "location.email=no@no.no" --data-urlencode "location.comments=" --data-urlencode "location.region=$T [...]
-
-	echo "INITIALIZED=1" >> /etc/environment
-}

-- 
To stop receiving notification emails like this one, please contact
dewrich@apache.org.

[trafficcontrol] 06/20: use one network; better readiness check

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit 43d86b562e304c73a8b65abef1e30721dd9d8dc8
Author: Dan Kirkwood <da...@gmail.com>
AuthorDate: Fri Jun 1 22:10:16 2018 +0000

    use one network; better readiness check
---
 .../cdn-in-a-box/traffic_ops/docker-compose.yml    | 25 +++++++---------------
 infrastructure/cdn-in-a-box/traffic_ops/run.sh     | 12 +++++++++--
 2 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml b/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml
index 23f91ee..579403c 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml
+++ b/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml
@@ -33,7 +33,7 @@
 version: '2.1'
 
 networks:
-  dbnet:
+  tcnet:
     driver: bridge
     enable_ipv6: true
     ipam:
@@ -41,20 +41,12 @@ networks:
       config:
         - subnet: 172.13.239.0/24
         - subnet: "fc01:9400:1000:8::/64"
-  trafficopsnet:
-    driver: bridge
-    enable_ipv6: true
-    ipam:
-      driver: default
-      config:
-        - subnet: 172.13.238.0/24
-        - subnet: "fc01:9400:1000:7::/64"
 
 services:
   db:
     image: postgres:9.6.6
     networks:
-      - dbnet
+      - tcnet
     env_file:
       - variables.env
     # TODO: change to expose: "5432" to limit to containers
@@ -63,7 +55,7 @@ services:
 
   dbinit:
     networks:
-      - dbnet
+      - tcnet
     env_file:
       - variables.env
     build:
@@ -75,8 +67,7 @@ services:
   trafficops-perl:
     image: trafficops-perl
     networks:
-      - dbnet
-      - trafficopsnet
+      - tcnet
     env_file:
       - variables.env
     expose: 
@@ -86,13 +77,12 @@ services:
       args:
         RPM: traffic_ops.rpm 
     depends_on:
-      - dbinit
+      - db
 
   trafficops:
     image: trafficops-go
     networks:
-      - dbnet
-      - trafficopsnet
+      - tcnet
     env_file:
       - variables.env
     ports: 
@@ -101,4 +91,5 @@ services:
       context: .
       dockerfile: Dockerfile-go
     depends_on:
-      - dbinit
+      - db
+      - trafficops-perl
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/run.sh b/infrastructure/cdn-in-a-box/traffic_ops/run.sh
index b56d6f4..c635ae3 100755
--- a/infrastructure/cdn-in-a-box/traffic_ops/run.sh
+++ b/infrastructure/cdn-in-a-box/traffic_ops/run.sh
@@ -45,10 +45,16 @@ do
 done
 
 # Write config files
-if [[ -x /config.sh ]]; then
-	/config.sh
+set -x
+if [[ -r /config.sh ]]; then
+	. /config.sh
 fi
 
+while ! nc $DB_SERVER $DB_PORT </dev/null; do # &>/dev/null; do
+        echo "waiting for $DB_SERVER $DB_PORT"
+        sleep 3
+done
+
 while true; do
 	echo "Checking for existence of role $DB_USER"
 	psql -U postgres -h $DB_SERVER -p $DB_PORT postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='$DB_USER'" | grep -q 1 && break
@@ -56,6 +62,8 @@ while true; do
 done
 
 TO_DIR=/opt/traffic_ops/app
+cat conf/production/database.conf
+
 export PERL5LIB=$TO_DIR/lib:$TO_DIR/local/lib/perl5
 cd $TO_DIR && ./db/admin.pl -env production reset
 

-- 
To stop receiving notification emails like this one, please contact
dewrich@apache.org.

[trafficcontrol] 12/20: add README.md for cdn-in-a-box

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit 138c56254c9204dae91f2a37bde62b8bee7918cd
Author: Dan Kirkwood <da...@gmail.com>
AuthorDate: Thu Jun 7 23:26:16 2018 +0000

    add README.md for cdn-in-a-box
---
 infrastructure/cdn-in-a-box/README.md | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/infrastructure/cdn-in-a-box/README.md b/infrastructure/cdn-in-a-box/README.md
new file mode 100644
index 0000000..1f38a9e
--- /dev/null
+++ b/infrastructure/cdn-in-a-box/README.md
@@ -0,0 +1,35 @@
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+
+CDN In a Box (containerized)
+============================
+
+This is intended to simplify the process of creating a "CDN in a box",  easing
+the barrier to entry for newcomers as well as providing a way to spin up a
+minimal CDN for full system testing.
+
+For now,  only `traffic_ops` is implemented.  Other components will follow as well
+as details on specific parts of the implementation.. 
+
+To start it, install `docker-ce` and `docker-compose` and simply:
+
+    cd infrastructure/cdn-in-a-box/traffic_ops
+    docker-compose up --build
+
+

-- 
To stop receiving notification emails like this one, please contact
dewrich@apache.org.

[trafficcontrol] 15/20: update comments

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit 7b58548adb00a59c4fa50aa1cfb5a5e355d7382a
Author: Dan Kirkwood <da...@apache.org>
AuthorDate: Thu Jun 14 09:54:50 2018 -0600

    update comments
---
 .../cdn-in-a-box/traffic_ops/docker-compose.yml         | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml b/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml
index 50ba196..fe6b1ca 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml
+++ b/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml
@@ -17,17 +17,18 @@
 #
 # To use this compose you should first build Traffic Ops and then copy the RPM to :
 #
-# incubator-trafficcontrol/infrastructure/docker/traffic_ops/traffic_ops.rpm
+# incubator-trafficcontrol/infrastructure/cdn-in-a-box/traffic_ops/traffic_ops.rpm
 #
-# You should then just be able to go to the directory incubator-trafficcontrol/infrastructure/docker/traffic_ops/
-# and type 'docker-compose up -d'
+#      cd incubator-trafficcontrol/infrastructure/cdn-in-a-box
+#  
+# Adjust the settings in `variables.env` to suit your needs.
 #
-# You should then be able to go to https://localhost and test Traffic Ops or the go api.
-# if you make code changes to the Go proxy then you just need to rebuild it and then
-# restart Traffic Ops:
+#      docker-compose up -d
 #
-# bash -c "clear && docker exec trafficops_to_server_1 /bin/bash /etc/init.d/traffic_ops /bin/bash /etc/init.d/traffic_ops start; sleep 5"
+# The Traffic Ops Go API will then be available on https://localhost:8443,
+# the Perl API on https://localhost:60443, and the postgres database on localhost 5432.
 #
+# Note that this setup is intended for testing and not for production use.
 
 ---
 version: '2.1'
@@ -82,7 +83,7 @@ services:
     env_file:
       - variables.env
     ports: 
-      - "443:443"
+      - "8443:443"
     build:
       context: .
       dockerfile: Dockerfile-go

-- 
To stop receiving notification emails like this one, please contact
dewrich@apache.org.

[trafficcontrol] 11/20: reset, seed, add admin user

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit 48fa05bbd12b4258745dd45e7af7a405b8e49230
Author: Dan Kirkwood <da...@gmail.com>
AuthorDate: Thu Jun 7 23:16:57 2018 +0000

    reset, seed, add admin user
---
 infrastructure/cdn-in-a-box/traffic_ops/run.sh | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/infrastructure/cdn-in-a-box/traffic_ops/run.sh b/infrastructure/cdn-in-a-box/traffic_ops/run.sh
index be60d71..d4b23e3 100755
--- a/infrastructure/cdn-in-a-box/traffic_ops/run.sh
+++ b/infrastructure/cdn-in-a-box/traffic_ops/run.sh
@@ -62,8 +62,11 @@ export PERL5LIB=$TO_DIR/lib:$TO_DIR/local/lib/perl5
 export PATH=/usr/local/go/bin:/opt/traffic_ops/go/bin:$PATH
 export GOPATH=/opt/traffic_ops/go
 
-cd $TO_DIR && ./db/admin.pl --env=production reset || echo "DB reset failed!"
-./db/adduser.pl $TO_ADMIN_USER $TO_ADMIN_PASSWORD | psql -U$DB_USER -h$DB_SERVER $DB_NAME || echo "adding traffic_ops admin user failed!"
+cd $TO_DIR && \
+	./db/admin.pl --env=production reset && \
+	./db/admin.pl --env=production seed || echo "db setup failed!"
+
+./db/adduser.pl $TO_ADMIN_USER $TO_ADMIN_PASSWORD admin | psql -U$DB_USER -h$DB_SERVER $DB_NAME || echo "adding traffic_ops admin user failed!"
 
 cd $TO_DIR && $TO_DIR/local/bin/hypnotoad script/cdn
 exec tail -f /var/log/traffic_ops/traffic_ops.log

-- 
To stop receiving notification emails like this one, please contact
dewrich@apache.org.

[trafficcontrol] 19/20: add basic usage

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit 840d27e9a178567216da720c6e32c756b4b83e96
Author: Dan Kirkwood <da...@apache.org>
AuthorDate: Thu Jun 14 10:55:50 2018 -0600

    add basic usage
---
 infrastructure/cdn-in-a-box/traffic_ops/adduser.pl | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/infrastructure/cdn-in-a-box/traffic_ops/adduser.pl b/infrastructure/cdn-in-a-box/traffic_ops/adduser.pl
index 57e1722..91f66c9 100755
--- a/infrastructure/cdn-in-a-box/traffic_ops/adduser.pl
+++ b/infrastructure/cdn-in-a-box/traffic_ops/adduser.pl
@@ -16,6 +16,10 @@
 # specific language governing permissions and limitations
 # under the License.
 
+# adduser.pl creates the sql necessary to add a user to the database for traffic_ops login.
+# Usage:   adduser.pl <username> <password> <role>
+#  -- the password is encrypted appropriately to be compatible with Traffic Ops.
+#
 use strict;
 use Crypt::ScryptKDF qw{ scrypt_hash };
 

-- 
To stop receiving notification emails like this one, please contact
dewrich@apache.org.

[trafficcontrol] 03/20: straighten out vars; write configs

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit e068e34b57fdf4350041b99e377a7fe92b9320d9
Author: Dan Kirkwood <da...@gmail.com>
AuthorDate: Fri Jun 1 16:35:17 2018 +0000

    straighten out vars; write configs
---
 infrastructure/cdn-in-a-box/traffic_ops/Dockerfile |   5 +
 .../cdn-in-a-box/traffic_ops/Dockerfile-dbinit     |   8 -
 .../cdn-in-a-box/traffic_ops/Dockerfile-go         |  10 +-
 infrastructure/cdn-in-a-box/traffic_ops/config.sh  | 121 +++++++++++
 infrastructure/cdn-in-a-box/traffic_ops/dbInit.sh  |   1 +
 .../cdn-in-a-box/traffic_ops/docker-compose.yml    |  66 +++---
 infrastructure/cdn-in-a-box/traffic_ops/run-go.sh  |  64 ++++++
 infrastructure/cdn-in-a-box/traffic_ops/run.sh     | 240 +++------------------
 .../cdn-in-a-box/traffic_ops/variables.env         |  20 ++
 9 files changed, 272 insertions(+), 263 deletions(-)

diff --git a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
index c176522..1ec9bcf 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
+++ b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
@@ -55,6 +55,9 @@ RUN export PERL5LIB=/opt/traffic_ops/app/local/lib/perl5/:/opt/traffic_ops/insta
 	&& export USER=root \
 	&& /opt/traffic_ops/install/bin/download_web_deps -i
 
+# TODO: move this up along with other yum's
+RUN yum -y install nmap-ncat openssl
+
 # \todo add Drive Letters to postinstall input
 # RUN sed -i -- 's/"value": "b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y"/"value": "0"/g' /opt/traffic_ops/install/data/profiles/profile.trafficserver_edge.traffic_ops
 # RUN sed -i -- 's/"value": "b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y"/"value": "0"/g' /opt/traffic_ops/install/data/profiles/profile.trafficserver_mid.traffic_ops
@@ -67,5 +70,7 @@ EXPOSE 443
 WORKDIR /opt/traffic_ops/app
 ENV MOJO_MODE production
 ADD profile.origin.traffic_ops /
+
+ADD config.sh /
 ADD run.sh /
 CMD /run.sh
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-dbinit b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-dbinit
index 9704aaa..8c92b79 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-dbinit
+++ b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-dbinit
@@ -30,13 +30,5 @@ RUN yum -y install \
   cpanminus && \
   yum clean all
 
-ENV POSTGRES_HOME $POSTGRES_HOME
-ENV PGPASSWORD $PGPASSWORD 
-ENV DB_USERNAME $DB_USERNAME
-ENV DB_NAME $DB_NAME
-ENV DB_USER_PASS $DB_USER_PASS 
-ENV DB_SERVER $DB_SERVER
-ENV DB_PORT $DB_PORT
-
 ADD dbInit.sh /
 CMD /dbInit.sh
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-go b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-go
index b7e8038..b270863 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-go
+++ b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-go
@@ -21,11 +21,15 @@
 ############################################################
 
 
-FROM traffic_ops:2.3.0 AS trafficops-perl
+FROM centos:7
+RUN yum -y install nmap-ncat openssl
 
-COPY --from=trafficops-perl /opt/traffic_ops/app/conf /opt/traffic_ops/app/conf
+RUN mkdir -p /opt/traffic_ops/app/bin /opt/traffic_ops/app/conf/production
 COPY --from=trafficops-perl /opt/traffic_ops/app/bin/traffic_ops_golang /opt/traffic_ops/app/bin/traffic_ops_golang 
 
 EXPOSE 443
 WORKDIR /opt/traffic_ops/app
-ENTRYPOINT bash
+
+ADD config.sh /
+ADD run-go.sh /
+CMD /run-go.sh
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/config.sh b/infrastructure/cdn-in-a-box/traffic_ops/config.sh
new file mode 100755
index 0000000..a7217fd
--- /dev/null
+++ b/infrastructure/cdn-in-a-box/traffic_ops/config.sh
@@ -0,0 +1,121 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Script for running the Dockerfile for Traffic Ops.
+# The Dockerfile sets up a Docker image which can be used for any new Traffic Ops container;
+# This script, which should be run when the container is run (it's the ENTRYPOINT), will configure the container.
+#
+# The following environment variables must be set, ordinarily by `docker run -e` arguments:
+# DB_SERVER
+# DB_PORT
+# DB_ROOT_PASS
+# DB_USER
+# DB_USER_PASS
+# DB_NAME
+# ADMIN_USER
+# ADMIN_PASS
+# CERT_COUNTRY
+# CERT_STATE
+# CERT_CITY
+# CERT_COMPANY
+# DOMAIN
+
+# Check that env vars are set
+envvars=( DB_SERVER DB_PORT DB_ROOT_PASS DB_USER DB_USER_PASS ADMIN_USER ADMIN_PASS CERT_COUNTRY CERT_STATE CERT_CITY CERT_COMPANY DOMAIN)
+for v in $envvars
+do
+	if [[ -z $$v ]]; then echo "$v is unset"; exit 1; fi
+done
+
+key=/server.key
+crt=/server.crt
+
+openssl req -newkey rsa:2048 -nodes -keyout $key -x509 -days 365 -out $crt -subj "/C=$CERT_COUNTRY/ST=$CERT_STATE/L=$CERT_CITY/O=$CERT_COMPANY"
+chown trafops:trafops $key $crt
+
+cat <<-EOF >/opt/traffic_ops/app/conf/cdn.conf
+{
+    "hypnotoad" : {
+        "listen" : [
+            "https://[::]:60443?cert=$crt&key=$key&verify=0x00&ciphers=AES128-GCM-SHA256:HIGH:!RC4:!MD5:!aNULL:!EDH:!ED"
+        ],
+        "user" : "trafops",
+        "group" : "trafops",
+        "heartbeat_timeout" : 20,
+        "pid_file" : "/var/run/traffic_ops.pid",
+        "workers" : 12
+    },
+    "traffic_ops_golang" : {
+        "port" : "443",
+        "proxy_timeout" : 60,
+        "proxy_keep_alive" : 60,
+        "proxy_tls_timeout" : 60,
+        "proxy_read_header_timeout" : 60,
+        "read_timeout" : 60,
+        "read_header_timeout" : 60,
+        "write_timeout" : 60,
+        "idle_timeout" : 60,
+        "log_location_error": "/var/log/traffic_ops/error.log",
+        "log_location_warning": "/var/log/traffic_ops/warning.log",
+        "log_location_info": "/var/log/traffic_ops/info.log",
+        "log_location_debug": "/var/log/traffic_ops/debug.log",
+        "log_location_event": "/var/log/traffic_ops/access.log",
+        "max_db_connections": 20,
+        "backend_max_connections": {
+            "mojolicious": 4
+        }
+    },
+    "cors" : {
+        "access_control_allow_origin" : "*"
+    },
+    "to" : {
+        "base_url" : "http://localhost:3000",
+        "email_from" : "no-reply@traffic-ops-domain.com",
+        "no_account_found_msg" : "A Traffic Ops user account is required for access. Please contact your Traffic Ops user administrator."
+    },
+    "portal" : {
+        "base_url" : "http://localhost:8080/!#/",
+        "email_from" : "no-reply@traffic-portal-domain.com",
+        "pass_reset_path" : "user",
+        "user_register_path" : "user"
+    },
+    "secrets" : [
+        "mONKEYDOmONKEYSEE."
+    ],
+    "geniso" : {
+        "iso_root_path" : "/opt/traffic_ops/app/public"
+    },
+    "inactivity_timeout" : 60
+}
+EOF
+
+cat <<-EOF >/opt/traffic_ops/app/conf/production/database.conf
+{
+        "description": "Local PostgreSQL database on port 5432",
+        "dbname": "$DB_NAME",
+        "hostname": "$DB_SERVER",
+        "user": "$DB_USER",
+        "password": "$DB_USER_PASS",
+        "port": "$DB_PORT",
+        "ssl": false,
+        "type": "Pg"
+}
+EOF
+
+cat /opt/traffic_ops/app/conf/cdn.conf
+cat /opt/traffic_ops/app/conf/production/database.conf
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/dbInit.sh b/infrastructure/cdn-in-a-box/traffic_ops/dbInit.sh
index f4392d4..2398f0c 100755
--- a/infrastructure/cdn-in-a-box/traffic_ops/dbInit.sh
+++ b/infrastructure/cdn-in-a-box/traffic_ops/dbInit.sh
@@ -26,5 +26,6 @@ while ! nc $DB_SERVER $DB_PORT </dev/null; do # &>/dev/null; do
         echo "waiting for $DB_SERVER:$DB_PORT"
         sleep 3
 done
+
 psql -h $DB_SERVER -U postgres -c "CREATE USER $DB_USER WITH ENCRYPTED PASSWORD '$DB_USER_PASS'"
 createdb $DB_NAME -h $DB_SERVER -U postgres --owner $DB_USER
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml b/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml
index 0001648..23f91ee 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml
+++ b/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml
@@ -33,7 +33,15 @@
 version: '2.1'
 
 networks:
-  cdnnet:
+  dbnet:
+    driver: bridge
+    enable_ipv6: true
+    ipam:
+      driver: default
+      config:
+        - subnet: 172.13.239.0/24
+        - subnet: "fc01:9400:1000:8::/64"
+  trafficopsnet:
     driver: bridge
     enable_ipv6: true
     ipam:
@@ -45,19 +53,19 @@ networks:
 services:
   db:
     image: postgres:9.6.6
+    networks:
+      - dbnet
+    env_file:
+      - variables.env
     # TODO: change to expose: "5432" to limit to containers
     ports: 
       - "5432:5432"
 
   dbinit:
-    environment:
-      POSTGRES_HOME: /usr/pgsql-9.6
-      PGPASSWORD: password
-      DB_NAME: traffic_ops
-      DB_PORT: 5432
-      DB_SERVER: db
-      DB_USER_PASS: password
-      DB_USER: traffic_ops
+    networks:
+      - dbnet
+    env_file:
+      - variables.env
     build:
       context: .
       dockerfile: Dockerfile-dbinit
@@ -66,21 +74,11 @@ services:
 
   trafficops-perl:
     image: trafficops-perl
-    environment:
-      DB_NAME: traffic_ops
-      DB_PORT: 5432
-      DB_ROOT_PASS: password
-      DB_SERVER: db
-      DB_USER_PASS: password
-      DB_USER: traffic_ops
-      ADMIN_USER: superroot
-      ADMIN_PASS: password
-      CERT_COUNTRY: US
-      CERT_STATE: Colorado
-      CERT_CITY: Denver
-      CERT_COMPANY: NotComcast
-      TRAFFIC_VAULT_PASS: password
-      DOMAIN: trafficops_default
+    networks:
+      - dbnet
+      - trafficopsnet
+    env_file:
+      - variables.env
     expose: 
       - "60443"
     build:
@@ -92,21 +90,11 @@ services:
 
   trafficops:
     image: trafficops-go
-    environment:
-      DB_NAME: traffic_ops
-      DB_PORT: 5432
-      DB_ROOT_PASS: password
-      DB_SERVER: db
-      DB_USER_PASS: password
-      DB_USER: traffic_ops
-      ADMIN_USER: superroot
-      ADMIN_PASS: password
-      CERT_COUNTRY: US
-      CERT_STATE: Colorado
-      CERT_CITY: Denver
-      CERT_COMPANY: NotComcast
-      TRAFFIC_VAULT_PASS: password
-      DOMAIN: trafficops_default
+    networks:
+      - dbnet
+      - trafficopsnet
+    env_file:
+      - variables.env
     ports: 
       - "443:443"
     build:
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/run-go.sh b/infrastructure/cdn-in-a-box/traffic_ops/run-go.sh
new file mode 100755
index 0000000..284ba60
--- /dev/null
+++ b/infrastructure/cdn-in-a-box/traffic_ops/run-go.sh
@@ -0,0 +1,64 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Script for running the Dockerfile for Traffic Ops.
+# The Dockerfile sets up a Docker image which can be used for any new Traffic Ops container;
+# This script, which should be run when the container is run (it's the ENTRYPOINT), will configure the container.
+#
+# The following environment variables must be set, ordinarily by `docker run -e` arguments:
+# DB_SERVER
+# DB_PORT
+# DB_ROOT_PASS
+# DB_USER
+# DB_USER_PASS
+# DB_NAME
+# ADMIN_USER
+# ADMIN_PASS
+# CERT_COUNTRY
+# CERT_STATE
+# CERT_CITY
+# CERT_COMPANY
+# DOMAIN
+
+# TODO:  Unused -- should be removed?  TRAFFIC_VAULT_PASS
+
+# Check that env vars are set
+
+set -x
+envvars=( DB_SERVER DB_PORT DB_ROOT_PASS DB_USER DB_USER_PASS ADMIN_USER ADMIN_PASS CERT_COUNTRY CERT_STATE CERT_CITY CERT_COMPANY DOMAIN)
+for v in $envvars
+do
+	if [[ -z $$v ]]; then echo "$v is unset"; exit 1; fi
+done
+
+# Write config files
+if [[ -x /config.sh ]]; then
+	/config.sh
+fi
+
+while ! nc trafficops-perl 60443 </dev/null; do # &>/dev/null; do
+        echo "waiting for trafficops-perl:60443"
+        sleep 3
+done
+
+cd /opt/traffic_ops/app
+ls -l bin
+CDNCONF=/opt/traffic_ops/app/conf/cdn.conf
+DBCONF=/opt/traffic_ops/app/conf/production/database.conf
+mkdir -p /var/log/traffic_ops
+./bin/traffic_ops_golang -cfg $CDNCONF -dbcfg $DBCONF
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/run.sh b/infrastructure/cdn-in-a-box/traffic_ops/run.sh
index 48efc54..14cc836 100755
--- a/infrastructure/cdn-in-a-box/traffic_ops/run.sh
+++ b/infrastructure/cdn-in-a-box/traffic_ops/run.sh
@@ -44,250 +44,64 @@ do
 	if [[ -z $$v ]]; then echo "$v is unset"; exit 1; fi
 done
 
+# Write config files
+if [[ -x /config.sh ]]; then
+	/config.sh
+fi
+
+while true; do
+	echo "Checking for existence of role $DB_USER"
+	psql -U postgres -h $DB_SERVER -p $DB_PORT postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='$DB_USER'" | grep -q 1 && break
+	sleep 3
+done
+
 start() {
 	TO_DIR=/opt/traffic_ops/app
+	export PERL5LIB=$TO_DIR/lib:$TO_DIR/local/lib/perl5
 	cd $TO_DIR && $TO_DIR/local/bin/hypnotoad script/cdn
 	exec tail -f /var/log/traffic_ops/traffic_ops.log
 }
 
 init() {
-	local postinstall_input_file="postinstall-input.json"
-	cat > "$postinstall_input_file" <<- ENDOFMESSAGE
-{
-  "/opt/traffic_ops/app/conf/production/database.conf":[
-    {
-      "Database type":"Pg",
-      "config_var":"type"
-    },
-    {
-      "Database name":"$DB_NAME",
-      "config_var":"dbname"
-    },
-    {
-      "Database server hostname IP or FQDN":"$DB_SERVER",
-      "config_var":"hostname"
-    },
-    {
-      "Database port number":"$DB_PORT",
-      "config_var":"port"
-    },
-    {
-      "Traffic Ops database user":"$DB_USER",
-      "config_var":"user"
-    },
-    {
-      "Traffic Ops database password":"$DB_USER_PASS",
-      "config_var":"password",
-      "hidden":"1"
-    }
-  ],
-  "/opt/traffic_ops/app/db/dbconf.yml":[
-    {
-      "Database server root (admin) user":"postgres",
-      "config_var":"pgUser"
-    },
-    {
-      "Database server admin password":"$DB_ROOT_PASS",
-      "config_var":"pgPassword",
-      "hidden":"1"
-    },
-    {
-      "Download Maxmind Database?":"yes",
-      "config_var":"maxmind"
-    }
-  ],
-  "/opt/traffic_ops/app/conf/cdn.conf":[
-    {
-      "Generate a new secret?":"yes",
-      "config_var":"genSecret"
-    },
-    {
-      "Port to serve on?": "443",
-      "config_var": "port"
-    },
-    {
-      "Number of workers?": "12",
-      "config_var":"workers"
-    },
-    {
-      "Traffic Ops url?": "https://$HOSTNAME",
-      "config_var": "base_url"
-    },
-    {
-      "Number of secrets to keep?":"1",
-      "config_var":"keepSecrets"
-    }
-  ],
-  "/opt/traffic_ops/app/conf/ldap.conf":[
-    {
-      "Do you want to set up LDAP?":"no",
-      "config_var":"setupLdap"
-    },
-    {
-      "LDAP server hostname":"",
-      "config_var":"host"
-    },
-    {
-      "LDAP Admin DN":"",
-      "config_var":"admin_dn"
-    },
-    {
-      "LDAP Admin Password":"",
-      "config_var":"admin_pass",
-      "hidden":"1"
-    },
-    {
-      "LDAP Search Base":"",
-      "config_var":"search_base"
-    }
-  ],
-  "/opt/traffic_ops/install/data/json/users.json":[
-    {
-      "Administration username for Traffic Ops":"$ADMIN_USER",
-      "config_var":"tmAdminUser"
-    },
-    {
-      "Password for the admin user":"$ADMIN_PASS",
-      "config_var":"tmAdminPw",
-      "hidden":"1"
-    }
-  ],
-  "/opt/traffic_ops/install/data/profiles/":[
-    {
-      "Add custom profiles?":"no",
-      "config_var":"custom_profiles"
-    }
-  ],
-  "/opt/traffic_ops/install/data/json/openssl_configuration.json":[
-    {
-      "Do you want to generate a certificate?":"yes",
-      "config_var":"genCert"
-    },
-    {
-      "Country Name (2 letter code)":"$CERT_COUNTRY",
-      "config_var":"country"
-    },
-    {
-      "State or Province Name (full name)":"$CERT_STATE",
-      "config_var":"state"
-    },
-    {
-      "Locality Name (eg, city)":"$CERT_CITY",
-      "config_var":"locality"
-    },
-    {
-      "Organization Name (eg, company)":"$CERT_COMPANY",
-      "config_var":"company"
-    },
-    {
-      "Organizational Unit Name (eg, section)":"",
-      "config_var":"org_unit"
-    },
-    {
-      "Common Name (eg, your name or your server's hostname)":"$HOSTNAME",
-      "config_var":"common_name"
-    },
-    {
-      "RSA Passphrase":"passphrase",
-      "config_var":"rsaPassword",
-      "hidden":"1"
-    }
-  ],
-  "/opt/traffic_ops/install/data/json/profiles.json":[
-    {
-      "Traffic Ops url":"https://$HOSTNAME",
-      "config_var":"tm.url"
-    },
-    {
-      "Human-readable CDN Name.  (No whitespace, please)":"cdn",
-      "config_var":"cdn_name"
-    },
-    {
-      "Health Polling Interval (milliseconds)":"8000",
-      "config_var":"health_polling_int"
-    },
-    {
-      "DNS sub-domain for which your CDN is authoritative":"$HOSTNAME.$DOMAIN",
-      "config_var":"dns_subdomain"
-    },
-    {
-      "TLD SOA admin":"traffic_ops",
-      "config_var":"soa_admin"
-    },
-    {
-      "TrafficServer Drive Prefix":"/dev/ram",
-      "config_var":"driver_prefix"
-    },
-    {
-      "TrafficServer RAM Drive Prefix":"/dev/ram",
-      "config_var":"ram_drive_prefix"
-    },
-    {
-      "TrafficServer RAM Drive Letters (comma separated)":"1",
-      "config_var":"ram_drive_letters"
-    },
-    {
-      "Health Threshold Load Average":"25",
-      "config_var":"health_thresh_load_avg"
-    },
-    {
-      "Health Threshold Available Bandwidth in Kbps":"1750000",
-      "config_var":"health_thresh_kbps"
-    },
-    {
-      "Traffic Server Health Connection Timeout (milliseconds)":"2000",
-      "config_var":"health_connect_timeout"
-    }
-  ]
-}
-	ENDOFMESSAGE
-
-	# TODO determine if term, user are necessary
-	export TERM=xterm && export USER=root && /opt/traffic_ops/install/bin/postinstall -cfile "$postinstall_input_file"
-
-	# Only listen on IPv4, not IPv6, because Docker doesn't provide a v6 interface by default. See http://mojolicious.org/perldoc/Mojo/Server/Daemon#listen
-	sed -i -e 's#https://\[::\]#https://127\.0\.0\.1#' /opt/traffic_ops/app/conf/cdn.conf
-	service traffic_ops restart
-
 	TRAFFIC_OPS_URI="https://localhost"
 
-	TMP_TO_COOKIE="$(curl -v -s -k -X POST --data '{ "u":"'"$ADMIN_USER"'", "p":"'"$ADMIN_PASS"'" }' $TRAFFIC_OPS_URI/api/1.2/user/login 2>&1 | grep 'Set-Cookie' | sed -e 's/.*mojolicious=\(.*\); expires.*/\1/')"
-	echo "Got cookie: $TMP_TO_COOKIE"
+	COOKIE="$(curl -v -s -k -X POST --data '{ "u":"'"$ADMIN_USER"'", "p":"'"$ADMIN_PASS"'" }' $TRAFFIC_OPS_URI/api/1.2/user/login 2>&1 | grep 'Set-Cookie' | sed -e 's/.*mojolicious=\(.*\); expires.*/\1/')"
+	echo "Got cookie: $COOKIE"
 
 	TMP_DOMAIN=$DOMAIN
 	sed -i -- "s/{{.Domain}}/$TMP_DOMAIN/g" /profile.origin.traffic_ops
 	echo "Got domain: $TMP_DOMAIN"
 
 	echo "Importing origin"
-	curl -v -k -X POST -H "Cookie: mojolicious=$TMP_TO_COOKIE" -F "filename=profile.origin.traffic_ops" -F "profile_to_import=@/profile.origin.traffic_ops" $TRAFFIC_OPS_URI/profile/doImport
+	curl -v -k -X POST -H "Cookie: mojolicious=$COOKIE" -F "filename=profile.origin.traffic_ops" -F "profile_to_import=@/profile.origin.traffic_ops" $TRAFFIC_OPS_URI/profile/doImport
 
-	curl -v -k -X POST -H "Cookie: mojolicious=$TMP_TO_COOKIE" --data-urlencode "division.name=East" $TRAFFIC_OPS_URI/division/create
-	TMP_DIVISION_ID="$(curl -s -k -X GET -H "Cookie: mojolicious=$TMP_TO_COOKIE" $TRAFFIC_OPS_URI/region/add | grep --color=never -oE "<option value=\"[0-9]+\">East</option>" | grep --color=never -oE "[0-9]+")"
+	curl -v -k -X POST -H "Cookie: mojolicious=$COOKIE" --data-urlencode "division.name=East" $TRAFFIC_OPS_URI/division/create
+	TMP_DIVISION_ID="$(curl -s -k -X GET -H "Cookie: mojolicious=$COOKIE" $TRAFFIC_OPS_URI/region/add | grep --color=never -oE "<option value=\"[0-9]+\">East</option>" | grep --color=never -oE "[0-9]+")"
 	echo "Got division ID: $TMP_DIVISION_ID"
 
-	curl -v -k -X POST -H "Cookie: mojolicious=$TMP_TO_COOKIE" --data-urlencode "region.name=Eastish" --data-urlencode "region.division_id=$TMP_DIVISION_ID" $TRAFFIC_OPS_URI/region/create
-	TMP_REGION_ID="$(curl -s -k -X GET -H "Cookie: mojolicious=$TMP_TO_COOKIE" $TRAFFIC_OPS_URI/api/1.2/regions.json | python -c 'import json,sys;obj=json.load(sys.stdin);match=[x["id"] for x in obj["response"] if x["name"]=="Eastish"]; print match[0]')"
+	curl -v -k -X POST -H "Cookie: mojolicious=$COOKIE" --data-urlencode "region.name=Eastish" --data-urlencode "region.division_id=$TMP_DIVISION_ID" $TRAFFIC_OPS_URI/region/create
+	TMP_REGION_ID="$(curl -s -k -X GET -H "Cookie: mojolicious=$COOKIE" $TRAFFIC_OPS_URI/api/1.2/regions.json | python -c 'import json,sys;obj=json.load(sys.stdin);match=[x["id"] for x in obj["response"] if x["name"]=="Eastish"]; print match[0]')"
 	echo "Got region ID: $TMP_REGION_ID"
 
-	TMP_CACHEGROUP_TYPE="$(curl -s -k -X GET -H "Cookie: mojolicious=$TMP_TO_COOKIE" $TRAFFIC_OPS_URI/api/1.2/types.json | python -c 'import json,sys;obj=json.load(sys.stdin);match=[x["id"] for x in obj["response"] if x["name"]=="MID_LOC"]; print match[0]')"
+	TMP_CACHEGROUP_TYPE="$(curl -s -k -X GET -H "Cookie: mojolicious=$COOKIE" $TRAFFIC_OPS_URI/api/1.2/types.json | python -c 'import json,sys;obj=json.load(sys.stdin);match=[x["id"] for x in obj["response"] if x["name"]=="MID_LOC"]; print match[0]')"
 	echo "Got cachegroup type ID: $TMP_CACHEGROUP_TYPE"
 
-	curl -v -k -X POST -H "Cookie: mojolicious=$TMP_TO_COOKIE" --data-urlencode "cg_data.name=mid-east" --data-urlencode "cg_data.short_name=east" --data-urlencode "cg_data.latitude=0" --data-urlencode "cg_data.longitude=0" --data-urlencode "cg_data.parent_cachegroup_id=-1" --data-urlencode "cg_data.type=$TMP_CACHEGROUP_TYPE" $TRAFFIC_OPS_URI/cachegroup/create
-	TMP_CACHEGROUP_ID="$(curl -s -k -X GET -H "Cookie: mojolicious=$TMP_TO_COOKIE" $TRAFFIC_OPS_URI/api/1.2/cachegroups.json | python -c 'import json,sys;obj=json.load(sys.stdin);match=[x["id"] for x in obj["response"] if x["name"]=="mid-east"]; print match[0]')"
+	curl -v -k -X POST -H "Cookie: mojolicious=$COOKIE" --data-urlencode "cg_data.name=mid-east" --data-urlencode "cg_data.short_name=east" --data-urlencode "cg_data.latitude=0" --data-urlencode "cg_data.longitude=0" --data-urlencode "cg_data.parent_cachegroup_id=-1" --data-urlencode "cg_data.type=$TMP_CACHEGROUP_TYPE" $TRAFFIC_OPS_URI/cachegroup/create
+	TMP_CACHEGROUP_ID="$(curl -s -k -X GET -H "Cookie: mojolicious=$COOKIE" $TRAFFIC_OPS_URI/api/1.2/cachegroups.json | python -c 'import json,sys;obj=json.load(sys.stdin);match=[x["id"] for x in obj["response"] if x["name"]=="mid-east"]; print match[0]')"
 	echo "Got cachegroup ID: $TMP_CACHEGROUP_ID"
 
-	TMP_CACHEGROUP_EDGE_TYPE="$(curl -s -k -X GET -H "Cookie: mojolicious=$TMP_TO_COOKIE" $TRAFFIC_OPS_URI/api/1.2/types.json | python -c 'import json,sys;obj=json.load(sys.stdin);match=[x["id"] for x in obj["response"] if x["name"]=="EDGE_LOC"]; print match[0]')"
+	TMP_CACHEGROUP_EDGE_TYPE="$(curl -s -k -X GET -H "Cookie: mojolicious=$COOKIE" $TRAFFIC_OPS_URI/api/1.2/types.json | python -c 'import json,sys;obj=json.load(sys.stdin);match=[x["id"] for x in obj["response"] if x["name"]=="EDGE_LOC"]; print match[0]')"
 	echo "Got cachegroup type ID: $TMP_CACHEGROUP_EDGE_TYPE"
 
-	curl -v -k -X POST -H "Cookie: mojolicious=$TMP_TO_COOKIE" --data-urlencode "cg_data.name=edge-east" --data-urlencode "cg_data.short_name=eeast" --data-urlencode "cg_data.latitude=0" --data-urlencode "cg_data.longitude=0" --data-urlencode "cg_data.parent_cachegroup_id=$TMP_CACHEGROUP_ID" --data-urlencode "cg_data.type=$TMP_CACHEGROUP_EDGE_TYPE" $TRAFFIC_OPS_URI/cachegroup/create
-	TMP_CACHEGROUP_EDGE_ID="$(curl -s -k -X GET -H "Cookie: mojolicious=$TMP_TO_COOKIE" $TRAFFIC_OPS_URI/api/1.2/cachegroups.json | python -c 'import json,sys;obj=json.load(sys.stdin);match=[x["id"] for x in obj["response"] if x["name"]=="edge-east"]; print match[0]')"
+	curl -v -k -X POST -H "Cookie: mojolicious=$COOKIE" --data-urlencode "cg_data.name=edge-east" --data-urlencode "cg_data.short_name=eeast" --data-urlencode "cg_data.latitude=0" --data-urlencode "cg_data.longitude=0" --data-urlencode "cg_data.parent_cachegroup_id=$TMP_CACHEGROUP_ID" --data-urlencode "cg_data.type=$TMP_CACHEGROUP_EDGE_TYPE" $TRAFFIC_OPS_URI/cachegroup/create
+	TMP_CACHEGROUP_EDGE_ID="$(curl -s -k -X GET -H "Cookie: mojolicious=$COOKIE" $TRAFFIC_OPS_URI/api/1.2/cachegroups.json | python -c 'import json,sys;obj=json.load(sys.stdin);match=[x["id"] for x in obj["response"] if x["name"]=="edge-east"]; print match[0]')"
 	echo "Got cachegroup edge ID: $TMP_CACHEGROUP_EDGE_ID"
 
-	curl -v -k -X POST -H "Cookie: mojolicious=$TMP_TO_COOKIE" --data-urlencode "location.name=plocation-nyc-1" --data-urlencode "location.short_name=nyc" --data-urlencode "location.address=1 Main Street" --data-urlencode "location.city=nyc" --data-urlencode "location.state=NY" --data-urlencode "location.zip=12345" --data-urlencode "location.poc=" --data-urlencode "location.phone=" --data-urlencode "location.email=no@no.no" --data-urlencode "location.comments=" --data-urlencode "location.re [...]
+	curl -v -k -X POST -H "Cookie: mojolicious=$COOKIE" --data-urlencode "location.name=plocation-nyc-1" --data-urlencode "location.short_name=nyc" --data-urlencode "location.address=1 Main Street" --data-urlencode "location.city=nyc" --data-urlencode "location.state=NY" --data-urlencode "location.zip=12345" --data-urlencode "location.poc=" --data-urlencode "location.phone=" --data-urlencode "location.email=no@no.no" --data-urlencode "location.comments=" --data-urlencode "location.region=$T [...]
 
 	echo "INITIALIZED=1" >> /etc/environment
 }
 
 source /etc/environment
-if [ -z "$INITIALIZED" ]; then init; fi
+#if [ -z "$INITIALIZED" ]; then init; fi
 start
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/variables.env b/infrastructure/cdn-in-a-box/traffic_ops/variables.env
new file mode 100644
index 0000000..1ca486b
--- /dev/null
+++ b/infrastructure/cdn-in-a-box/traffic_ops/variables.env
@@ -0,0 +1,20 @@
+DOMAIN=domain
+CERT_CITY=Denver
+CERT_COMPANY=NotComcast
+CERT_COUNTRY=US
+CERT_STATE=CO
+DB_NAME=traffic_ops
+DB_USER_PASS=twelve
+DB_PORT=5432
+DB_SERVER=db
+DB_USER=traffic_ops
+POSTGRES_PASSWORD=twelve
+PGPASSWORD=twelve
+TO_ADMIN_PASSWORD=twelve
+TO_ADMIN_USER=admin
+TO_EMAIL=cdnadmin@example.com
+TO_HOST=trafficops
+TO_PORT=443
+TO_SECRET=blahblah
+TP_EMAIL=none
+TP_HOST=none

-- 
To stop receiving notification emails like this one, please contact
dewrich@apache.org.

[trafficcontrol] 07/20: add rpm to .gitignore

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit b9f8784cee08dc786b3c62c2613b40bb5e0a95d6
Author: Dan Kirkwood <da...@gmail.com>
AuthorDate: Fri Jun 1 22:13:54 2018 +0000

    add rpm to .gitignore
---
 infrastructure/cdn-in-a-box/traffic_ops/.gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/infrastructure/cdn-in-a-box/traffic_ops/.gitignore b/infrastructure/cdn-in-a-box/traffic_ops/.gitignore
new file mode 100644
index 0000000..aa26976
--- /dev/null
+++ b/infrastructure/cdn-in-a-box/traffic_ops/.gitignore
@@ -0,0 +1 @@
+traffic_ops.rpm

-- 
To stop receiving notification emails like this one, please contact
dewrich@apache.org.

[trafficcontrol] 17/20: add missing license text

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit d5992b25ed68bbcdcc3d29a38a0c3b33d218cbb3
Author: Dan Kirkwood <da...@apache.org>
AuthorDate: Thu Jun 14 10:42:18 2018 -0600

    add missing license text
---
 infrastructure/cdn-in-a-box/traffic_ops/adduser.pl | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/infrastructure/cdn-in-a-box/traffic_ops/adduser.pl b/infrastructure/cdn-in-a-box/traffic_ops/adduser.pl
index eacf6ae..57e1722 100755
--- a/infrastructure/cdn-in-a-box/traffic_ops/adduser.pl
+++ b/infrastructure/cdn-in-a-box/traffic_ops/adduser.pl
@@ -1,4 +1,20 @@
 #!/usr/bin/env perl
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
 
 use strict;
 use Crypt::ScryptKDF qw{ scrypt_hash };

-- 
To stop receiving notification emails like this one, please contact
dewrich@apache.org.

[trafficcontrol] 09/20: config fixes

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit a14fef8a24978cf061db5f00013b0c5ed2efb7b0
Author: Dan Kirkwood <da...@gmail.com>
AuthorDate: Tue Jun 5 20:01:43 2018 +0000

    config fixes
---
 infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-go | 1 +
 infrastructure/cdn-in-a-box/traffic_ops/config.sh     | 9 +++++----
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-go b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-go
index b270863..b8a1fac 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-go
+++ b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-go
@@ -26,6 +26,7 @@ RUN yum -y install nmap-ncat openssl
 
 RUN mkdir -p /opt/traffic_ops/app/bin /opt/traffic_ops/app/conf/production
 COPY --from=trafficops-perl /opt/traffic_ops/app/bin/traffic_ops_golang /opt/traffic_ops/app/bin/traffic_ops_golang 
+COPY --from=trafficops-perl /usr/local/go /usr/local/go
 
 EXPOSE 443
 WORKDIR /opt/traffic_ops/app
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/config.sh b/infrastructure/cdn-in-a-box/traffic_ops/config.sh
index 3c2efe0..6e92c82 100755
--- a/infrastructure/cdn-in-a-box/traffic_ops/config.sh
+++ b/infrastructure/cdn-in-a-box/traffic_ops/config.sh
@@ -42,11 +42,14 @@ do
 	if [[ -z $$v ]]; then echo "$v is unset"; exit 1; fi
 done
 
+key=/server.key
+crt=/server.crt
+
 cat <<-EOF >/opt/traffic_ops/app/conf/cdn.conf
 {
     "hypnotoad" : {
         "listen" : [
-            "https://[::]:60443?cert=$crt&key=$key&verify=0x00&ciphers=AES128-GCM-SHA256:HIGH:!RC4:!MD5:!aNULL:!EDH:!ED"
+            "https://trafficops-perl:60443?cert=$crt&key=$key&verify=0x00&ciphers=AES128-GCM-SHA256:HIGH:!RC4:!MD5:!aNULL:!EDH:!ED"
         ],
         "user" : "trafops",
         "group" : "trafops",
@@ -55,6 +58,7 @@ cat <<-EOF >/opt/traffic_ops/app/conf/cdn.conf
         "workers" : 12
     },
     "traffic_ops_golang" : {
+	"insecure": true,
         "port" : "443",
         "proxy_timeout" : 60,
         "proxy_keep_alive" : 60,
@@ -120,8 +124,5 @@ production:
   open: host=$DB_SERVER port=$DB_PORT user=$DB_USER password=$DB_USER_PASS dbname=$DB_NAME sslmode=disable
 EOF
 
-key=/server.key
-crt=/server.crt
-
 openssl req -newkey rsa:2048 -nodes -keyout $key -x509 -days 365 -out $crt -subj "/C=$CERT_COUNTRY/ST=$CERT_STATE/L=$CERT_CITY/O=$CERT_COMPANY"
 chown trafops:trafops $key $crt

-- 
To stop receiving notification emails like this one, please contact
dewrich@apache.org.

[trafficcontrol] 10/20: perl script to create sql for new user with encrypted password.

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit 36d86a9feeb918e113d19f00fd09d916db227dc9
Author: Dan Kirkwood <da...@gmail.com>
AuthorDate: Thu Apr 19 20:23:44 2018 +0000

    perl script to create sql for new user with encrypted password.
---
 infrastructure/cdn-in-a-box/traffic_ops/run.sh |  1 +
 traffic_ops/app/db/adduser.pl                  | 28 ++++++++++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/infrastructure/cdn-in-a-box/traffic_ops/run.sh b/infrastructure/cdn-in-a-box/traffic_ops/run.sh
index 46821c5..be60d71 100755
--- a/infrastructure/cdn-in-a-box/traffic_ops/run.sh
+++ b/infrastructure/cdn-in-a-box/traffic_ops/run.sh
@@ -63,6 +63,7 @@ export PATH=/usr/local/go/bin:/opt/traffic_ops/go/bin:$PATH
 export GOPATH=/opt/traffic_ops/go
 
 cd $TO_DIR && ./db/admin.pl --env=production reset || echo "DB reset failed!"
+./db/adduser.pl $TO_ADMIN_USER $TO_ADMIN_PASSWORD | psql -U$DB_USER -h$DB_SERVER $DB_NAME || echo "adding traffic_ops admin user failed!"
 
 cd $TO_DIR && $TO_DIR/local/bin/hypnotoad script/cdn
 exec tail -f /var/log/traffic_ops/traffic_ops.log
diff --git a/traffic_ops/app/db/adduser.pl b/traffic_ops/app/db/adduser.pl
new file mode 100755
index 0000000..eacf6ae
--- /dev/null
+++ b/traffic_ops/app/db/adduser.pl
@@ -0,0 +1,28 @@
+#!/usr/bin/env perl
+
+use strict;
+use Crypt::ScryptKDF qw{ scrypt_hash };
+
+if ($#ARGV < 2) {
+    die "Usage: $ARGV[0] <username> <password> <role>\n";
+}
+
+my $username = shift // 'admin';
+my $password = shift or die "Password is required\n";
+my $role = shift // 'admin';
+
+# Skip the insert if the admin 'username' is already there.
+my $hashed_passwd = hash_pass( $password );
+print <<"ADMIN";
+insert into tm_user (username, role, local_passwd, confirm_local_passwd)
+    values  ('$username',
+            (select id from role where name = '$role'),
+            '$hashed_passwd',
+            '$hashed_passwd' )
+    ON CONFLICT (username) DO NOTHING;
+ADMIN
+
+sub hash_pass {
+    my $pass = shift;
+    return scrypt_hash($pass, \64, 16384, 8, 1, 64);
+}

-- 
To stop receiving notification emails like this one, please contact
dewrich@apache.org.

[trafficcontrol] 01/20: start with docker

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit a95758d66c4d2f63c20f94be3b3c431fe961a85e
Author: Dan Kirkwood <da...@gmail.com>
AuthorDate: Tue May 29 23:15:41 2018 +0000

    start with docker
---
 infrastructure/cdn-in-a-box/traffic_ops/Dockerfile |  78 ++++++
 .../cdn-in-a-box/traffic_ops/Dockerfile_psql       |  42 +++
 infrastructure/cdn-in-a-box/traffic_ops/dbInit.sh  |  30 +++
 .../cdn-in-a-box/traffic_ops/docker-compose.yml    |  86 ++++++
 .../traffic_ops/profile.origin.traffic_ops         |  18 ++
 infrastructure/cdn-in-a-box/traffic_ops/run.sh     | 292 +++++++++++++++++++++
 6 files changed, 546 insertions(+)

diff --git a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
new file mode 100644
index 0000000..9c94e24
--- /dev/null
+++ b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
@@ -0,0 +1,78 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+############################################################
+# Dockerfile to build Traffic Ops container images
+# Based on CentOS 7.2
+############################################################
+
+# Example Build and Run:
+# docker network create cdnet
+# docker build --rm --tag traffic_ops:1.7.0 --build-arg=RPM=http://traffic-control-cdn.net/downloads/1.7.0/RELEASE-1.7.0/traffic_ops-1.7.0-3908.5b77f60f.x86_64.rpm traffic_ops
+#
+# docker run --name my-traffic-ops-mysql --hostname my-traffic-ops-mysql --net cdnet --env MYSQL_ROOT_PASSWORD=secretrootpass --detach mysql:5.5
+#
+# docker run --name my-traffic-ops --hostname my-traffic-ops --net cdnet --publish 443:443 --env MYSQL_IP=my-traffic-ops-mysql --env MYSQL_PORT=3306 --env MYSQL_ROOT_PASS=secretrootpass --env MYSQL_TRAFFIC_OPS_PASS=supersecretpassword --env ADMIN_USER=superroot --env ADMIN_PASS=supersecreterpassward --env CERT_COUNTRY=US --env CERT_STATE=Colorado --env CERT_CITY=Denver --env CERT_COMPANY=NotComcast --env TRAFFIC_VAULT_PASS=marginallylesssecret --env DOMAIN=cdnet --detach traffic_ops:1.5.1
+
+FROM centos/systemd
+MAINTAINER Dan Kirkwood
+
+RUN yum install -y https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-redhat96-9.6-3.noarch.rpm
+RUN yum install -y initscripts # needed for service command
+RUN yum install -y epel-release # needed for perl-Crypt-ScryptKDF
+RUN yum install -y perl-Crypt-ScryptKDF
+RUN yum install -y perl cpanminus perl-Test-CPAN-Meta
+RUN cpanm Carton
+RUN yum install -y perl-DBIx-Connector
+
+# Override RPM arg to use a different one using --build-arg RPM=...  Can be local file or http://...
+ARG RPM=traffic_ops.rpm
+ADD $RPM /
+RUN yum install -y /$(basename $RPM)
+
+# once installed, remove rpm to lower image size
+RUN rm /$(basename $RPM)
+
+RUN POSTGRES_HOME=/usr/pgsql-9.6 cd /opt/traffic_ops/app && carton
+
+RUN /opt/traffic_ops/install/bin/install_go.sh
+RUN /opt/traffic_ops/install/bin/install_goose.sh
+
+# RUN export PERL5LIB=/opt/traffic_ops/app/local/lib/perl5/:/opt/traffic_ops/install/lib/ \
+# 	&& export TERM=xterm \
+# 	&& export USER=root \
+# 	&& yes | /opt/traffic_ops/install/bin/build_trafficops_perl_library -i
+
+RUN export PERL5LIB=/opt/traffic_ops/app/local/lib/perl5/:/opt/traffic_ops/install/lib/ \
+	&& export TERM=xterm \
+	&& export USER=root \
+	&& /opt/traffic_ops/install/bin/download_web_deps -i
+
+# \todo add Drive Letters to postinstall input
+# RUN sed -i -- 's/"value": "b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y"/"value": "0"/g' /opt/traffic_ops/install/data/profiles/profile.trafficserver_edge.traffic_ops
+# RUN sed -i -- 's/"value": "b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y"/"value": "0"/g' /opt/traffic_ops/install/data/profiles/profile.trafficserver_mid.traffic_ops
+
+RUN echo "{\"user\": \"riakuser\",\"password\": \"$TRAFFIC_VAULT_PASS\"}" > /opt/traffic_ops/app/conf/production/riak.conf
+
+RUN cp /opt/traffic_ops/app/bin/traffic_ops_golang{,.new} && mv /opt/traffic_ops/app/bin/traffic_ops_golang{.new,} # fixes an 'Invalid Argument' bug; TODO diagnose, fix, & remove
+
+EXPOSE 443
+WORKDIR /opt/traffic_ops/app
+ENV MOJO_MODE production
+ADD profile.origin.traffic_ops /
+ADD run.sh /
+CMD /run.sh
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile_psql b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile_psql
new file mode 100644
index 0000000..9704aaa
--- /dev/null
+++ b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile_psql
@@ -0,0 +1,42 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+############################################################
+# Dockerfile to initialized Traffic Ops Database container 
+# Based on CentOS 7.2
+############################################################
+
+FROM centos/systemd
+
+RUN yum install -y https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-redhat96-9.6-3.noarch.rpm
+
+RUN yum -y install \
+  postgresql96 \
+  nmap-ncat \
+  cpanminus && \
+  yum clean all
+
+ENV POSTGRES_HOME $POSTGRES_HOME
+ENV PGPASSWORD $PGPASSWORD 
+ENV DB_USERNAME $DB_USERNAME
+ENV DB_NAME $DB_NAME
+ENV DB_USER_PASS $DB_USER_PASS 
+ENV DB_SERVER $DB_SERVER
+ENV DB_PORT $DB_PORT
+
+ADD dbInit.sh /
+CMD /dbInit.sh
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/dbInit.sh b/infrastructure/cdn-in-a-box/traffic_ops/dbInit.sh
new file mode 100755
index 0000000..80156f5
--- /dev/null
+++ b/infrastructure/cdn-in-a-box/traffic_ops/dbInit.sh
@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+############################################################
+# Script for creating the database user account for traffic
+# ops. 
+# Used while the Docker Image is initializing itself
+############################################################
+
+while ! nc $DB_SERVER $DB_PORT </dev/null; do # &>/dev/null; do
+        echo "waiting for $DB_SERVER:$DB_PORT"
+        sleep 3
+done
+psql -h $DB_SERVER -U postgres -c "CREATE USER $DB_USERNAME WITH ENCRYPTED PASSWORD '$DB_USER_PASS'"
+createdb $DB_NAME -h $DB_SERVER -U postgres --owner $DB_USERNAME
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml b/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml
new file mode 100644
index 0000000..8451aae
--- /dev/null
+++ b/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml
@@ -0,0 +1,86 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# To use this compose you should first build Traffic Ops and then copy the RPM to :
+#
+# incubator-trafficcontrol/infrastructure/docker/traffic_ops/traffic_ops.rpm
+#
+# You should then just be able to go to the directory incubator-trafficcontrol/infrastructure/docker/traffic_ops/
+# and type 'docker-compose up -d'
+#
+# You should then be able to go to https://localhost and test Traffic Ops or the go api.
+# if you make code changes to the Go proxy then you just need to rebuild it and then
+# restart Traffic Ops:
+#
+# bash -c "clear && docker exec trafficops_to_server_1 /bin/bash /etc/init.d/traffic_ops /bin/bash /etc/init.d/traffic_ops start; sleep 5"
+#
+
+---
+version: '2'
+
+volumes:
+  incubator-trafficcontrol:
+  traffic_ops:
+  conf:
+
+services:
+  db:
+    image: postgres:9.6.6
+    ports: 
+      - "5432:5432"
+
+  db_init:
+    environment:
+      POSTGRES_HOME: /usr/pgsql-9.6
+      PGPASSWORD: secretrootpass
+      DB_USERNAME: traffic_ops
+      DB_NAME: traffic_ops
+      DB_USER_PASS: twelve
+      DB_SERVER: db
+      DB_PORT: 5432
+    build:
+      context: .
+      dockerfile: Dockerfile_psql
+    depends_on: 
+      - db
+
+  to_server:
+    environment:
+      DB_SERVER: db
+      DB_PORT: 5432
+      DB_NAME: traffic_ops
+      DB_ROOT_PASS: null
+      DB_USER_PASS: twelve
+      DB_USER: traffic_ops
+      ADMIN_USER: superroot
+      ADMIN_PASS: passward
+      CERT_COUNTRY: US
+      CERT_STATE: Colorado
+      CERT_CITY: Denver
+      CERT_COMPANY: NotComcast
+      TRAFFIC_VAULT_PASS: tvsecret
+      DOMAIN: trafficops_default
+    ports: 
+      - "443:443"
+    build:
+      context: .
+      args:
+        RPM: traffic_ops.rpm 
+    volumes:
+      - ../../../traffic_ops/traffic_ops_golang/traffic_ops_golang:/opt/traffic_ops/app/bin/traffic_ops_golang
+    depends_on:
+      - db_init
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/profile.origin.traffic_ops b/infrastructure/cdn-in-a-box/traffic_ops/profile.origin.traffic_ops
new file mode 100644
index 0000000..f655f89
--- /dev/null
+++ b/infrastructure/cdn-in-a-box/traffic_ops/profile.origin.traffic_ops
@@ -0,0 +1,18 @@
+{
+    "parameters": [
+        {
+            "config_file": "CRConfig.json",
+            "name": "domain_name",
+            "value": "{{.Domain}}"
+        },
+        {
+            "config_file": "parent.config",
+            "name": "weight",
+            "value": "1.0"
+        }
+    ],
+    "profile": {
+        "description": "Multi site origin profile 1",
+        "name": "ORG1_CDN1"
+    }
+}
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/run.sh b/infrastructure/cdn-in-a-box/traffic_ops/run.sh
new file mode 100755
index 0000000..5aed968
--- /dev/null
+++ b/infrastructure/cdn-in-a-box/traffic_ops/run.sh
@@ -0,0 +1,292 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Script for running the Dockerfile for Traffic Ops.
+# The Dockerfile sets up a Docker image which can be used for any new Traffic Ops container;
+# This script, which should be run when the container is run (it's the ENTRYPOINT), will configure the container.
+#
+# The following environment variables must be set, ordinarily by `docker run -e` arguments:
+# DB_SERVER
+# DB_PORT
+# DB_ROOT_PASS
+# DB_USER
+# DB_USER_PASS
+# DB_NAME
+# ADMIN_USER
+# ADMIN_PASS
+# CERT_COUNTRY
+# CERT_STATE
+# CERT_CITY
+# CERT_COMPANY
+# DOMAIN
+
+# TODO:  Unused -- should be removed?  TRAFFIC_VAULT_PASS
+
+# Check that env vars are set
+envvars=( DB_SERVER DB_PORT DB_ROOT_PASS DB_USER DB_USER_PASS ADMIN_USER ADMIN_PASS CERT_COUNTRY CERT_STATE CERT_CITY CERT_COMPANY DOMAIN)
+for v in $envvars
+do
+	if [[ -z $$v ]]; then echo "$v is unset"; exit 1; fi
+done
+
+start() {
+	service traffic_ops start
+	exec tail -f /var/log/traffic_ops/traffic_ops.log
+}
+
+init() {
+	local postinstall_input_file="postinstall-input.json"
+	cat > "$postinstall_input_file" <<- ENDOFMESSAGE
+{
+  "/opt/traffic_ops/app/conf/production/database.conf":[
+    {
+      "Database type":"Pg",
+      "config_var":"type"
+    },
+    {
+      "Database name":"$DB_NAME",
+      "config_var":"dbname"
+    },
+    {
+      "Database server hostname IP or FQDN":"$DB_SERVER",
+      "config_var":"hostname"
+    },
+    {
+      "Database port number":"$DB_PORT",
+      "config_var":"port"
+    },
+    {
+      "Traffic Ops database user":"$DB_USER",
+      "config_var":"user"
+    },
+    {
+      "Traffic Ops database password":"$DB_USER_PASS",
+      "config_var":"password",
+      "hidden":"1"
+    }
+  ],
+  "/opt/traffic_ops/app/db/dbconf.yml":[
+    {
+      "Database server root (admin) user":"postgres",
+      "config_var":"pgUser"
+    },
+    {
+      "Database server admin password":"$DB_ROOT_PASS",
+      "config_var":"pgPassword",
+      "hidden":"1"
+    },
+    {
+      "Download Maxmind Database?":"yes",
+      "config_var":"maxmind"
+    }
+  ],
+  "/opt/traffic_ops/app/conf/cdn.conf":[
+    {
+      "Generate a new secret?":"yes",
+      "config_var":"genSecret"
+    },
+    {
+      "Port to serve on?": "443",
+      "config_var": "port"
+    },
+    {
+      "Number of workers?": "12",
+      "config_var":"workers"
+    },
+    {
+      "Traffic Ops url?": "https://$HOSTNAME",
+      "config_var": "base_url"
+    },
+    {
+      "Number of secrets to keep?":"1",
+      "config_var":"keepSecrets"
+    }
+  ],
+  "/opt/traffic_ops/app/conf/ldap.conf":[
+    {
+      "Do you want to set up LDAP?":"no",
+      "config_var":"setupLdap"
+    },
+    {
+      "LDAP server hostname":"",
+      "config_var":"host"
+    },
+    {
+      "LDAP Admin DN":"",
+      "config_var":"admin_dn"
+    },
+    {
+      "LDAP Admin Password":"",
+      "config_var":"admin_pass",
+      "hidden":"1"
+    },
+    {
+      "LDAP Search Base":"",
+      "config_var":"search_base"
+    }
+  ],
+  "/opt/traffic_ops/install/data/json/users.json":[
+    {
+      "Administration username for Traffic Ops":"$ADMIN_USER",
+      "config_var":"tmAdminUser"
+    },
+    {
+      "Password for the admin user":"$ADMIN_PASS",
+      "config_var":"tmAdminPw",
+      "hidden":"1"
+    }
+  ],
+  "/opt/traffic_ops/install/data/profiles/":[
+    {
+      "Add custom profiles?":"no",
+      "config_var":"custom_profiles"
+    }
+  ],
+  "/opt/traffic_ops/install/data/json/openssl_configuration.json":[
+    {
+      "Do you want to generate a certificate?":"yes",
+      "config_var":"genCert"
+    },
+    {
+      "Country Name (2 letter code)":"$CERT_COUNTRY",
+      "config_var":"country"
+    },
+    {
+      "State or Province Name (full name)":"$CERT_STATE",
+      "config_var":"state"
+    },
+    {
+      "Locality Name (eg, city)":"$CERT_CITY",
+      "config_var":"locality"
+    },
+    {
+      "Organization Name (eg, company)":"$CERT_COMPANY",
+      "config_var":"company"
+    },
+    {
+      "Organizational Unit Name (eg, section)":"",
+      "config_var":"org_unit"
+    },
+    {
+      "Common Name (eg, your name or your server's hostname)":"$HOSTNAME",
+      "config_var":"common_name"
+    },
+    {
+      "RSA Passphrase":"passphrase",
+      "config_var":"rsaPassword",
+      "hidden":"1"
+    }
+  ],
+  "/opt/traffic_ops/install/data/json/profiles.json":[
+    {
+      "Traffic Ops url":"https://$HOSTNAME",
+      "config_var":"tm.url"
+    },
+    {
+      "Human-readable CDN Name.  (No whitespace, please)":"cdn",
+      "config_var":"cdn_name"
+    },
+    {
+      "Health Polling Interval (milliseconds)":"8000",
+      "config_var":"health_polling_int"
+    },
+    {
+      "DNS sub-domain for which your CDN is authoritative":"$HOSTNAME.$DOMAIN",
+      "config_var":"dns_subdomain"
+    },
+    {
+      "TLD SOA admin":"traffic_ops",
+      "config_var":"soa_admin"
+    },
+    {
+      "TrafficServer Drive Prefix":"/dev/ram",
+      "config_var":"driver_prefix"
+    },
+    {
+      "TrafficServer RAM Drive Prefix":"/dev/ram",
+      "config_var":"ram_drive_prefix"
+    },
+    {
+      "TrafficServer RAM Drive Letters (comma separated)":"1",
+      "config_var":"ram_drive_letters"
+    },
+    {
+      "Health Threshold Load Average":"25",
+      "config_var":"health_thresh_load_avg"
+    },
+    {
+      "Health Threshold Available Bandwidth in Kbps":"1750000",
+      "config_var":"health_thresh_kbps"
+    },
+    {
+      "Traffic Server Health Connection Timeout (milliseconds)":"2000",
+      "config_var":"health_connect_timeout"
+    }
+  ]
+}
+	ENDOFMESSAGE
+
+	# TODO determine if term, user are necessary
+	export TERM=xterm && export USER=root && /opt/traffic_ops/install/bin/postinstall -cfile "$postinstall_input_file"
+
+	# Only listen on IPv4, not IPv6, because Docker doesn't provide a v6 interface by default. See http://mojolicious.org/perldoc/Mojo/Server/Daemon#listen
+	sed -i -e 's#https://\[::\]#https://127\.0\.0\.1#' /opt/traffic_ops/app/conf/cdn.conf
+	service traffic_ops restart
+
+	TRAFFIC_OPS_URI="https://localhost"
+
+	TMP_TO_COOKIE="$(curl -v -s -k -X POST --data '{ "u":"'"$ADMIN_USER"'", "p":"'"$ADMIN_PASS"'" }' $TRAFFIC_OPS_URI/api/1.2/user/login 2>&1 | grep 'Set-Cookie' | sed -e 's/.*mojolicious=\(.*\); expires.*/\1/')"
+	echo "Got cookie: $TMP_TO_COOKIE"
+
+	TMP_DOMAIN=$DOMAIN
+	sed -i -- "s/{{.Domain}}/$TMP_DOMAIN/g" /profile.origin.traffic_ops
+	echo "Got domain: $TMP_DOMAIN"
+
+	echo "Importing origin"
+	curl -v -k -X POST -H "Cookie: mojolicious=$TMP_TO_COOKIE" -F "filename=profile.origin.traffic_ops" -F "profile_to_import=@/profile.origin.traffic_ops" $TRAFFIC_OPS_URI/profile/doImport
+
+	curl -v -k -X POST -H "Cookie: mojolicious=$TMP_TO_COOKIE" --data-urlencode "division.name=East" $TRAFFIC_OPS_URI/division/create
+	TMP_DIVISION_ID="$(curl -s -k -X GET -H "Cookie: mojolicious=$TMP_TO_COOKIE" $TRAFFIC_OPS_URI/region/add | grep --color=never -oE "<option value=\"[0-9]+\">East</option>" | grep --color=never -oE "[0-9]+")"
+	echo "Got division ID: $TMP_DIVISION_ID"
+
+	curl -v -k -X POST -H "Cookie: mojolicious=$TMP_TO_COOKIE" --data-urlencode "region.name=Eastish" --data-urlencode "region.division_id=$TMP_DIVISION_ID" $TRAFFIC_OPS_URI/region/create
+	TMP_REGION_ID="$(curl -s -k -X GET -H "Cookie: mojolicious=$TMP_TO_COOKIE" $TRAFFIC_OPS_URI/api/1.2/regions.json | python -c 'import json,sys;obj=json.load(sys.stdin);match=[x["id"] for x in obj["response"] if x["name"]=="Eastish"]; print match[0]')"
+	echo "Got region ID: $TMP_REGION_ID"
+
+	TMP_CACHEGROUP_TYPE="$(curl -s -k -X GET -H "Cookie: mojolicious=$TMP_TO_COOKIE" $TRAFFIC_OPS_URI/api/1.2/types.json | python -c 'import json,sys;obj=json.load(sys.stdin);match=[x["id"] for x in obj["response"] if x["name"]=="MID_LOC"]; print match[0]')"
+	echo "Got cachegroup type ID: $TMP_CACHEGROUP_TYPE"
+
+	curl -v -k -X POST -H "Cookie: mojolicious=$TMP_TO_COOKIE" --data-urlencode "cg_data.name=mid-east" --data-urlencode "cg_data.short_name=east" --data-urlencode "cg_data.latitude=0" --data-urlencode "cg_data.longitude=0" --data-urlencode "cg_data.parent_cachegroup_id=-1" --data-urlencode "cg_data.type=$TMP_CACHEGROUP_TYPE" $TRAFFIC_OPS_URI/cachegroup/create
+	TMP_CACHEGROUP_ID="$(curl -s -k -X GET -H "Cookie: mojolicious=$TMP_TO_COOKIE" $TRAFFIC_OPS_URI/api/1.2/cachegroups.json | python -c 'import json,sys;obj=json.load(sys.stdin);match=[x["id"] for x in obj["response"] if x["name"]=="mid-east"]; print match[0]')"
+	echo "Got cachegroup ID: $TMP_CACHEGROUP_ID"
+
+	TMP_CACHEGROUP_EDGE_TYPE="$(curl -s -k -X GET -H "Cookie: mojolicious=$TMP_TO_COOKIE" $TRAFFIC_OPS_URI/api/1.2/types.json | python -c 'import json,sys;obj=json.load(sys.stdin);match=[x["id"] for x in obj["response"] if x["name"]=="EDGE_LOC"]; print match[0]')"
+	echo "Got cachegroup type ID: $TMP_CACHEGROUP_EDGE_TYPE"
+
+	curl -v -k -X POST -H "Cookie: mojolicious=$TMP_TO_COOKIE" --data-urlencode "cg_data.name=edge-east" --data-urlencode "cg_data.short_name=eeast" --data-urlencode "cg_data.latitude=0" --data-urlencode "cg_data.longitude=0" --data-urlencode "cg_data.parent_cachegroup_id=$TMP_CACHEGROUP_ID" --data-urlencode "cg_data.type=$TMP_CACHEGROUP_EDGE_TYPE" $TRAFFIC_OPS_URI/cachegroup/create
+	TMP_CACHEGROUP_EDGE_ID="$(curl -s -k -X GET -H "Cookie: mojolicious=$TMP_TO_COOKIE" $TRAFFIC_OPS_URI/api/1.2/cachegroups.json | python -c 'import json,sys;obj=json.load(sys.stdin);match=[x["id"] for x in obj["response"] if x["name"]=="edge-east"]; print match[0]')"
+	echo "Got cachegroup edge ID: $TMP_CACHEGROUP_EDGE_ID"
+
+	curl -v -k -X POST -H "Cookie: mojolicious=$TMP_TO_COOKIE" --data-urlencode "location.name=plocation-nyc-1" --data-urlencode "location.short_name=nyc" --data-urlencode "location.address=1 Main Street" --data-urlencode "location.city=nyc" --data-urlencode "location.state=NY" --data-urlencode "location.zip=12345" --data-urlencode "location.poc=" --data-urlencode "location.phone=" --data-urlencode "location.email=no@no.no" --data-urlencode "location.comments=" --data-urlencode "location.re [...]
+
+	echo "INITIALIZED=1" >> /etc/environment
+}
+
+source /etc/environment
+if [ -z "$INITIALIZED" ]; then init; fi
+start

-- 
To stop receiving notification emails like this one, please contact
dewrich@apache.org.

[trafficcontrol] 20/20: fix issues from review

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit a40a35ad7034d9e390a43b63a8b2419e22913dae
Author: Dan Kirkwood <da...@apache.org>
AuthorDate: Thu Jun 14 11:26:28 2018 -0600

    fix issues from review
---
 infrastructure/cdn-in-a-box/traffic_ops/config.sh | 10 +++++-----
 infrastructure/cdn-in-a-box/traffic_ops/run.sh    |  4 +++-
 infrastructure/cdn-in-a-box/variables.env         | 16 ++++++++++++++++
 3 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/infrastructure/cdn-in-a-box/traffic_ops/config.sh b/infrastructure/cdn-in-a-box/traffic_ops/config.sh
index 6e92c82..14730f3 100755
--- a/infrastructure/cdn-in-a-box/traffic_ops/config.sh
+++ b/infrastructure/cdn-in-a-box/traffic_ops/config.sh
@@ -68,11 +68,11 @@ cat <<-EOF >/opt/traffic_ops/app/conf/cdn.conf
         "read_header_timeout" : 60,
         "write_timeout" : 60,
         "idle_timeout" : 60,
-        "log_location_error": "/var/log/traffic_ops/error.log",
-        "log_location_warning": "/var/log/traffic_ops/warning.log",
-        "log_location_info": "/var/log/traffic_ops/info.log",
-        "log_location_debug": "/var/log/traffic_ops/debug.log",
-        "log_location_event": "/var/log/traffic_ops/access.log",
+        "log_location_error": "stdout",
+        "log_location_warning": "stdout",
+        "log_location_info": "stdout",
+        "log_location_debug": "stdout",
+        "log_location_event": "stdout",
         "max_db_connections": 20,
         "backend_max_connections": {
             "mojolicious": 4
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/run.sh b/infrastructure/cdn-in-a-box/traffic_ops/run.sh
index 7126ac7..f5fd76d 100755
--- a/infrastructure/cdn-in-a-box/traffic_ops/run.sh
+++ b/infrastructure/cdn-in-a-box/traffic_ops/run.sh
@@ -20,7 +20,9 @@
 # The Dockerfile sets up a Docker image which can be used for any new Traffic Ops container;
 # This script, which should be run when the container is run (it's the ENTRYPOINT), will configure the container.
 #
-# The following environment variables must be set, ordinarily by `docker run -e` arguments:
+# The following environment variables are used to configure the database and traffic ops.  They must be set
+# in ../variables.env for docker-compose to pick up the values:
+# 
 # DB_SERVER
 # DB_PORT
 # DB_ROOT_PASS
diff --git a/infrastructure/cdn-in-a-box/variables.env b/infrastructure/cdn-in-a-box/variables.env
index bde6dc3..50ecf51 100644
--- a/infrastructure/cdn-in-a-box/variables.env
+++ b/infrastructure/cdn-in-a-box/variables.env
@@ -1,3 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
 DOMAIN=domain
 CERT_CITY=Denver
 CERT_COMPANY=NotComcast

-- 
To stop receiving notification emails like this one, please contact
dewrich@apache.org.

[trafficcontrol] 13/20: move adduser.pl to where docker can pick up

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit 48241e03b5c4c40e40579c68c6bfb79a8736c353
Author: Dan Kirkwood <da...@gmail.com>
AuthorDate: Mon Jun 11 19:07:50 2018 +0000

    move adduser.pl to where docker can pick up
---
 infrastructure/cdn-in-a-box/traffic_ops/Dockerfile                      | 1 +
 .../app/db => infrastructure/cdn-in-a-box/traffic_ops}/adduser.pl       | 0
 infrastructure/cdn-in-a-box/traffic_ops/run.sh                          | 2 +-
 3 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
index d67b039..437ec3c 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
+++ b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
@@ -66,6 +66,7 @@ WORKDIR /opt/traffic_ops/app
 ENV MOJO_MODE production
 ADD profile.origin.traffic_ops /
 
+ADD adduser.pl /
 ADD config.sh /
 ADD run.sh /
 CMD /run.sh
diff --git a/traffic_ops/app/db/adduser.pl b/infrastructure/cdn-in-a-box/traffic_ops/adduser.pl
similarity index 100%
rename from traffic_ops/app/db/adduser.pl
rename to infrastructure/cdn-in-a-box/traffic_ops/adduser.pl
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/run.sh b/infrastructure/cdn-in-a-box/traffic_ops/run.sh
index d4b23e3..7897d02 100755
--- a/infrastructure/cdn-in-a-box/traffic_ops/run.sh
+++ b/infrastructure/cdn-in-a-box/traffic_ops/run.sh
@@ -66,7 +66,7 @@ cd $TO_DIR && \
 	./db/admin.pl --env=production reset && \
 	./db/admin.pl --env=production seed || echo "db setup failed!"
 
-./db/adduser.pl $TO_ADMIN_USER $TO_ADMIN_PASSWORD admin | psql -U$DB_USER -h$DB_SERVER $DB_NAME || echo "adding traffic_ops admin user failed!"
+/adduser.pl $TO_ADMIN_USER $TO_ADMIN_PASSWORD admin | psql -U$DB_USER -h$DB_SERVER $DB_NAME || echo "adding traffic_ops admin user failed!"
 
 cd $TO_DIR && $TO_DIR/local/bin/hypnotoad script/cdn
 exec tail -f /var/log/traffic_ops/traffic_ops.log

-- 
To stop receiving notification emails like this one, please contact
dewrich@apache.org.

[trafficcontrol] 05/20: clean up dockerfile

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit c65ea063d11f73cb2c87115f2e8a999148723a3d
Author: Dan Kirkwood <da...@gmail.com>
AuthorDate: Fri Jun 1 20:22:17 2018 +0000

    clean up dockerfile
---
 infrastructure/cdn-in-a-box/traffic_ops/Dockerfile | 31 +++++++++-------------
 1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
index 1ec9bcf..d67b039 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
+++ b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
@@ -21,14 +21,19 @@
 ############################################################
 
 
-FROM centos/systemd
-MAINTAINER Dan Kirkwood
+FROM centos:7
 
 RUN yum install -y https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-redhat96-9.6-3.noarch.rpm
-RUN yum install -y initscripts # needed for service command
-RUN yum install -y epel-release # needed for perl-Crypt-ScryptKDF
-RUN yum install -y perl-Crypt-ScryptKDF
-RUN yum install -y perl cpanminus perl-Test-CPAN-Meta
+RUN yum install -y \
+	cpanminus \
+	epel-release \
+	nmap-ncat \
+	openssl \
+	perl \
+	perl-Crypt-ScryptKDF \
+	perl-Test-CPAN-Meta && \
+	yum clean all
+
 RUN cpanm Carton
 RUN yum install -y perl-DBIx-Connector
 
@@ -42,30 +47,20 @@ RUN rm /$(basename $RPM)
 
 RUN POSTGRES_HOME=/usr/pgsql-9.6 cd /opt/traffic_ops/app && carton
 
-RUN /opt/traffic_ops/install/bin/install_go.sh
-RUN /opt/traffic_ops/install/bin/install_goose.sh
-
-# RUN export PERL5LIB=/opt/traffic_ops/app/local/lib/perl5/:/opt/traffic_ops/install/lib/ \
-# 	&& export TERM=xterm \
-# 	&& export USER=root \
-# 	&& yes | /opt/traffic_ops/install/bin/build_trafficops_perl_library -i
+RUN /opt/traffic_ops/install/bin/install_go.sh && \
+    /opt/traffic_ops/install/bin/install_goose.sh
 
 RUN export PERL5LIB=/opt/traffic_ops/app/local/lib/perl5/:/opt/traffic_ops/install/lib/ \
 	&& export TERM=xterm \
 	&& export USER=root \
 	&& /opt/traffic_ops/install/bin/download_web_deps -i
 
-# TODO: move this up along with other yum's
-RUN yum -y install nmap-ncat openssl
-
 # \todo add Drive Letters to postinstall input
 # RUN sed -i -- 's/"value": "b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y"/"value": "0"/g' /opt/traffic_ops/install/data/profiles/profile.trafficserver_edge.traffic_ops
 # RUN sed -i -- 's/"value": "b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y"/"value": "0"/g' /opt/traffic_ops/install/data/profiles/profile.trafficserver_mid.traffic_ops
 
 RUN echo "{\"user\": \"riakuser\",\"password\": \"$TRAFFIC_VAULT_PASS\"}" > /opt/traffic_ops/app/conf/production/riak.conf
 
-RUN cp /opt/traffic_ops/app/bin/traffic_ops_golang{,.new} && mv /opt/traffic_ops/app/bin/traffic_ops_golang{.new,} # fixes an 'Invalid Argument' bug; TODO diagnose, fix, & remove
-
 EXPOSE 443
 WORKDIR /opt/traffic_ops/app
 ENV MOJO_MODE production

-- 
To stop receiving notification emails like this one, please contact
dewrich@apache.org.

[trafficcontrol] 16/20: move compose file up

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit 2d1b8eba956fa5ca3ac5e8422646f9b6244a7763
Author: Dan Kirkwood <da...@apache.org>
AuthorDate: Wed Jun 13 09:16:11 2018 -0600

    move compose file up
---
 .../cdn-in-a-box/{traffic_ops => }/docker-compose.yml       |  6 +++---
 infrastructure/cdn-in-a-box/traffic_ops/Dockerfile          | 13 +++++++------
 infrastructure/cdn-in-a-box/{traffic_ops => }/variables.env |  0
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml b/infrastructure/cdn-in-a-box/docker-compose.yml
similarity index 96%
rename from infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml
rename to infrastructure/cdn-in-a-box/docker-compose.yml
index fe6b1ca..cbe5f92 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml
+++ b/infrastructure/cdn-in-a-box/docker-compose.yml
@@ -68,9 +68,9 @@ services:
     ports: 
       - "60443:60443"
     build:
-      context: .
+      context: traffic_ops
       args:
-        RPM: traffic_ops.rpm 
+        TRAFFIC_OPS_RPM: traffic_ops.rpm
     depends_on:
       - db
 
@@ -85,7 +85,7 @@ services:
     ports: 
       - "8443:443"
     build:
-      context: .
+      context: traffic_ops
       dockerfile: Dockerfile-go
     depends_on:
       - db
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
index 437ec3c..dd4ea75 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
+++ b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
@@ -37,15 +37,16 @@ RUN yum install -y \
 RUN cpanm Carton
 RUN yum install -y perl-DBIx-Connector
 
-# Override RPM arg to use a different one using --build-arg RPM=...  Can be local file or http://...
-ARG RPM=traffic_ops.rpm
-ADD $RPM /
-RUN yum install -y /$(basename $RPM)
+# Override TRAFFIC_OPS_RPM arg to use a different one using --build-arg TRAFFIC_OPS_RPM=...  Can be local file or http://...
+ARG TRAFFIC_OPS_RPM=traffic_ops.rpm
+ADD $TRAFFIC_OPS_RPM /
+RUN yum install -y /$(basename $TRAFFIC_OPS_RPM)
 
 # once installed, remove rpm to lower image size
-RUN rm /$(basename $RPM)
+RUN rm /$(basename $TRAFFIC_OPS_RPM) && \
+    yum clean all
 
-RUN POSTGRES_HOME=/usr/pgsql-9.6 cd /opt/traffic_ops/app && carton
+RUN POSTGRES_HOME=/usr/pgsql-9.6 cd /opt/traffic_ops/app && carton && rm -rf $HOME/.cpan*
 
 RUN /opt/traffic_ops/install/bin/install_go.sh && \
     /opt/traffic_ops/install/bin/install_goose.sh
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/variables.env b/infrastructure/cdn-in-a-box/variables.env
similarity index 100%
rename from infrastructure/cdn-in-a-box/traffic_ops/variables.env
rename to infrastructure/cdn-in-a-box/variables.env

-- 
To stop receiving notification emails like this one, please contact
dewrich@apache.org.

[trafficcontrol] 02/20: separate perl and go containers

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit 98d602766fc053efd1ec60d264e7ab4df23978e9
Author: Dan Kirkwood <da...@gmail.com>
AuthorDate: Thu May 31 15:45:28 2018 +0000

    separate perl and go containers
---
 infrastructure/cdn-in-a-box/traffic_ops/Dockerfile |  7 --
 .../{Dockerfile_psql => Dockerfile-dbinit}         |  0
 .../traffic_ops/{dbInit.sh => Dockerfile-go}       | 21 +++---
 infrastructure/cdn-in-a-box/traffic_ops/dbInit.sh  |  4 +-
 .../cdn-in-a-box/traffic_ops/docker-compose.yml    | 74 +++++++++++++++-------
 infrastructure/cdn-in-a-box/traffic_ops/run.sh     |  3 +-
 6 files changed, 67 insertions(+), 42 deletions(-)

diff --git a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
index 9c94e24..c176522 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
+++ b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
@@ -20,13 +20,6 @@
 # Based on CentOS 7.2
 ############################################################
 
-# Example Build and Run:
-# docker network create cdnet
-# docker build --rm --tag traffic_ops:1.7.0 --build-arg=RPM=http://traffic-control-cdn.net/downloads/1.7.0/RELEASE-1.7.0/traffic_ops-1.7.0-3908.5b77f60f.x86_64.rpm traffic_ops
-#
-# docker run --name my-traffic-ops-mysql --hostname my-traffic-ops-mysql --net cdnet --env MYSQL_ROOT_PASSWORD=secretrootpass --detach mysql:5.5
-#
-# docker run --name my-traffic-ops --hostname my-traffic-ops --net cdnet --publish 443:443 --env MYSQL_IP=my-traffic-ops-mysql --env MYSQL_PORT=3306 --env MYSQL_ROOT_PASS=secretrootpass --env MYSQL_TRAFFIC_OPS_PASS=supersecretpassword --env ADMIN_USER=superroot --env ADMIN_PASS=supersecreterpassward --env CERT_COUNTRY=US --env CERT_STATE=Colorado --env CERT_CITY=Denver --env CERT_COMPANY=NotComcast --env TRAFFIC_VAULT_PASS=marginallylesssecret --env DOMAIN=cdnet --detach traffic_ops:1.5.1
 
 FROM centos/systemd
 MAINTAINER Dan Kirkwood
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile_psql b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-dbinit
similarity index 100%
rename from infrastructure/cdn-in-a-box/traffic_ops/Dockerfile_psql
rename to infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-dbinit
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/dbInit.sh b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-go
old mode 100755
new mode 100644
similarity index 67%
copy from infrastructure/cdn-in-a-box/traffic_ops/dbInit.sh
copy to infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-go
index 80156f5..b7e8038
--- a/infrastructure/cdn-in-a-box/traffic_ops/dbInit.sh
+++ b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-go
@@ -1,4 +1,3 @@
-#!/usr/bin/env bash
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
@@ -17,14 +16,16 @@
 # under the License.
 
 ############################################################
-# Script for creating the database user account for traffic
-# ops. 
-# Used while the Docker Image is initializing itself
+# Dockerfile to build Traffic Ops container images
+# Based on CentOS 7.2
 ############################################################
 
-while ! nc $DB_SERVER $DB_PORT </dev/null; do # &>/dev/null; do
-        echo "waiting for $DB_SERVER:$DB_PORT"
-        sleep 3
-done
-psql -h $DB_SERVER -U postgres -c "CREATE USER $DB_USERNAME WITH ENCRYPTED PASSWORD '$DB_USER_PASS'"
-createdb $DB_NAME -h $DB_SERVER -U postgres --owner $DB_USERNAME
+
+FROM traffic_ops:2.3.0 AS trafficops-perl
+
+COPY --from=trafficops-perl /opt/traffic_ops/app/conf /opt/traffic_ops/app/conf
+COPY --from=trafficops-perl /opt/traffic_ops/app/bin/traffic_ops_golang /opt/traffic_ops/app/bin/traffic_ops_golang 
+
+EXPOSE 443
+WORKDIR /opt/traffic_ops/app
+ENTRYPOINT bash
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/dbInit.sh b/infrastructure/cdn-in-a-box/traffic_ops/dbInit.sh
index 80156f5..f4392d4 100755
--- a/infrastructure/cdn-in-a-box/traffic_ops/dbInit.sh
+++ b/infrastructure/cdn-in-a-box/traffic_ops/dbInit.sh
@@ -26,5 +26,5 @@ while ! nc $DB_SERVER $DB_PORT </dev/null; do # &>/dev/null; do
         echo "waiting for $DB_SERVER:$DB_PORT"
         sleep 3
 done
-psql -h $DB_SERVER -U postgres -c "CREATE USER $DB_USERNAME WITH ENCRYPTED PASSWORD '$DB_USER_PASS'"
-createdb $DB_NAME -h $DB_SERVER -U postgres --owner $DB_USERNAME
+psql -h $DB_SERVER -U postgres -c "CREATE USER $DB_USER WITH ENCRYPTED PASSWORD '$DB_USER_PASS'"
+createdb $DB_NAME -h $DB_SERVER -U postgres --owner $DB_USER
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml b/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml
index 8451aae..0001648 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml
+++ b/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml
@@ -30,57 +30,87 @@
 #
 
 ---
-version: '2'
+version: '2.1'
 
-volumes:
-  incubator-trafficcontrol:
-  traffic_ops:
-  conf:
+networks:
+  cdnnet:
+    driver: bridge
+    enable_ipv6: true
+    ipam:
+      driver: default
+      config:
+        - subnet: 172.13.238.0/24
+        - subnet: "fc01:9400:1000:7::/64"
 
 services:
   db:
     image: postgres:9.6.6
+    # TODO: change to expose: "5432" to limit to containers
     ports: 
       - "5432:5432"
 
-  db_init:
+  dbinit:
     environment:
       POSTGRES_HOME: /usr/pgsql-9.6
-      PGPASSWORD: secretrootpass
-      DB_USERNAME: traffic_ops
+      PGPASSWORD: password
       DB_NAME: traffic_ops
-      DB_USER_PASS: twelve
-      DB_SERVER: db
       DB_PORT: 5432
+      DB_SERVER: db
+      DB_USER_PASS: password
+      DB_USER: traffic_ops
     build:
       context: .
-      dockerfile: Dockerfile_psql
+      dockerfile: Dockerfile-dbinit
     depends_on: 
       - db
 
-  to_server:
+  trafficops-perl:
+    image: trafficops-perl
     environment:
-      DB_SERVER: db
+      DB_NAME: traffic_ops
       DB_PORT: 5432
+      DB_ROOT_PASS: password
+      DB_SERVER: db
+      DB_USER_PASS: password
+      DB_USER: traffic_ops
+      ADMIN_USER: superroot
+      ADMIN_PASS: password
+      CERT_COUNTRY: US
+      CERT_STATE: Colorado
+      CERT_CITY: Denver
+      CERT_COMPANY: NotComcast
+      TRAFFIC_VAULT_PASS: password
+      DOMAIN: trafficops_default
+    expose: 
+      - "60443"
+    build:
+      context: .
+      args:
+        RPM: traffic_ops.rpm 
+    depends_on:
+      - dbinit
+
+  trafficops:
+    image: trafficops-go
+    environment:
       DB_NAME: traffic_ops
-      DB_ROOT_PASS: null
-      DB_USER_PASS: twelve
+      DB_PORT: 5432
+      DB_ROOT_PASS: password
+      DB_SERVER: db
+      DB_USER_PASS: password
       DB_USER: traffic_ops
       ADMIN_USER: superroot
-      ADMIN_PASS: passward
+      ADMIN_PASS: password
       CERT_COUNTRY: US
       CERT_STATE: Colorado
       CERT_CITY: Denver
       CERT_COMPANY: NotComcast
-      TRAFFIC_VAULT_PASS: tvsecret
+      TRAFFIC_VAULT_PASS: password
       DOMAIN: trafficops_default
     ports: 
       - "443:443"
     build:
       context: .
-      args:
-        RPM: traffic_ops.rpm 
-    volumes:
-      - ../../../traffic_ops/traffic_ops_golang/traffic_ops_golang:/opt/traffic_ops/app/bin/traffic_ops_golang
+      dockerfile: Dockerfile-go
     depends_on:
-      - db_init
+      - dbinit
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/run.sh b/infrastructure/cdn-in-a-box/traffic_ops/run.sh
index 5aed968..48efc54 100755
--- a/infrastructure/cdn-in-a-box/traffic_ops/run.sh
+++ b/infrastructure/cdn-in-a-box/traffic_ops/run.sh
@@ -45,7 +45,8 @@ do
 done
 
 start() {
-	service traffic_ops start
+	TO_DIR=/opt/traffic_ops/app
+	cd $TO_DIR && $TO_DIR/local/bin/hypnotoad script/cdn
 	exec tail -f /var/log/traffic_ops/traffic_ops.log
 }
 

-- 
To stop receiving notification emails like this one, please contact
dewrich@apache.org.