BIGTOP-2679: Streamline CI Jobs
diff --git a/.dockerignore b/.dockerignore
index a7b219a..150d143 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -15,5 +15,4 @@
 
 build
 output
-bigtop-packages
 dl
diff --git a/bigtop-ci/create-container.sh b/bigtop-ci/create-container.sh
new file mode 100755
index 0000000..f04273a
--- /dev/null
+++ b/bigtop-ci/create-container.sh
@@ -0,0 +1,54 @@
+#!/bin/bash
+
+while [[ $# -gt 1 ]]
+do
+key="$1"
+case $key in
+    -t|--target)
+    TARGET="$2"
+    shift
+    ;;
+    -o|--os)
+    OS="$2" 
+    shift
+    ;;
+    -n|--nexus)
+    NEXUS="--net=container:nexus"
+    CONFIGURE_NEXUS="configure-nexus"
+    shift
+    ;;
+    *)
+    echo "usage build.sh --os debian-8|centos-7|... --target hadoop|tez|..."
+    exit 1 # unknown option
+    ;;
+esac
+shift
+done
+
+# prepare source image
+cat >Dockerfile <<EOF
+FROM bigtop/slaves:$OS
+# copy source to container
+COPY . /var/lib/jenkins/bigtop
+# make it belong to compile account
+# disable gradle daemon
+# create output dir (for docker cp)
+RUN mkdir -p /var/lib/jenkins/bigtop/output && chown -R jenkins /var/lib/jenkins/bigtop && sed -i /GRADLE_OPTS/d /etc/profile.d/bigtop.sh 
+# define default user jenkins
+USER jenkins
+WORKDIR /var/lib/jenkins/bigtop
+ENTRYPOINT [ "bigtop-ci/entrypoint.sh" ]
+# initialize gradle
+RUN bigtop-ci/entrypoint.sh
+# make it a volume, performancewise
+VOLUME /var/lib/jenkins
+EOF
+
+# build source image
+docker build -t image-$OS .
+
+# This container collects all the output
+# use gradle option "-m" 
+docker rm -f container-$OS || true
+docker run --name container-$OS image-$OS -m help
+
diff --git a/bigtop-ci/entrypoint.sh b/bigtop-ci/entrypoint.sh
new file mode 100755
index 0000000..cab665e
--- /dev/null
+++ b/bigtop-ci/entrypoint.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+. /etc/profile.d/bigtop.sh
+exec ./gradlew "$@"
diff --git a/bigtop-ci/repo-container.sh b/bigtop-ci/repo-container.sh
new file mode 100755
index 0000000..24d410d
--- /dev/null
+++ b/bigtop-ci/repo-container.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+while [[ $# -gt 1 ]]
+do
+key="$1"
+case $key in
+    -t|--target)
+    TARGET="$2"
+    shift
+    ;;
+    -o|--os)
+    OS="$2" 
+    shift
+    ;;
+    -n|--nexus)
+    NEXUS="--net=container:nexus"
+    CONFIGURE_NEXUS="configure-nexus"
+    shift
+    ;;
+    *)
+    echo "usage build.sh --os debian-8|centos-7|... --target hadoop|tez|..."
+    exit 1 # unknown option
+    ;;
+esac
+shift
+done
+
+docker commit container-$OS repo-$OS
+case $OS in 
+*debian*|*ubuntu*) R=apt;;
+*) R=yum;;
+esac
+docker run --name repo-container-$OS repo-$OS $R
+mkdir -p output
+docker cp repo-container-$OS:/var/lib/jenkins/bigtop/output .
+docker rm -v repo-container-$OS
diff --git a/bigtop-ci/run-container.sh b/bigtop-ci/run-container.sh
new file mode 100755
index 0000000..8f27617
--- /dev/null
+++ b/bigtop-ci/run-container.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+while [[ $# -gt 1 ]]
+do
+key="$1"
+case $key in
+    -t|--target)
+    TARGET="$2"
+    shift
+    ;;
+    -o|--os)
+    OS="$2" 
+    shift
+    ;;
+    -n|--nexus)
+    NEXUS="--net=container:nexus"
+    CONFIGURE_NEXUS="configure-nexus"
+    shift
+    ;;
+    *)
+    echo "usage build.sh --os debian-8|centos-7|... --target hadoop|tez|..."
+    exit 1 # unknown option
+    ;;
+esac
+shift
+done
+
+docker run --name container-$OS-$TARGET-$$ $NEXUS image-$OS $CONFIGURE_NEXUS $TARGET-pkg
+
+# save output
+mkdir -p output
+docker cp container-$OS-$TARGET-$$:/var/lib/jenkins/bigtop/output .
+# copy to results container
+docker cp output/  container-$OS:/var/lib/jenkins/bigtop/output
+docker rm -v container-$OS-$TARGET-$$