split containers into base and erlang layers
diff --git a/ansible/centos-7-base.yml b/ansible/centos-7-base.yml
new file mode 100644
index 0000000..1a78c82
--- /dev/null
+++ b/ansible/centos-7-base.yml
@@ -0,0 +1,23 @@
+# 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.
+
+- hosts: couchdb-ci-worker
+  remote_user: root
+  roles:
+  - geerlingguy.repo-epel
+  - dependencies-centos
+  - common
diff --git a/ansible/centos-7-erlang-18.yml b/ansible/centos-7-erlang-18.yml
index 1ed08b9..492f252 100644
--- a/ansible/centos-7-erlang-18.yml
+++ b/ansible/centos-7-erlang-18.yml
@@ -18,7 +18,4 @@
 - hosts: couchdb-ci-worker
   remote_user: root
   roles:
-  - geerlingguy.repo-epel
-  - dependencies-centos
   - erlang-18-centos
-  - common
diff --git a/ansible/centos-7-erlang-default.yml b/ansible/centos-7-erlang-default.yml
index 11302e8..07bf3e1 100644
--- a/ansible/centos-7-erlang-default.yml
+++ b/ansible/centos-7-erlang-default.yml
@@ -18,7 +18,4 @@
 - hosts: couchdb-ci-worker
   remote_user: root
   roles:
-  - geerlingguy.repo-epel
-  - dependencies-centos
   - erlang-default-centos
-  - common
diff --git a/ansible/debian-8-base.yml b/ansible/debian-8-base.yml
new file mode 100644
index 0000000..b98e973
--- /dev/null
+++ b/ansible/debian-8-base.yml
@@ -0,0 +1,24 @@
+# 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.
+
+- hosts: couchdb-ci-worker
+  remote_user: root
+  roles:
+  - debian-8
+  - nodesource.node
+  - dependencies-debian
+  - common
diff --git a/ansible/debian-8-erlang-18.yml b/ansible/debian-8-erlang-18.yml
index 69e7d0f..953dbaf 100644
--- a/ansible/debian-8-erlang-18.yml
+++ b/ansible/debian-8-erlang-18.yml
@@ -19,7 +19,4 @@
   remote_user: root
   roles:
   - debian-8
-  - nodesource.node
-  - dependencies-debian
   - erlang-18-debian
-  - common
diff --git a/ansible/debian-8-erlang-default.yml b/ansible/debian-8-erlang-default.yml
index 808513c..1b0b0a7 100644
--- a/ansible/debian-8-erlang-default.yml
+++ b/ansible/debian-8-erlang-default.yml
@@ -19,7 +19,4 @@
   remote_user: root
   roles:
   - debian-8
-  - nodesource.node
-  - dependencies-debian
   - erlang-default-debian
-  - common
diff --git a/ansible/roles/dependencies-centos/tasks/latex.yml b/ansible/roles/dependencies-centos/tasks/latex.yml
new file mode 100644
index 0000000..ca0ba59
--- /dev/null
+++ b/ansible/roles/dependencies-centos/tasks/latex.yml
@@ -0,0 +1,43 @@
+# 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.
+
+- name: copy TeX Live installer
+  copy:
+    src: install-tl-unx.tar.gz
+    dest: /tmp/install-tl-unx.tar.gz
+- name: copy TeX Live installer profile
+  copy:
+    src: texlive.profile
+    dest: /tmp/texlive.profile
+- name: unpack TeX Live installer
+  unarchive:
+    src: /tmp/install-tl-unx.tar.gz
+    dest: /tmp
+    copy: no
+- name: install TeX Live via net installer
+  command: /tmp/install-tl-20160206/install-tl --profile=/tmp/texlive.profile
+  args:
+    chdir: /tmp/install-tl-20160206
+- name: install additional TeX packages
+  command: tlmgr install capt-of framed multirow needspace threeparttable titlesec upquote wrapfig
+
+# remove docs dir - this has no benefit for our use case and makes the
+# container 500 MB bigger
+- name: delete LaTeX docs
+  file:
+    path: /usr/local/texlive/2015/texmf-dist/doc
+    state: absent
diff --git a/ansible/roles/dependencies-centos/tasks/main.yml b/ansible/roles/dependencies-centos/tasks/main.yml
index a06d6fb..71a29d3 100644
--- a/ansible/roles/dependencies-centos/tasks/main.yml
+++ b/ansible/roles/dependencies-centos/tasks/main.yml
@@ -57,22 +57,8 @@
 - name: install up to date version of sphinx via pip
   shell: pip install sphinx==1.3.4
 
-- name: copy TeX Live installer
-  copy:
-    src: install-tl-unx.tar.gz
-    dest: /tmp/install-tl-unx.tar.gz
-- name: copy TeX Live installer profile
-  copy:
-    src: texlive.profile
-    dest: /tmp/texlive.profile
-- name: unpack TeX Live installer
-  unarchive:
-    src: /tmp/install-tl-unx.tar.gz
-    dest: /tmp
-    copy: no
-- name: install TeX Live via net installer
-  command: /tmp/install-tl-20160206/install-tl --profile=/tmp/texlive.profile
-  args:
-    chdir: /tmp/install-tl-20160206
-- name: install additional TeX packages
-  command: tlmgr install capt-of framed multirow needspace threeparttable titlesec upquote wrapfig
+# download and install TeX Live
+- include: latex.yml
+
+- name: clean up yum cache
+  command: yum clean all
diff --git a/ansible/roles/erlang-18-centos/tasks/main.yml b/ansible/roles/erlang-18-centos/tasks/main.yml
index ba6a9c9..f082cbb 100644
--- a/ansible/roles/erlang-18-centos/tasks/main.yml
+++ b/ansible/roles/erlang-18-centos/tasks/main.yml
@@ -18,3 +18,6 @@
 - name: download and install Erlang 18
   yum:
     name: "https://packages.erlang-solutions.com/erlang/esl-erlang/FLAVOUR_1_general/esl-erlang_18.2-1~centos~6_amd64.rpm"
+
+- name: clean up yum cache
+  command: yum clean all
diff --git a/ansible/roles/erlang-default-centos/tasks/main.yml b/ansible/roles/erlang-default-centos/tasks/main.yml
index 61e8fc3..056f302 100644
--- a/ansible/roles/erlang-default-centos/tasks/main.yml
+++ b/ansible/roles/erlang-default-centos/tasks/main.yml
@@ -19,3 +19,6 @@
   yum: name={{item}} state=present
   with_items:
   - erlang
+
+- name: clean up yum cache
+  command: yum clean all
diff --git a/ansible/ubuntu-14.04-base.yml b/ansible/ubuntu-14.04-base.yml
new file mode 100644
index 0000000..030559c
--- /dev/null
+++ b/ansible/ubuntu-14.04-base.yml
@@ -0,0 +1,24 @@
+# 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.
+
+- hosts: couchdb-ci-worker
+  remote_user: root
+  roles:
+  - ubuntu-1404
+  - nodesource.node
+  - dependencies-debian
+  - common
diff --git a/ansible/ubuntu-14.04-erlang-18.yml b/ansible/ubuntu-14.04-erlang-18.yml
index c55f01a..e1f2792 100644
--- a/ansible/ubuntu-14.04-erlang-18.yml
+++ b/ansible/ubuntu-14.04-erlang-18.yml
@@ -19,7 +19,4 @@
   remote_user: root
   roles:
   - ubuntu-1404
-  - nodesource.node
-  - dependencies-debian
   - erlang-18-debian
-  - common
diff --git a/ansible/ubuntu-14.04-erlang-default.yml b/ansible/ubuntu-14.04-erlang-default.yml
index bab0183..087b097 100644
--- a/ansible/ubuntu-14.04-erlang-default.yml
+++ b/ansible/ubuntu-14.04-erlang-default.yml
@@ -19,7 +19,4 @@
   remote_user: root
   roles:
   - ubuntu-1404
-  - nodesource.node
-  - dependencies-debian
   - erlang-default-debian
-  - common
diff --git a/bin/centos-7-base/create-container.sh b/bin/centos-7-base/create-container.sh
new file mode 100755
index 0000000..5c76a88
--- /dev/null
+++ b/bin/centos-7-base/create-container.sh
@@ -0,0 +1,28 @@
+#!/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.
+
+set -e
+
+# The Docker containers need the root directory of this repository as their
+# build context (because they need the Ansible files).
+pushd `dirname $0`/../.. > /dev/null
+
+docker build -f dockerfiles/centos-7-base -t basti1302/couchdb-build-centos-7-base .
+
+popd > /dev/null
diff --git a/bin/centos-7-base/enter-container.sh b/bin/centos-7-base/enter-container.sh
new file mode 100755
index 0000000..4802026
--- /dev/null
+++ b/bin/centos-7-base/enter-container.sh
@@ -0,0 +1,20 @@
+#!/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.
+
+docker run -it basti1302/couchdb-build-centos-7-base bash
diff --git a/bin/centos-7-base/publish-container.sh b/bin/centos-7-base/publish-container.sh
new file mode 100755
index 0000000..a5ded1e
--- /dev/null
+++ b/bin/centos-7-base/publish-container.sh
@@ -0,0 +1,20 @@
+#!/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.
+
+docker push basti1302/couchdb-build-centos-7-base
diff --git a/bin/centos-7-erlang-18/create-container.sh b/bin/centos-7-erlang-18/create-container.sh
index 2254c7d..5925346 100755
--- a/bin/centos-7-erlang-18/create-container.sh
+++ b/bin/centos-7-erlang-18/create-container.sh
@@ -23,6 +23,6 @@
 # build context (because they need the Ansible files).
 pushd `dirname $0`/../.. > /dev/null
 
-docker build -f docker/centos-7-erlang-18/Dockerfile -t basti1302/couchdb-build-centos-7-erlang-18.2 .
+docker build -f dockerfiles/centos-7-erlang-18 -t basti1302/couchdb-build-centos-7-erlang-18.2 .
 
 popd > /dev/null
diff --git a/bin/centos-7-erlang-default/create-container.sh b/bin/centos-7-erlang-default/create-container.sh
index f93f581..3325143 100755
--- a/bin/centos-7-erlang-default/create-container.sh
+++ b/bin/centos-7-erlang-default/create-container.sh
@@ -23,6 +23,6 @@
 # build context (because they need the Ansible files).
 pushd `dirname $0`/../.. > /dev/null
 
-docker build -f docker/centos-7-erlang-default/Dockerfile -t basti1302/couchdb-build-centos-7-erlang-default .
+docker build -f dockerfiles/centos-7-erlang-default -t basti1302/couchdb-build-centos-7-erlang-default .
 
 popd > /dev/null
diff --git a/bin/debian-8-base/create-container.sh b/bin/debian-8-base/create-container.sh
new file mode 100755
index 0000000..97ae00e
--- /dev/null
+++ b/bin/debian-8-base/create-container.sh
@@ -0,0 +1,28 @@
+#!/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.
+
+set -e
+
+# The Docker containers need the root directory of this repository as their
+# build context (because they need the Ansible files).
+pushd `dirname $0`/../.. > /dev/null
+
+docker build -f dockerfiles/debian-8-base -t basti1302/couchdb-build-debian-8-base .
+
+popd > /dev/null
diff --git a/bin/debian-8-base/enter-container.sh b/bin/debian-8-base/enter-container.sh
new file mode 100755
index 0000000..2cf06c1
--- /dev/null
+++ b/bin/debian-8-base/enter-container.sh
@@ -0,0 +1,20 @@
+#!/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.
+
+docker run -it basti1302/couchdb-build-debian-8-base bash
diff --git a/bin/debian-8-base/publish-container.sh b/bin/debian-8-base/publish-container.sh
new file mode 100755
index 0000000..a69aea3
--- /dev/null
+++ b/bin/debian-8-base/publish-container.sh
@@ -0,0 +1,20 @@
+#!/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.
+
+docker push basti1302/couchdb-build-debian-8-base
diff --git a/bin/debian-8-erlang-18/create-container.sh b/bin/debian-8-erlang-18/create-container.sh
index 4745d12..209d782 100755
--- a/bin/debian-8-erlang-18/create-container.sh
+++ b/bin/debian-8-erlang-18/create-container.sh
@@ -23,6 +23,6 @@
 # build context (because they need the Ansible files).
 pushd `dirname $0`/../.. > /dev/null
 
-docker build -f docker/debian-8-erlang-18/Dockerfile -t basti1302/couchdb-build-debian-8-erlang-18.2 .
+docker build -f dockerfiles/debian-8-erlang-18 -t basti1302/couchdb-build-debian-8-erlang-18.2 .
 
 popd > /dev/null
diff --git a/bin/debian-8-erlang-default/create-container.sh b/bin/debian-8-erlang-default/create-container.sh
index ae506d9..f8d395c 100755
--- a/bin/debian-8-erlang-default/create-container.sh
+++ b/bin/debian-8-erlang-default/create-container.sh
@@ -23,6 +23,6 @@
 # build context (because they need the Ansible files).
 pushd `dirname $0`/../.. > /dev/null
 
-docker build -f docker/debian-8-erlang-default/Dockerfile -t basti1302/couchdb-build-debian-8-erlang-default .
+docker build -f dockerfiles/debian-8-erlang-default -t basti1302/couchdb-build-debian-8-erlang-default .
 
 popd > /dev/null
diff --git a/bin/ubuntu-14.04-base/create-container.sh b/bin/ubuntu-14.04-base/create-container.sh
new file mode 100755
index 0000000..046c97f
--- /dev/null
+++ b/bin/ubuntu-14.04-base/create-container.sh
@@ -0,0 +1,28 @@
+#!/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.
+
+set -e
+
+# The Docker containers need the root directory of this repository as their
+# build context (because they need the Ansible files).
+pushd `dirname $0`/../.. > /dev/null
+
+docker build -f dockerfiles/ubuntu-14.04-base -t basti1302/couchdb-build-ubuntu-14.04-base .
+
+popd > /dev/null
diff --git a/bin/ubuntu-14.04-base/enter-container.sh b/bin/ubuntu-14.04-base/enter-container.sh
new file mode 100755
index 0000000..ac5691d
--- /dev/null
+++ b/bin/ubuntu-14.04-base/enter-container.sh
@@ -0,0 +1,20 @@
+#!/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.
+
+docker run -it basti1302/couchdb-build-ubuntu-14.04-base bash
diff --git a/bin/ubuntu-14.04-base/publish-container.sh b/bin/ubuntu-14.04-base/publish-container.sh
new file mode 100755
index 0000000..8625e7b
--- /dev/null
+++ b/bin/ubuntu-14.04-base/publish-container.sh
@@ -0,0 +1,20 @@
+#!/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.
+
+docker push basti1302/couchdb-build-ubuntu-14.04-base
diff --git a/bin/ubuntu-14.04-erlang-18/create-container.sh b/bin/ubuntu-14.04-erlang-18/create-container.sh
index f5b4faf..3a76a99 100755
--- a/bin/ubuntu-14.04-erlang-18/create-container.sh
+++ b/bin/ubuntu-14.04-erlang-18/create-container.sh
@@ -23,6 +23,6 @@
 # build context (because they need the Ansible files).
 pushd `dirname $0`/../.. > /dev/null
 
-docker build -f docker/ubuntu-14.04-erlang-18/Dockerfile -t basti1302/couchdb-build-ubuntu-14.04-erlang-18.2 .
+docker build -f dockerfiles/ubuntu-14.04-erlang-18 -t basti1302/couchdb-build-ubuntu-14.04-erlang-18.2 .
 
 popd > /dev/null
diff --git a/bin/ubuntu-14.04-erlang-default/create-container.sh b/bin/ubuntu-14.04-erlang-default/create-container.sh
index b96234f..695d219 100755
--- a/bin/ubuntu-14.04-erlang-default/create-container.sh
+++ b/bin/ubuntu-14.04-erlang-default/create-container.sh
@@ -23,6 +23,6 @@
 # build context (because they need the Ansible files).
 pushd `dirname $0`/../.. > /dev/null
 
-docker build -f docker/ubuntu-14.04-erlang-default/Dockerfile -t basti1302/couchdb-build-ubuntu-14.04-erlang-default .
+docker build -f dockerfiles/ubuntu-14.04-erlang-default -t basti1302/couchdb-build-ubuntu-14.04-erlang-default .
 
 popd > /dev/null
diff --git a/docker/centos-7-erlang-18/Dockerfile b/dockerfiles/centos-7-base
similarity index 89%
rename from docker/centos-7-erlang-18/Dockerfile
rename to dockerfiles/centos-7-base
index 8625106..17e23c4 100644
--- a/docker/centos-7-erlang-18/Dockerfile
+++ b/dockerfiles/centos-7-base
@@ -27,11 +27,7 @@
 # Install Ansible roles
 RUN ansible-galaxy install geerlingguy.repo-epel
 
-# Run Ansible to provision container
-RUN ansible-playbook centos-7-erlang-18.yml \
+# Run Ansible to provision CentOS base container
+RUN ansible-playbook centos-7-base.yml \
   --connection=local \
   --inventory-file=./inventory/couchdb-ci-worker
-
-USER couchdb
-
-CMD ["/home/couchdb/build-ci.sh"]
diff --git a/docker/centos-7-erlang-18/Dockerfile b/dockerfiles/centos-7-erlang-18
similarity index 77%
copy from docker/centos-7-erlang-18/Dockerfile
copy to dockerfiles/centos-7-erlang-18
index 8625106..771d5a2 100644
--- a/docker/centos-7-erlang-18/Dockerfile
+++ b/dockerfiles/centos-7-erlang-18
@@ -17,17 +17,9 @@
 # NOTE: All docker files need to be run from ../../, that is
 # docker build -f /docker/<container>/Dockerfile
 
-# Base Image: Plain Vanilla CentOS with Ansible installed
-FROM williamyeh/ansible:centos7-onbuild
+FROM basti1302/couchdb-build-centos-7-base:latest
 
-# Add ansible directory and cd to it
-ADD ./ansible /ansible
-WORKDIR /ansible
-
-# Install Ansible roles
-RUN ansible-galaxy install geerlingguy.repo-epel
-
-# Run Ansible to provision container
+# Run Ansible to provision container with Erlang 18.2
 RUN ansible-playbook centos-7-erlang-18.yml \
   --connection=local \
   --inventory-file=./inventory/couchdb-ci-worker
diff --git a/docker/centos-7-erlang-default/Dockerfile b/dockerfiles/centos-7-erlang-default
similarity index 78%
rename from docker/centos-7-erlang-default/Dockerfile
rename to dockerfiles/centos-7-erlang-default
index 543e213..ae1ad4a 100644
--- a/docker/centos-7-erlang-default/Dockerfile
+++ b/dockerfiles/centos-7-erlang-default
@@ -17,17 +17,9 @@
 # NOTE: All docker files need to be run from ../../, that is
 # docker build -f /docker/<container>/Dockerfile
 
-# Base Image: Plain Vanilla CentOS with Ansible installed
-FROM williamyeh/ansible:centos7-onbuild
+FROM basti1302/couchdb-build-centos-7-base:latest
 
-# Add ansible directory and cd to it
-ADD ./ansible /ansible
-WORKDIR /ansible
-
-# Install Ansible roles
-RUN ansible-galaxy install geerlingguy.repo-epel
-
-# Run Ansible to provision container
+# Run Ansible to provision container with CentOS' default Erlang
 RUN ansible-playbook centos-7-erlang-default.yml \
   --connection=local \
   --inventory-file=./inventory/couchdb-ci-worker
diff --git a/docker/debian-8-erlang-18/Dockerfile b/dockerfiles/debian-8-base
similarity index 89%
rename from docker/debian-8-erlang-18/Dockerfile
rename to dockerfiles/debian-8-base
index 14fc8e1..b479be4 100644
--- a/docker/debian-8-erlang-18/Dockerfile
+++ b/dockerfiles/debian-8-base
@@ -27,11 +27,7 @@
 # Install Ansible roles
 RUN ansible-galaxy install nodesource.node
 
-# Run Ansible to provision container
-RUN ansible-playbook debian-8-erlang-18.yml \
+# Run Ansible to provision Debian base container
+RUN ansible-playbook debian-8-base.yml \
   --connection=local \
   --inventory-file=./inventory/couchdb-ci-worker
-
-USER couchdb
-
-CMD ["/home/couchdb/build-ci.sh"]
diff --git a/docker/debian-8-erlang-18/Dockerfile b/dockerfiles/debian-8-erlang-18
similarity index 78%
copy from docker/debian-8-erlang-18/Dockerfile
copy to dockerfiles/debian-8-erlang-18
index 14fc8e1..ad06875 100644
--- a/docker/debian-8-erlang-18/Dockerfile
+++ b/dockerfiles/debian-8-erlang-18
@@ -17,17 +17,9 @@
 # NOTE: All docker files need to be run from ../../, that is
 # docker build -f /docker/<container>/Dockerfile
 
-# Base Image: Plain Vanilla Debian with Ansible installed
-FROM williamyeh/ansible:debian8-onbuild
+FROM basti1302/couchdb-build-debian-8-base:latest
 
-# Add ansible directory and cd to it
-ADD ./ansible /ansible
-WORKDIR /ansible
-
-# Install Ansible roles
-RUN ansible-galaxy install nodesource.node
-
-# Run Ansible to provision container
+# Run Ansible to provision container with Erlang 18.2
 RUN ansible-playbook debian-8-erlang-18.yml \
   --connection=local \
   --inventory-file=./inventory/couchdb-ci-worker
diff --git a/docker/debian-8-erlang-default/Dockerfile b/dockerfiles/debian-8-erlang-default
similarity index 78%
rename from docker/debian-8-erlang-default/Dockerfile
rename to dockerfiles/debian-8-erlang-default
index 4e7c946..7808e7f 100644
--- a/docker/debian-8-erlang-default/Dockerfile
+++ b/dockerfiles/debian-8-erlang-default
@@ -17,17 +17,9 @@
 # NOTE: All docker files need to be run from ../../, that is
 # docker build -f /docker/<container>/Dockerfile
 
-# Base Image: Plain Vanilla Debian with Ansible installed
-FROM williamyeh/ansible:debian8-onbuild
+FROM basti1302/couchdb-build-debian-8-base:latest
 
-# Add ansible directory and cd to it
-ADD ./ansible /ansible
-WORKDIR /ansible
-
-# Install Ansible roles
-RUN ansible-galaxy install nodesource.node
-
-# Run Ansible to provision container
+# Run Ansible to provision container with Debian's default Erlang
 RUN ansible-playbook debian-8-erlang-default.yml \
   --connection=local \
   --inventory-file=./inventory/couchdb-ci-worker
diff --git a/docker/ubuntu-14.04-erlang-18/Dockerfile b/dockerfiles/ubuntu-14.04-base
similarity index 89%
rename from docker/ubuntu-14.04-erlang-18/Dockerfile
rename to dockerfiles/ubuntu-14.04-base
index 9069515..8d5c59b 100644
--- a/docker/ubuntu-14.04-erlang-18/Dockerfile
+++ b/dockerfiles/ubuntu-14.04-base
@@ -27,11 +27,7 @@
 # Install Ansible roles
 RUN ansible-galaxy install nodesource.node
 
-# Run Ansible to provision container
-RUN ansible-playbook ubuntu-14.04-erlang-18.yml \
+# Run Ansible to provision Ubuntu base container
+RUN ansible-playbook ubuntu-14.04-base.yml \
   --connection=local \
   --inventory-file=./inventory/couchdb-ci-worker
-
-USER couchdb
-
-CMD ["/home/couchdb/build-ci.sh"]
diff --git a/docker/ubuntu-14.04-erlang-18/Dockerfile b/dockerfiles/ubuntu-14.04-erlang-18
similarity index 77%
copy from docker/ubuntu-14.04-erlang-18/Dockerfile
copy to dockerfiles/ubuntu-14.04-erlang-18
index 9069515..452dbeb 100644
--- a/docker/ubuntu-14.04-erlang-18/Dockerfile
+++ b/dockerfiles/ubuntu-14.04-erlang-18
@@ -17,17 +17,9 @@
 # NOTE: All docker files need to be run from ../../, that is
 # docker build -f /docker/<container>/Dockerfile
 
-# Base Image: Plain Vanilla Ubuntu 14.04 with Ansible installed
-FROM williamyeh/ansible:ubuntu14.04-onbuild
+FROM basti1302/couchdb-build-ubuntu-14.04-base:latest
 
-# Add ansible directory and cd to it
-ADD ./ansible /ansible
-WORKDIR /ansible
-
-# Install Ansible roles
-RUN ansible-galaxy install nodesource.node
-
-# Run Ansible to provision container
+# Run Ansible to provision container with Erlang 18.2
 RUN ansible-playbook ubuntu-14.04-erlang-18.yml \
   --connection=local \
   --inventory-file=./inventory/couchdb-ci-worker
diff --git a/docker/ubuntu-14.04-erlang-default/Dockerfile b/dockerfiles/ubuntu-14.04-erlang-default
similarity index 77%
rename from docker/ubuntu-14.04-erlang-default/Dockerfile
rename to dockerfiles/ubuntu-14.04-erlang-default
index fc444bc..ff8499b 100644
--- a/docker/ubuntu-14.04-erlang-default/Dockerfile
+++ b/dockerfiles/ubuntu-14.04-erlang-default
@@ -17,17 +17,9 @@
 # NOTE: All docker files need to be run from ../../, that is
 # docker build -f /docker/<container>/Dockerfile
 
-# Base Image: Plain Vanilla Ubuntu 14.04 with Ansible installed
-FROM williamyeh/ansible:ubuntu14.04-onbuild
+FROM basti1302/couchdb-build-ubuntu-14.04-base:latest
 
-# Add ansible directory and cd to it
-ADD ./ansible /ansible
-WORKDIR /ansible
-
-# Install Ansible roles
-RUN ansible-galaxy install nodesource.node
-
-# Run Ansible to provision container
+# Run Ansible to provision container with Ubuntu's default Erlang
 RUN ansible-playbook ubuntu-14.04-erlang-default.yml \
   --connection=local \
   --inventory-file=./inventory/couchdb-ci-worker