VOL-1674 - add version reporting information

Change-Id: Ie6cc244c66077467d371ffb3506ea0f4e817c197
diff --git a/docker/Dockerfile.afrouter b/docker/Dockerfile.afrouter
index e604e2c..04cbf4c 100644
--- a/docker/Dockerfile.afrouter
+++ b/docker/Dockerfile.afrouter
@@ -17,6 +17,13 @@
 
 FROM golang:1.12-alpine3.9 AS build-env
 
+ARG org_label_schema_version=unknown
+ARG org_label_schema_vcs_url=unknown
+ARG org_label_schema_vcs_ref=unknown
+ARG org_label_schema_build_date=unknown
+ARG org_opencord_vcs_commit_date=unknown
+ARG org_opencord_vcs_dirty=unknown
+
 # Install required packages
 RUN apk add --no-cache wget git make build-base protobuf protobuf-dev
 
@@ -43,7 +50,15 @@
 RUN cp vendor/github.com/opencord/voltha-protos/go/voltha.pb /build
 
 # Build
-RUN cd afrouter && go build -o /build/afrouter
+RUN cd afrouter && go build -o /build/afrouter \
+	-ldflags \
+	"-X github.com/opencord/voltha-go/common/version.version=$org_label_schema_version \
+	 -X github.com/opencord/voltha-go/common/version.vcsRef=$org_label_schema_vcs_ref  \
+	 -X github.com/opencord/voltha-go/common/version.vcsDirty=$org_opencord_vcs_dirty \
+	 -X github.com/opencord/voltha-go/common/version.goVersion=$(go version 2>&1 | sed -E  's/.*go([0-9]+\.[0-9]+\.[0-9]+).*/\1/g') \
+	 -X github.com/opencord/voltha-go/common/version.os=$(go env GOHOSTOS) \
+	 -X github.com/opencord/voltha-go/common/version.arch=$(go env GOHOSTARCH) \
+	 -X github.com/opencord/voltha-go/common/version.buildTime=$org_label_schema_build_date"
 
 # -------------
 # Image creation stage
diff --git a/docker/Dockerfile.afrouterTest b/docker/Dockerfile.afrouterTest
index c93570e..33c6d46 100644
--- a/docker/Dockerfile.afrouterTest
+++ b/docker/Dockerfile.afrouterTest
@@ -17,6 +17,13 @@
 
 FROM golang:1.12-alpine3.9 AS build-env
 
+ARG org_label_schema_version=unknown
+ARG org_label_schema_vcs_url=unknown
+ARG org_label_schema_vcs_ref=unknown
+ARG org_label_schema_build_date=unknown
+ARG org_opencord_vcs_commit_date=unknown
+ARG org_opencord_vcs_dirty=unknown
+
 # Install required packages
 RUN apk add --no-cache wget git make build-base protobuf protobuf-dev
 
@@ -48,8 +55,25 @@
 RUN cp vendor/github.com/opencord/voltha-protos/go/voltha.pb /build/tests/suites/
 
 # Build
-RUN cd afrouter && go build --tags integration -o /build/afrouter
-RUN cd tests/afrouter && go build --tags integration -o /build/afrouterTest
+RUN cd afrouter && go build --tags integration -o /build/afrouter \
+	-ldflags \
+	"-X github.com/opencord/voltha-go/common/version.version=$org_label_schema_version \
+	 -X github.com/opencord/voltha-go/common/version.vcsRef=$org_label_schema_vcs_ref  \
+	 -X github.com/opencord/voltha-go/common/version.vcsDirty=$org_opencord_vcs_dirty \
+	 -X github.com/opencord/voltha-go/common/version.goVersion=$(go version 2>&1 | sed -E  's/.*go([0-9]+\.[0-9]+\.[0-9]+).*/\1/g') \
+	 -X github.com/opencord/voltha-go/common/version.os=$(go env GOHOSTOS) \
+	 -X github.com/opencord/voltha-go/common/version.arch=$(go env GOHOSTARCH) \
+	 -X github.com/opencord/voltha-go/common/version.buildTime=$org_label_schema_build_date"
+
+RUN cd tests/afrouter && go build --tags integration -o /build/afrouterTest \
+	-ldflags \
+	"-X github.com/opencord/voltha-go/common/version.version=$org_label_schema_version \
+	 -X github.com/opencord/voltha-go/common/version.vcsRef=$org_label_schema_vcs_ref  \
+	 -X github.com/opencord/voltha-go/common/version.vcsDirty=$org_opencord_vcs_dirty \
+	 -X github.com/opencord/voltha-go/common/version.goVersion=$(go version 2>&1 | sed -E  's/.*go([0-9]+\.[0-9]+\.[0-9]+).*/\1/g') \
+	 -X github.com/opencord/voltha-go/common/version.os=$(uname -s | tr A-Z a-z) \
+	 -X github.com/opencord/voltha-go/common/version.arch=$(uname -m | tr A-Z a-z) \
+	 -X github.com/opencord/voltha-go/common/version.buildTime=$org_label_schema_build_date"
 
 # Run tests
 RUN cd /build/tests/suites && /build/afrouterTest -config main.json -logLevel 1
diff --git a/docker/Dockerfile.afrouterd b/docker/Dockerfile.afrouterd
index 123a5dc..6778b7b 100644
--- a/docker/Dockerfile.afrouterd
+++ b/docker/Dockerfile.afrouterd
@@ -17,6 +17,13 @@
 
 FROM golang:1.12-alpine3.9 AS build-env
 
+ARG org_label_schema_version=unknown
+ARG org_label_schema_vcs_url=unknown
+ARG org_label_schema_vcs_ref=unknown
+ARG org_label_schema_build_date=unknown
+ARG org_opencord_vcs_commit_date=unknown
+ARG org_opencord_vcs_dirty=unknown
+
 # Install required packages
 RUN apk add --no-cache wget git make build-base protobuf protobuf-dev
 
@@ -43,7 +50,15 @@
 RUN cp afrouter/arouter.json /build
 
 # Build
-RUN cd arouterd && go build -o /build/arouterd
+RUN cd arouterd && go build -o /build/arouterd \
+	-ldflags \
+	"-X github.com/opencord/voltha-go/common/version.version=$org_label_schema_version \
+	 -X github.com/opencord/voltha-go/common/version.vcsRef=$org_label_schema_vcs_ref  \
+	 -X github.com/opencord/voltha-go/common/version.vcsDirty=$org_opencord_vcs_dirty \
+	 -X github.com/opencord/voltha-go/common/version.goVersion=$(go version 2>&1 | sed -E  's/.*go([0-9]+\.[0-9]+\.[0-9]+).*/\1/g') \
+	 -X github.com/opencord/voltha-go/common/version.os=$(go env GOHOSTOS) \
+	 -X github.com/opencord/voltha-go/common/version.arch=$(go env GOHOSTARCH) \
+	 -X github.com/opencord/voltha-go/common/version.buildTime=$org_label_schema_build_date"
 
 # -------------
 # Image creation stage
diff --git a/docker/Dockerfile.ro_core b/docker/Dockerfile.ro_core
index 27dd34d..5b41c89 100644
--- a/docker/Dockerfile.ro_core
+++ b/docker/Dockerfile.ro_core
@@ -17,6 +17,13 @@
 
 FROM golang:1.12-alpine3.9 AS build-env
 
+ARG org_label_schema_version=unknown
+ARG org_label_schema_vcs_url=unknown
+ARG org_label_schema_vcs_ref=unknown
+ARG org_label_schema_build_date=unknown
+ARG org_opencord_vcs_commit_date=unknown
+ARG org_opencord_vcs_dirty=unknown
+
 # Install required packages
 RUN apk add --no-cache wget git make build-base protobuf protobuf-dev
 
@@ -38,7 +45,15 @@
 COPY ro_core ./ro_core
 
 # Build
-RUN cd ro_core && go build -o /build/ro_core
+RUN cd ro_core && go build -o /build/ro_core \
+	-ldflags \
+	"-X github.com/opencord/voltha-go/common/version.version=$org_label_schema_version \
+	 -X github.com/opencord/voltha-go/common/version.vcsRef=$org_label_schema_vcs_ref  \
+	 -X github.com/opencord/voltha-go/common/version.vcsDirty=$org_opencord_vcs_dirty \
+	 -X github.com/opencord/voltha-go/common/version.goVersion=$(go version 2>&1 | sed -E  's/.*go([0-9]+\.[0-9]+\.[0-9]+).*/\1/g') \
+	 -X github.com/opencord/voltha-go/common/version.os=$(go env GOHOSTOS) \
+	 -X github.com/opencord/voltha-go/common/version.arch=$(go env GOHOSTARCH) \
+	 -X github.com/opencord/voltha-go/common/version.buildTime=$org_label_schema_build_date"
 
 # -------------
 # Image creation stage
diff --git a/docker/Dockerfile.rw_core b/docker/Dockerfile.rw_core
index 6bd4f89..71996be 100644
--- a/docker/Dockerfile.rw_core
+++ b/docker/Dockerfile.rw_core
@@ -17,6 +17,13 @@
 
 FROM golang:1.12-alpine3.9 AS build-env
 
+ARG org_label_schema_version=unknown
+ARG org_label_schema_vcs_url=unknown
+ARG org_label_schema_vcs_ref=unknown
+ARG org_label_schema_build_date=unknown
+ARG org_opencord_vcs_commit_date=unknown
+ARG org_opencord_vcs_dirty=unknown
+
 # Install required packages
 RUN apk add --no-cache wget git make build-base protobuf protobuf-dev
 
@@ -38,7 +45,15 @@
 COPY rw_core ./rw_core
 
 # Build
-RUN cd rw_core && go build -o /build/rw_core
+RUN cd rw_core && go build -o /build/rw_core \
+	-ldflags \
+	"-X github.com/opencord/voltha-go/common/version.version=$org_label_schema_version \
+	 -X github.com/opencord/voltha-go/common/version.vcsRef=$org_label_schema_vcs_ref  \
+	 -X github.com/opencord/voltha-go/common/version.vcsDirty=$org_opencord_vcs_dirty \
+	 -X github.com/opencord/voltha-go/common/version.goVersion=$(go version 2>&1 | sed -E  's/.*go([0-9]+\.[0-9]+\.[0-9]+).*/\1/g') \
+	 -X github.com/opencord/voltha-go/common/version.os=$(go env GOHOSTOS) \
+	 -X github.com/opencord/voltha-go/common/version.arch=$(go env GOHOSTARCH) \
+	 -X github.com/opencord/voltha-go/common/version.buildTime=$org_label_schema_build_date"
 
 # -------------
 # Image creation stage
diff --git a/docker/Dockerfile.simulated_olt b/docker/Dockerfile.simulated_olt
index 0a14ac9..6904318 100644
--- a/docker/Dockerfile.simulated_olt
+++ b/docker/Dockerfile.simulated_olt
@@ -17,6 +17,13 @@
 
 FROM golang:1.12-alpine3.9 AS build-env
 
+ARG org_label_schema_version=unknown
+ARG org_label_schema_vcs_url=unknown
+ARG org_label_schema_vcs_ref=unknown
+ARG org_label_schema_build_date=unknown
+ARG org_opencord_vcs_commit_date=unknown
+ARG org_opencord_vcs_dirty=unknown
+
 # Install required packages
 RUN apk add --no-cache wget git make build-base protobuf protobuf-dev
 
@@ -40,7 +47,15 @@
 COPY adapters/*.go ./adapters/
 
 # Build
-RUN cd adapters/simulated_olt && go build -o /build/simulated_olt
+RUN cd adapters/simulated_olt && go build -o /build/simulated_olt \
+	-ldflags \
+	"-X github.com/opencord/voltha-go/common/version.version=$org_label_schema_version \
+	 -X github.com/opencord/voltha-go/common/version.vcsRef=$org_label_schema_vcs_ref  \
+	 -X github.com/opencord/voltha-go/common/version.vcsDirty=$org_opencord_vcs_dirty \
+	 -X github.com/opencord/voltha-go/common/version.goVersion=$(go version 2>&1 | sed -E  's/.*go([0-9]+\.[0-9]+\.[0-9]+).*/\1/g') \
+	 -X github.com/opencord/voltha-go/common/version.os=$(go env GOHOSTOS) \
+	 -X github.com/opencord/voltha-go/common/version.arch=$(go env GOHOSTARCH) \
+	 -X github.com/opencord/voltha-go/common/version.buildTime=$org_label_schema_build_date"
 
 # -------------
 # Image creation stage
diff --git a/docker/Dockerfile.simulated_onu b/docker/Dockerfile.simulated_onu
index b9d01cc..921fc2a 100644
--- a/docker/Dockerfile.simulated_onu
+++ b/docker/Dockerfile.simulated_onu
@@ -17,6 +17,13 @@
 
 FROM golang:1.12-alpine3.9 AS build-env
 
+ARG org_label_schema_version=unknown
+ARG org_label_schema_vcs_url=unknown
+ARG org_label_schema_vcs_ref=unknown
+ARG org_label_schema_build_date=unknown
+ARG org_opencord_vcs_commit_date=unknown
+ARG org_opencord_vcs_dirty=unknown
+
 # Install required packages
 RUN apk add --no-cache wget git make build-base protobuf protobuf-dev
 
@@ -40,7 +47,15 @@
 COPY adapters/*.go ./adapters/
 
 # Build
-RUN cd adapters/simulated_onu && go build -o /build/simulated_onu
+RUN cd adapters/simulated_onu && go build -o /build/simulated_onu \
+	-ldflags \
+	"-X github.com/opencord/voltha-go/common/version.version=$org_label_schema_version \
+	 -X github.com/opencord/voltha-go/common/version.vcsRef=$org_label_schema_vcs_ref  \
+	 -X github.com/opencord/voltha-go/common/version.vcsDirty=$org_opencord_vcs_dirty \
+	 -X github.com/opencord/voltha-go/common/version.goVersion=$(go version 2>&1 | sed -E  's/.*go([0-9]+\.[0-9]+\.[0-9]+).*/\1/g') \
+	 -X github.com/opencord/voltha-go/common/version.os=$(go env GOHOSTOS) \
+	 -X github.com/opencord/voltha-go/common/version.arch=$(go env GOHOSTARCH) \
+	 -X github.com/opencord/voltha-go/common/version.buildTime=$org_label_schema_build_date"
 
 # -------------
 # Image creation stage