Install clang instead of gcc in bazel container. (#105)

* Install clang instead of gcc in bazel container.
* Also extract some more common yaml file.
* Move openssl check to java layer.


diff --git a/container/ubuntu16_04/layers/git/git.yaml b/container/common/git.yaml
similarity index 100%
rename from container/ubuntu16_04/layers/git/git.yaml
rename to container/common/git.yaml
diff --git a/container/common/java.yaml b/container/common/java.yaml
index 0fe3ce6..1bf8111 100644
--- a/container/common/java.yaml
+++ b/container/common/java.yaml
@@ -6,6 +6,10 @@
   args: ['-version']
   # java outputs to stderr.
   expectedError: ["openjdk version \"1.8.*"]
+- name: 'check-openssl'
+  command: 'openssl'
+  args: ['version']
+  expectedOutput: ['OpenSSL .*']
 
 fileExistenceTests:
 - name: 'OpenJDK'
diff --git a/container/common/rbe-base.yaml b/container/common/rbe-base.yaml
index e91e278..ddd2b5e 100644
--- a/container/common/rbe-base.yaml
+++ b/container/common/rbe-base.yaml
@@ -22,10 +22,6 @@
   args: ['-h']
   # nc outputs to stderr.
   expectedError: ['\[v.*']
-- name: 'check-openssl'
-  command: 'openssl'
-  args: ['version']
-  expectedOutput: ['OpenSSL .*']
 - name: 'check-patch'
   command: 'patch'
   args: ['--version']
diff --git a/container/ubuntu16_04/layers/wget/wget.yaml b/container/common/wget.yaml
similarity index 90%
rename from container/ubuntu16_04/layers/wget/wget.yaml
rename to container/common/wget.yaml
index 0eafc1f..1306865 100644
--- a/container/ubuntu16_04/layers/wget/wget.yaml
+++ b/container/common/wget.yaml
@@ -1,5 +1,6 @@
 schemaVersion: "2.0.0"
 
+commandTests:
 - name: 'check-wget'
   command: 'wget'
   args: ['--version']
diff --git a/container/ubuntu16_04/builders/bazel/BUILD b/container/ubuntu16_04/builders/bazel/BUILD
index d8d3932..9f11216 100644
--- a/container/ubuntu16_04/builders/bazel/BUILD
+++ b/container/ubuntu16_04/builders/bazel/BUILD
@@ -33,6 +33,7 @@
     # reproduction.
     installation_cleanup_commands = "update-ca-certificates -f",
     language_layers = [
+        "//container/ubuntu16_04/layers/clang:clang-ltl",
         "//container/ubuntu16_04/layers/java:java-ltl",
         "//container/ubuntu16_04/layers/python:python-ltl",
         "//container/ubuntu16_04/layers/bazel:bazel-tools",
@@ -46,12 +47,14 @@
     name = "bazel-test",
     configs = [
         ":container.yaml",
+        "//container/common:clang.yaml",
+        "//container/common:git.yaml",
         "//container/common:java.yaml",
         "//container/common:python2.yaml",
+        "//container/common:wget.yaml",
         "//container/ubuntu16_04:ubuntu16_04.yaml",
         "//container/ubuntu16_04/layers/bazel:bazel.yaml",
-        "//container/ubuntu16_04/layers/git:git.yaml",
-        "//container/ubuntu16_04/layers/wget:wget.yaml",
+        "//container/ubuntu16_04/layers/bazel:bazel_tools.yaml",
     ],
     image = ":bazel",
     verbose = True,
@@ -79,13 +82,15 @@
     name = "bazel_docker-test",
     configs = [
         ":container.yaml",
+        "//container/common:clang.yaml",
+        "//container/common:git.yaml",
         "//container/common:java.yaml",
         "//container/common:python2.yaml",
+        "//container/common:wget.yaml",
         "//container/ubuntu16_04:ubuntu16_04.yaml",
         "//container/ubuntu16_04/layers/bazel:bazel.yaml",
+        "//container/ubuntu16_04/layers/bazel:bazel_tools.yaml",
         "//container/ubuntu16_04/layers/docker-17.12.0:docker-17.12.0.yaml",
-        "//container/ubuntu16_04/layers/git:git.yaml",
-        "//container/ubuntu16_04/layers/wget:wget.yaml",
     ],
     image = ":bazel_docker",
     verbose = True,
diff --git a/container/ubuntu16_04/builders/bazel/container.yaml b/container/ubuntu16_04/builders/bazel/container.yaml
index 59a420d..c27a43a 100644
--- a/container/ubuntu16_04/builders/bazel/container.yaml
+++ b/container/ubuntu16_04/builders/bazel/container.yaml
@@ -1,28 +1,5 @@
 schemaVersion: "2.0.0"
 
-commandTests:
-- name: 'gcc-version'
-  command: 'gcc'
-  args: ['--version']
-  expectedOutput: ['gcc .*']
-- name: 'check-openssl'
-  command: 'openssl'
-  args: ['version']
-  expectedOutput: ['OpenSSL .*']
-- name: 'check-patch'
-  command: 'patch'
-  args: ['--version']
-  expectedOutput: ['GNU patch .*']
-- name: 'check-unzip'
-  command: 'unzip'
-  expectedOutput: ['.*Usage: unzip .*']
-- name: 'check-zip'
-  command: 'zip'
-  args: ['--version']
-  expectedOutput: ['.*This is Zip.*']
-
-
-
 metadataTest:
   env:
     - key: 'PATH'
diff --git a/container/ubuntu16_04/layers/bazel/BUILD b/container/ubuntu16_04/layers/bazel/BUILD
index 98eda91..ba799f9 100644
--- a/container/ubuntu16_04/layers/bazel/BUILD
+++ b/container/ubuntu16_04/layers/bazel/BUILD
@@ -18,16 +18,15 @@
 
 load("//container/rules:docker_toolchains.bzl", "language_tool_layer")
 
-exports_files(["bazel.yaml"])
+exports_files(glob(["*.yaml"]))
 
-#  gcc + other tools required by Bazel
+# Tools required by Bazel. Note that we do not add a CC complier here as we
+# will include that in the final container.
 language_tool_layer(
     name = "bazel-tools",
     base = "@ubuntu16_04//image",
     packages = [
-        "g++",
         "patch",
-        "software-properties-common",
         "unzip",
         "zip",
     ],
diff --git a/container/ubuntu16_04/layers/bazel/bazel_tools.yaml b/container/ubuntu16_04/layers/bazel/bazel_tools.yaml
new file mode 100644
index 0000000..5eefecb
--- /dev/null
+++ b/container/ubuntu16_04/layers/bazel/bazel_tools.yaml
@@ -0,0 +1,14 @@
+schemaVersion: "2.0.0"
+
+commandTests:
+- name: 'check-patch'
+  command: 'patch'
+  args: ['--version']
+  expectedOutput: ['GNU patch .*']
+- name: 'check-unzip'
+  command: 'unzip'
+  expectedOutput: ['.*Usage: unzip .*']
+- name: 'check-zip'
+  command: 'zip'
+  args: ['--version']
+  expectedOutput: ['.*This is Zip.*']
diff --git a/container/ubuntu16_04/layers/git/BUILD b/container/ubuntu16_04/layers/git/BUILD
index 95cae1b..cc1e88f 100644
--- a/container/ubuntu16_04/layers/git/BUILD
+++ b/container/ubuntu16_04/layers/git/BUILD
@@ -18,8 +18,6 @@
 
 load("//container/rules:docker_toolchains.bzl", "language_tool_layer")
 
-exports_files(["git.yaml"])
-
 language_tool_layer(
     name = "git-ltl",
     base = "@ubuntu16_04//image",
diff --git a/container/ubuntu16_04/layers/wget/BUILD b/container/ubuntu16_04/layers/wget/BUILD
index 3bb51c3..a551225 100644
--- a/container/ubuntu16_04/layers/wget/BUILD
+++ b/container/ubuntu16_04/layers/wget/BUILD
@@ -18,8 +18,6 @@
 
 load("//container/rules:docker_toolchains.bzl", "language_tool_layer")
 
-exports_files(["wget.yaml"])
-
 language_tool_layer(
     name = "wget-ltl",
     base = "@ubuntu16_04//image",