VOL-3383 - add build with race condition detection

Change-Id: I52211a49cc5d7328895a851b0d0184ce1756c91e
diff --git a/Makefile b/Makefile
index 667792d..a838c07 100644
--- a/Makefile
+++ b/Makefile
@@ -69,8 +69,6 @@
 	@echo "build                : Build the docker images."
 	@echo "                         - If this is the first time you are building, choose 'make build' option."
 	@echo "rw_core              : Build the rw_core docker image"
-	@echo "docker-build-profile : Build the rw_core_docker image with profiling enabled"
-	@echo "rw_core_profile      : Build the rw_core docker image with profiling enabled"
 	@echo "clean                : Remove files created by the build and tests"
 	@echo "distclean            : Remove sca directory and clean"
 	@echo "docker-push          : Push the docker images to an external repository"
@@ -100,19 +98,24 @@
 build: docker-build
 
 docker-build: rw_core
-docker-build-profile: rw_core_profile
 
 rw_core: local-protos local-lib-go
 	docker build $(DOCKER_BUILD_ARGS) -t ${RWCORE_IMAGENAME}:${DOCKER_TAG} -f docker/Dockerfile.rw_core .
 ifdef BUILD_PROFILED
 	docker build $(DOCKER_BUILD_ARGS) --build-arg EXTRA_GO_BUILD_TAGS="-tags profile" -t ${RWCORE_IMAGENAME}:${DOCKER_TAG}-profile -f docker/Dockerfile.rw_core .
 endif
+ifdef BUILD_RACE
+	docker build $(DOCKER_BUILD_ARGS) --build-arg GOLANG_IMAGE=golang:1.13.8-buster --build-arg DEPLOY_IMAGE=debian:buster-slim --build-arg EXTRA_GO_BUILD_TAGS="--race" -t ${RWCORE_IMAGENAME}:${DOCKER_TAG}-rd -f docker/Dockerfile.rw_core .
+endif
 
 docker-push:
 	docker push ${RWCORE_IMAGENAME}:${DOCKER_TAG}
 ifdef BUILD_PROFILED
 	docker push ${RWCORE_IMAGENAME}:${DOCKER_TAG}-profile
 endif
+ifdef BUILD_RACE
+	docker push ${RWCORE_IMAGENAME}:${DOCKER_TAG}-rd
+endif
 docker-kind-load:
 	@if [ "`kind get clusters | grep voltha-$(TYPE)`" = '' ]; then echo "no voltha-$(TYPE) cluster found" && exit 1; fi
 	kind load docker-image ${RWCORE_IMAGENAME}:${DOCKER_TAG} --name=voltha-$(TYPE) --nodes $(shell kubectl get nodes --template='{{range .items}}{{.metadata.name}},{{end}}' | rev | cut -c 2- | rev)
diff --git a/docker/Dockerfile.rw_core b/docker/Dockerfile.rw_core
index 1b159f7..2533f88 100644
--- a/docker/Dockerfile.rw_core
+++ b/docker/Dockerfile.rw_core
@@ -15,10 +15,13 @@
 # -------------
 # Build stage
 
-FROM golang:1.13.8-alpine3.11 AS build-env
+ARG GOLANG_IMAGE=golang:1.13.8-alpine3.11
+ARG DEPLOY_IMAGE=alpine:3.11.3
+# hadolint ignore=DL3006
+FROM $GOLANG_IMAGE AS build-env
 
 # Install required packages
-RUN apk add --no-cache build-base=0.5-r1
+RUN if command -v apk; then apk add --no-cache build-base=0.5-r1; fi
 
 # Use Standard go build directory structure
 WORKDIR /go/src
@@ -43,7 +46,10 @@
 
 # Build
 WORKDIR /go/src/rw_core
-SHELL ["/bin/ash", "-o", "pipefail", "-c"]
+# Need to ignore DL4006 as depending on the image being used different
+# shell may be used and there is no known way to parameterize the
+# Dockerfile SHELL command as build args did not seems to work
+# hadolint ignore=DL4006
 RUN go build $EXTRA_GO_BUILD_TAGS -mod=vendor -o /go/bin/rw_core \
 	-ldflags \
 	"-X github.com/opencord/voltha-lib-go/v3/pkg/version.version=$org_label_schema_version \
@@ -57,7 +63,8 @@
 # -------------
 # Image creation stage
 
-FROM alpine:3.11.3
+# hadolint ignore=DL3006
+FROM $DEPLOY_IMAGE
 
 # Set the working directory
 WORKDIR /app