VOL-621 add build hook to support build args on docker cloud

Change-Id: I2b5acfdd7ef96896751687f56480e68267334718
diff --git a/docker/hooks/README.md b/docker/hooks/README.md
new file mode 100644
index 0000000..23b27dd
--- /dev/null
+++ b/docker/hooks/README.md
@@ -0,0 +1,18 @@
+# What are these `hook` files?
+
+The files in this directory are levergaed by Docker Cloud (`cloud.docker.com`)
+in support of autmatically building VOLTHA containers on the Docker Cloud
+infrastructure.
+
+At issue is that for the automated builds Docker Cloud does not set docker
+build arguments. You can set environment variables via the automated build UI,
+but in order to make these values visible during the building of containers
+they must be converted to docker build arguments set via the `--build-arg` 
+command line option.
+
+To achieve this a custom *build hook* must be created. This hook will replace
+the stardard build command on Docker Cloud and augment the command by setting
+build arguments. This is the `build` file in this directory.
+
+Full documentation on *hooks* that can be used with Docker Cloud automated
+builds can be found at `https://docs.docker.com/docker-cloud/builds/advanced/`.
diff --git a/docker/hooks/build b/docker/hooks/build
new file mode 100755
index 0000000..618a914
--- /dev/null
+++ b/docker/hooks/build
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+echo "=> Using custom build hook to add build arguments"
+echo "=> set DEBUG=true to see debug information"
+
+if [ "$DEBUG" == "true" ]; then
+  env | sort
+fi
+
+cd /src/${BUILD_CODE}${BUILD_PATH}
+
+if [ "$DEBUG" == "true" ]; then
+  echo docker build --build-arg REPOSITORY=$REPOSITORY --build-arg REGISTRY=$REGISTRY --build-arg TAG=${TAG:-latest} -t $IMAGE_NAME -f $DOCKERFILE_PATH .
+fi
+
+docker build --build-arg REPOSITORY=$REPOSITORY --build-arg REGISTRY=$REGISTRY --build-arg TAG=${TAG:-latest} -t $IMAGE_NAME -f $DOCKERFILE_PATH .