IPTV Containerization - larz7/larzworksamples GitHub Wiki

Overview

IPTV software development lifecycle and deployment runs in a containerized datacenter. The purpose of having a containerized datacenter is to isolate software development from corporate network traffic while providing a secure and convenient environment for software engineers. Containers can be torn down and rebuilt quickly without large scale overhead such as memory consumption.

Docker-Martin Configuration

Martin is a homegrown IPTV container orchestration tool and runtime scheduler deployed inside a Docker datacenter. After completing the following Docker-Martin integration steps, your source code repo in Git will be sync with your datacenter. You can additionally sync'd with the Travis CI/CD build tool.

Prerequisites

<namespace>: dev, qa, or prod
<resource>: the name of a resource, e.g. mysql
<unitName>: the name of the unit being deployed, e.g yourlaptop-http

Integration Steps

First, set up environment vars for Docker interaction using a username / password combination:

export MARTIN_DOCKER_USERNAME=XXXXXXXXXXXX
export MARTIN_DOCKER_PASSWORD=XXXXXXXXXXXX
export MARTIN_DOCKER_HOST=XXXXXXXXXXXX
  1. Add a line to your /etc/hosts so martin.local domain points to your local loopback interface.
127.0.0.1 martin.local
  1. Start the Martin service by using the following command inside your SBT shell:
http/re-start
  1. Open your browser at martin.local:9000 to confirm the service is operational.

  2. Configure Docker environment variables in docker-machine env default.

eval $(docker-machine env default)
  1. Configure Docker to login to your Git repository. This command will write a JSON configuration file to ~/.docker/config.json, which contains the login credentials you provided:
docker login -u myuser -p mypass -e myemail docker.xxxx.null.net
  1. Verify your installation by pulling the following image:
docker pull docker.xxxx.xxxx.com/xxxxx/build-name-3-2-jdk8
  1. Automate Martin when running the Docker image:

From the root of your Martin source tree, run the following command:

docker run --rm \
  --name martin-local \
  --env-file /tmp/martin/martin.env \
  -p 9000:9000 \
  -v "`pwd`/etc/classpath/revolver/logback.xml":/opt/application/conf/logback.xml \
  -v "`pwd`/etc/development/docker/martin.cfg":/opt/application/conf/martin.cfg \
  -v "`pwd`/db":/opt/application/db \
  docker.xxxx.xxxxx.com/units/martin:latest

The martin.env file will look like this:

MARTIN_SECURITY_BLOB=xxxxxxxxxxxx
MARTIN_GIT_SECRET=xxxxxxxxxxxx
MARTIN_GIT_CLIENT_ID=xxxxxxxxxxxx
MARTIN_DOMAIN=xxxxxxxxxxxx
GIT_USER=xxxxxxxxxxxx
GIT_TOKEN=xxxxxxxxxxxx

Launching your Containerized Datacenter

Start Docker:

docker run --name martin \
 --log-driver journald \
 --env-file martin.env \
 -p 8080:9000 \
 -v /path/to/db:/opt/application/db \
 -v /var/run/docker.sock:/opt/application/docker.sock \
 -v /path/to/.docker/config.json:/root/.docker/config.json:ro
 -v /etc/localtime:/etc/localtime:ro
 -v /path/to/datacenters.cfg:/opt/application/conf/datacenters.cfg:ro
 /martin:latest

You will see a log output of:

MARTIN_SECURITY_BLOB=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
MARTIN_GIT_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxx
MARTIN_GIT_CLIENT_ID=xxxxxxxxxxxxxxxxxxxxxxxxx
MARTIN_GIT_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxx
MARTIN_DOMAIN=your.nelson.domain.com

Your Docker-Martin integration is complete.

Configure Travis CI

Travis CI is integrated into the IPTV environment. To generate builds, configure the .travis.yml file to point to the root of your Git repository.

Run:

language: scala

scala:
  - 2.10.5

jdk:
  - oraclejdk8

branches:
  only:
    - master

sudo: required

before_script:
  - "if [ $TRAVIS_PULL_REQUEST = 'false' ]; then git checkout -qf $TRAVIS_BRANCH; fi"

script:
  - "if [ $TRAVIS_PULL_REQUEST = 'false' ]; then sbt ++$TRAVIS_SCALA_VERSION 'release with-defaults'; else sbt ++$TRAVIS_SCALA_VERSION test coverageReport coverageAggregate; fi"
  - find $HOME/.sbt -name "*.lock" | xargs rm
  - find $HOME/.data -name "data-*.properties" | xargs rm

cache:
  directories:
    - $HOME/.data/cache
    - $HOME/.sbt/boot/scala-$TRAVIS_SCALA_VERSION

⚠️ **GitHub.com Fallback** ⚠️