[VOL-1920] Migrated voltha-go from dep to go mod for dependency management
Change-Id: Ie14418cef7ba046a7c43a343b9017c436af6b395
diff --git a/docker/Dockerfile.ro_core b/docker/Dockerfile.ro_core
index 511e913..a0fdf1a 100644
--- a/docker/Dockerfile.ro_core
+++ b/docker/Dockerfile.ro_core
@@ -26,13 +26,13 @@
protobuf=3.6.1-r1 \
protobuf-dev=3.6.1-r1
-# Prepare directory structure
-RUN mkdir -p /build \
- "$GOPATH/src/" "$GOPATH/pkg" "$GOPATH/bin" \
- "$GOPATH/src/github.com/opencord" \
- "$GOPATH/src/github.com/opencord/voltha-go"
+# Golang container has GOPATH set to /go by default. Hence, need to explicitly enable
+# Go modules while using folder /go/src under GOPATH as build path; lest go modules
+# will be disabled
+ENV GO111MODULE=on
-WORKDIR $GOPATH/src/github.com/opencord/voltha-go
+# Use Standard go build directory structure
+WORKDIR /go/src
# Copy common files.
COPY common ./common
@@ -42,6 +42,8 @@
# Copy files.
COPY ro_core ./ro_core
+COPY go.mod ./
+COPY go.sum ./
ARG org_label_schema_version=unknown
ARG org_label_schema_vcs_url=unknown
@@ -51,9 +53,9 @@
ARG org_opencord_vcs_dirty=unknown
# Build
-WORKDIR $GOPATH/src/github.com/opencord/voltha-go/ro_core
+WORKDIR /go/src/ro_core
SHELL ["/bin/ash", "-o", "pipefail", "-c"]
-RUN go build -o /build/ro_core \
+RUN go build -mod=vendor -o /go/bin/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 \
@@ -72,7 +74,7 @@
WORKDIR /app
# Copy required files
-COPY --from=build-env /build/ro_core /app/
+COPY --from=build-env /go/bin/ro_core /app/
# Label image
ARG org_label_schema_version=unknown