THRIFT-2962:Docker Thrift env for development and testing
Client: build
Patch: jfarrell

Adds build folder and moves all travis, cmake and docker build scripts into
one location for easier maintainability.
diff --git a/.travis.yml b/.travis.yml
index e29f555..cfa3c85 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -31,8 +31,8 @@
   - gcc
 
 before_install:
-  - sh contrib/installCXXDependencies.sh
-  - if [ "$ALL_DEPS" != "no" ] ; then sh contrib/installDependencies.sh 1> /dev/null ; fi
+  - sh build/travis/installCXXDependencies.sh
+  - if [ "$ALL_DEPS" != "no" ] ; then sh build/travis/installDependencies.sh 1> /dev/null ; fi
   - if [ "$ALL_DEPS" != "no" ] ; then export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/1.20/bin:$PATH ; fi
   - if [ "$ALL_DEPS" != "no" ] ; then cabal update ; fi
 
@@ -112,8 +112,8 @@
         - TEST_NAME="Debian Packages"
       compiler: clang
       before_install:
-       - sh contrib/installCXXDependencies.sh;
-       - sh contrib/installDependencies.sh 1> /dev/null;
+       - sh build/travis/installCXXDependencies.sh;
+       - sh build/travis/installDependencies.sh 1> /dev/null;
        - sudo apt-get install build-essential mono-gmcs mono-devel libmono-system-web2.0-cil erlang-base ruby1.8-dev python-all python-all-dev python-all-dbg php5 php5-dev
       script:
        - dpkg-buildpackage -tc -us -uc
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 712a5ca..3fe0f92 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -22,7 +22,7 @@
 
 project(thrift)
 
-set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake")
 
 # TODO: add `git rev-parse --short HEAD`
 # Read the version information from the Autoconf file
diff --git a/cmake/CPackConfig.cmake b/build/cmake/CPackConfig.cmake
similarity index 100%
rename from cmake/CPackConfig.cmake
rename to build/cmake/CPackConfig.cmake
diff --git a/cmake/ConfigureChecks.cmake b/build/cmake/ConfigureChecks.cmake
similarity index 100%
rename from cmake/ConfigureChecks.cmake
rename to build/cmake/ConfigureChecks.cmake
diff --git a/cmake/DefineCMakeDefaults.cmake b/build/cmake/DefineCMakeDefaults.cmake
similarity index 100%
rename from cmake/DefineCMakeDefaults.cmake
rename to build/cmake/DefineCMakeDefaults.cmake
diff --git a/cmake/DefineInstallationPaths.cmake b/build/cmake/DefineInstallationPaths.cmake
similarity index 100%
rename from cmake/DefineInstallationPaths.cmake
rename to build/cmake/DefineInstallationPaths.cmake
diff --git a/cmake/DefineOptions.cmake b/build/cmake/DefineOptions.cmake
similarity index 100%
rename from cmake/DefineOptions.cmake
rename to build/cmake/DefineOptions.cmake
diff --git a/cmake/DefinePlatformSpecifc.cmake b/build/cmake/DefinePlatformSpecifc.cmake
similarity index 100%
rename from cmake/DefinePlatformSpecifc.cmake
rename to build/cmake/DefinePlatformSpecifc.cmake
diff --git a/cmake/FindAnt.cmake b/build/cmake/FindAnt.cmake
similarity index 100%
rename from cmake/FindAnt.cmake
rename to build/cmake/FindAnt.cmake
diff --git a/cmake/FindGLIB.cmake b/build/cmake/FindGLIB.cmake
similarity index 100%
rename from cmake/FindGLIB.cmake
rename to build/cmake/FindGLIB.cmake
diff --git a/cmake/README.md b/build/cmake/README.md
similarity index 100%
rename from cmake/README.md
rename to build/cmake/README.md
diff --git a/cmake/ThriftMacros.cmake b/build/cmake/ThriftMacros.cmake
similarity index 100%
rename from cmake/ThriftMacros.cmake
rename to build/cmake/ThriftMacros.cmake
diff --git a/cmake/config.h.in b/build/cmake/config.h.in
similarity index 100%
rename from cmake/config.h.in
rename to build/cmake/config.h.in
diff --git a/build/docker/README.md b/build/docker/README.md
new file mode 100644
index 0000000..2ae309b
--- /dev/null
+++ b/build/docker/README.md
@@ -0,0 +1,27 @@
+# Apache Thrift Docker containers
+A set of docker containers used to build and test Apache Thrift
+
+### Available Containers
+
+* Ubuntu
+* Centos
+
+## Dependencies
+
+* A working Docker environment. A Vagrantfile is provided which will setup an Ubuntu host and working Docker environment as well as build the Apache Thrift Docker container for testing and development
+
+## Usage
+From the Apache Thrift code base root
+
+* Build
+
+	docker build -t thrift contrib/docker/ubuntu
+
+	or
+
+	docker build -t thrift contrib/docker/centos
+
+* Run
+
+	docker run -v $(pwd):/thrift -it thrift /bin/bash
+
diff --git a/build/docker/Vagrantfile b/build/docker/Vagrantfile
new file mode 100644
index 0000000..5eac6e6
--- /dev/null
+++ b/build/docker/Vagrantfile
@@ -0,0 +1,59 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+#
+# Licensed 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.
+
+# Base system bootstrap script
+$bootstrap_script = <<__BOOTSTRAP__
+echo "Provisioning defaults"
+
+sudo apt-get update -y
+sudo apt-get upgrade -y
+
+# Install default packages
+sudo apt-get install -y build-essential curl git
+
+# Install latest Docker version
+sudo curl -sSL https://get.docker.io/gpg | sudo apt-key add -
+sudo echo "deb http://get.docker.io/ubuntu docker main" > /etc/apt/sources.list.d/docker.list
+sudo apt-get update -y
+sudo apt-get install -y linux-image-extra-`uname -r` aufs-tools
+sudo apt-get install -y lxc-docker
+
+echo "Finished provisioning defaults"
+__BOOTSTRAP__
+
+Vagrant.configure("2") do |config|
+  config.vm.box = "trusty64"
+  config.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
+  config.ssh.forward_agent = true
+
+  config.vm.provider :virtualbox do |vbox|
+    vbox.customize ["modifyvm", :id, "--memory", "1024"]
+    vbox.customize ["modifyvm", :id, "--cpus", "2"]
+  end
+
+  # Setup the default bootstrap script for our ubuntu base box image
+  config.vm.provision "shell", inline: $bootstrap_script
+
+  # Setup the custom docker image from our Ubuntu Dockerfile
+  config.vm.provision "docker" do |d|
+    d.build_image "/vagrant/ubuntu", args: "-t thrift"
+  end
+
+  # Setup the custom docker image from our Centos Dockerfile
+  #config.vm.provision "docker" do |d|
+  #  d.build_image "/vagrant/centos", args: "-t thrift-centos"
+  #end
+
+end
diff --git a/build/docker/centos/Dockerfile b/build/docker/centos/Dockerfile
new file mode 100644
index 0000000..999a98f
--- /dev/null
+++ b/build/docker/centos/Dockerfile
@@ -0,0 +1,118 @@
+# Licensed 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.
+
+# Apache Thrift Docker build environment for Centos
+#
+# Known missing client libraries:
+#  - D
+#  - Haxe
+#
+
+FROM centos:6.6
+MAINTAINER Apache Thrift <dev@thrift.apache.org>
+
+ENV HOME /root
+
+RUN yum -y update
+
+# General dependencies
+RUN yum -y install -y tar m4 perl gcc git libtool libevent-devel zlib-devel openssl-devel
+
+RUN mkdir -p /tmp/epel && \
+    curl -SL "http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm" -o /tmp/epel/epel-release-6-8.noarch.rpm && \
+    cd /tmp/epel && \
+    rpm -ivh epel-release-6-8.noarch.rpm && \
+    cd $HOME
+
+# Autoconf
+RUN mkdir -p /tmp/autoconf && \
+    curl -SL "http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz" | tar -xzC /tmp/autoconf && \
+    cd /tmp/autoconf/autoconf-2.69 && \
+    ./configure --prefix=/usr && \
+    make && \
+    make install && \
+    cd $HOME
+
+# Automake
+RUN mkdir -p /tmp/automake && \
+    curl -SL "http://ftp.gnu.org/gnu/automake/automake-1.14.tar.gz" | tar -xzC /tmp/automake && \
+    cd /tmp/automake/automake-1.14 && \
+    ./configure --prefix=/usr && \
+    make && \
+    make install && \
+    cd $HOME
+
+# Bison
+RUN mkdir -p /tmp/bison && \
+    curl -SL "http://ftp.gnu.org/gnu/bison/bison-2.5.1.tar.gz" | tar -xzC /tmp/bison && \
+    cd /tmp/bison/bison-2.5.1 && \
+    ./configure --prefix=/usr && \
+    make && \
+    make install && \
+    cd $HOME
+
+# Install an updated Boost library
+RUN mkdir -p /tmp/boost && \
+    curl -SL "http://sourceforge.net/projects/boost/files/boost/1.55.0/boost_1_55_0.tar.gz" | tar -xzC /tmp/boost && \
+    cd /tmp/boost/boost_1_55_0 && \
+    ./bootstrap.sh  && \
+    ./b2 install && \
+    cd $HOME
+
+# Java Dependencies
+RUN yum install -y ant junit ant-nodeps ant-junit java-1.7.0-openjdk-devel
+
+# Python Dependencies
+RUN yum install -y python-devel python-setuptools python-twisted
+
+# Ruby Dependencies
+RUN yum install -y ruby ruby-devel rubygems && \
+    gem install bundler rake
+
+# Node.js Dependencies
+RUN yum install -y nodejs nodejs-devel npm
+
+# Perl Dependencies
+RUN yum install -y perl-Bit-Vector perl-Class-Accessor perl-ExtUtils-MakeMaker perl-Test-Simple
+
+# PHP Dependencies
+RUN yum install -y php php-devel php-pear re2c
+
+# GLibC Dependencies
+RUN yum install -y glib2-devel
+
+# Erlang Dependencies
+RUN yum install -y erlang-kernel erlang-erts erlang-stdlib erlang-eunit erlang-rebar
+
+# Lua Dependencies
+RUN yum install -y lua-devel
+
+# Go Dependencies
+RUN yum install -y golang golang-pkg-linux-amd64
+
+# C# Dependencies
+RUN yum install -y mono-core mono-devel mono-web-devel mono-extras mingw32-binutils mingw32-runtime mingw32-nsis
+
+# Haskell Dependencies
+RUN mkdir -p /tmp/haskell &&\
+    curl -SL "http://sherkin.justhub.org/el6/RPMS/x86_64/justhub-release-2.0-4.0.el6.x86_64.rpm" -o /tmp/haskell/justhub-release-2.0-4.0.el6.x86_64.rpm && \
+    cd /tmp/haskell && \
+    rpm -ivh justhub-release-2.0-4.0.el6.x86_64.rpm && \
+    yum -y install haskell && \
+    cabal update && \
+    cabal install cabal-install && \
+    cd $HOME
+
+# Clean up
+RUN rm -rf /tmp/*
+
+WORKDIR $HOME
\ No newline at end of file
diff --git a/build/docker/ubuntu/Dockerfile b/build/docker/ubuntu/Dockerfile
new file mode 100644
index 0000000..eff474f
--- /dev/null
+++ b/build/docker/ubuntu/Dockerfile
@@ -0,0 +1,103 @@
+# Licensed 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.
+
+# Apache Thrift Docker build environment for Centos
+#
+# Known missing client libraries:
+#  - None
+
+FROM ubuntu:trusty
+MAINTAINER Apache Thrift <dev@thrift.apache.org>
+
+ENV HOME /root
+ENV DEBIAN_FRONTEND noninteractive
+
+RUN apt-get update -y && apt-get dist-upgrade -y
+
+# General dependencies
+RUN apt-get install -y automake libtool flex bison pkg-config g++ libssl-dev make libqt4-dev git \
+    debhelper
+
+# C++ dependencies
+RUN apt-get install -y libboost-dev libboost-test-dev libboost-program-options-dev \
+    libboost-filesystem-dev libboost-system-dev libevent-dev
+
+# Java dependencies
+RUN apt-get install -y ant openjdk-7-jdk maven && \
+    update-java-alternatives -s java-1.7.0-openjdk-amd64
+
+# Python dependencies
+RUN apt-get install -y python-all python-all-dev python-all-dbg python-setuptools python-support
+
+# Ruby dependencies
+RUN apt-get install -y ruby ruby-dev && \
+    gem install bundler rake
+
+# Perl dependencies
+RUN apt-get install -y libbit-vector-perl libclass-accessor-class-perl
+
+# Php dependencies
+RUN apt-get install -y php5 php5-dev php5-cli php-pear re2c phpunit
+
+# GlibC dependencies
+RUN apt-get install -y libglib2.0-dev
+
+# Erlang dependencies
+RUN apt-get install -y erlang-base erlang-eunit erlang-dev
+
+# GO dependencies
+RUN echo "golang-go golang-go/dashboard boolean false" | debconf-set-selections && \
+    apt-get install -y golang golang-go
+
+# Haskell dependencies
+RUN apt-get install -y ghc cabal-install libghc-binary-dev libghc-network-dev libghc-http-dev \
+    libghc-hashable-dev libghc-unordered-containers-dev libghc-vector-dev && \
+    cabal update
+
+# Haxe
+RUN apt-get install -y libneko0 && \
+    mkdir -p /tmp/haxe /usr/lib/haxe && \
+    curl http://haxe.org/website-content/downloads/3,1,3/downloads/haxe-3.1.3-linux64.tar.gz -o /tmp/haxe/haxe-3.1.3-linux64.tar.gz && \
+    tar -xvzf /tmp/haxe/haxe-3.1.3-linux64.tar.gz -C /usr/lib/haxe --strip-components=1 && \
+    ln -s /usr/lib/haxe/haxe /usr/bin/haxe && \
+    ln -s /usr/lib/haxe/haxelib /usr/bin/haxelib && \
+    ln -s /usr/lib/libneko.so.0 /usr/lib/libneko.so && \
+    mkdir -p /usr/lib/haxe/lib  && \
+    chmod -R 777 /usr/lib/haxe/lib && \
+    haxelib setup /usr/lib/haxe/lib && \
+    haxelib install hxcpp
+
+# Lua dependencies
+RUN apt-get install -y lua5.2 lua5.2-dev
+
+# Node.js dependencies
+RUN apt-get install -y nodejs nodejs-dev nodejs-legacy npm
+
+# CSharp
+RUN apt-get install -y mono-gmcs mono-devel mono-xbuild mono-complete libmono-system-web2.0-cil \
+    mingw32 mingw32-binutils mingw32-runtime nsis
+
+# D dependencies
+# THRIFT-2916: DMD pinned to 2.065.0-0 due to regression in 2.066
+RUN curl http://master.dl.sourceforge.net/project/d-apt/files/d-apt.list -o /etc/apt/sources.list.d/d-apt.list && \
+    apt-get update && apt-get -y --allow-unauthenticated install --reinstall d-apt-keyring && \
+    apt-get update && \
+    apt-get install -y xdg-utils dmd-bin=2.065.0-0 libphobos2-dev=2.065.0-0
+
+# Clean up
+RUN apt-get clean && \
+    rm -rf /var/cache/apt/* && \
+    rm -rf /var/lib/apt/lists/* && \
+    rm -rf /tmp/* && \
+    rm -rf /var/tmp/*
+
+WORKDIR $HOME
diff --git a/contrib/installCXXDependencies.sh b/build/travis/installCXXDependencies.sh
old mode 100644
new mode 100755
similarity index 100%
rename from contrib/installCXXDependencies.sh
rename to build/travis/installCXXDependencies.sh
diff --git a/contrib/installDependencies.sh b/build/travis/installDependencies.sh
similarity index 100%
rename from contrib/installDependencies.sh
rename to build/travis/installDependencies.sh