Inject and report version info
Build system injects version and environment
information similar to voltha-go builds.
Reports version via command line arg or via
"adapters" api call.
Change-Id: Ib21de7faac0d36c86a80c6d2f574c6e052b96459
diff --git a/docker/Dockerfile.openolt b/docker/Dockerfile.openolt
index a0a2554..d7cc1dc 100644
--- a/docker/Dockerfile.openolt
+++ b/docker/Dockerfile.openolt
@@ -33,8 +33,24 @@
COPY vendor ./vendor
COPY *.go ./
+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
+
# Build openolt
-RUN go build -o /build/openolt
+SHELL ["/bin/ash", "-o", "pipefail", "-c"]
+RUN go build -o /build/openolt \
+ -ldflags \
+ "-X github.com/opencord/voltha-openolt-adapter/vendor/github.com/opencord/voltha-go/common/version.version=$org_label_schema_version \
+ -X github.com/opencord/voltha-openolt-adapter/vendor/github.com/opencord/voltha-go/common/version.vcsRef=$org_label_schema_vcs_ref \
+ -X github.com/opencord/voltha-openolt-adapter/vendor/github.com/opencord/voltha-go/common/version.vcsDirty=$org_opencord_vcs_dirty \
+ -X github.com/opencord/voltha-openolt-adapter/vendor/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-openolt-adapter/vendor/github.com/opencord/voltha-go/common/version.os=$(go env GOHOSTOS) \
+ -X github.com/opencord/voltha-openolt-adapter/vendor/github.com/opencord/voltha-go/common/version.arch=$(go env GOHOSTARCH) \
+ -X github.com/opencord/voltha-openolt-adapter/vendor/github.com/opencord/voltha-go/common/version.buildTime=$org_label_schema_build_date"
# -------------
# Image creation stage
@@ -53,6 +69,7 @@
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
LABEL org.label-schema.schema-version=1.0 \
org.label-schema.name=voltha-openolt-adapter-go \
@@ -60,4 +77,5 @@
org.label-schema.vcs-url=$org_label_schema_vcs_url \
org.label-schema.vcs-ref=$org_label_schema_vcs_ref \
org.label-schema.build-date=$org_label_schema_build_date \
- org.opencord.vcs-commit-date=$org_opencord_vcs_commit_date
+ org.opencord.vcs-commit-date=$org_opencord_vcs_commit_date \
+ org.opencord.vcs-dirty=$org_opencord_vcs_dirty