Changes to the build system to use a base container for the
affinity router data and control planes.

Change-Id: Iea7f6ad72c1a9e9d1e90753c7b5f482e6c638f28
diff --git a/Makefile b/Makefile
index de5f790..3583c94 100644
--- a/Makefile
+++ b/Makefile
@@ -54,7 +54,7 @@
 	rw_core
 
 
-.PHONY: $(DIRS) $(DIRS_CLEAN) $(DIRS_FLAKE8) rw_core protos kafka db tests python simulators k8s afrouter arouterd
+.PHONY: $(DIRS) $(DIRS_CLEAN) $(DIRS_FLAKE8) rw_core protos kafka db tests python simulators k8s afrouter arouterd base
 
 # This should to be the first and default target in this Makefile
 help:
@@ -80,7 +80,10 @@
 
 build: containers
 
-containers: rw_core simulated_olt simulated_onu afrouter arouterd
+containers: base rw_core simulated_olt simulated_onu afrouter arouterd
+
+base:
+	docker build $(DOCKER_BUILD_ARGS) -t base:latest -f docker/Dockerfile.base .
 
 afrouter:
 	docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}arouter:${TAG} -f docker/Dockerfile.arouter .
diff --git a/docker/Dockerfile.arouter b/docker/Dockerfile.arouter
index be87905..b1769a1 100644
--- a/docker/Dockerfile.arouter
+++ b/docker/Dockerfile.arouter
@@ -1,35 +1,18 @@
 # -------------
 # Build stage
 
-FROM golang:1.10-alpine AS build-env
-
-
-# Install required packages
-RUN apk add --no-cache wget git make build-base protobuf protobuf-dev
-
-RUN git clone https://github.com/googleapis/googleapis.git /usr/local/include/googleapis
-
-# Prepare directory structure
-RUN ["mkdir", "-p", "/src", "src/protos"]
-RUN ["mkdir", "-p", "$GOPATH/src", "$GOPATH/pkg", "$GOPATH/bin"]
-RUN ["mkdir", "-p", "$GOPATH/src/github.com/opencord/voltha/protos/go"]
-
-# Install golang protobuf
-RUN go get github.com/golang/protobuf/protoc-gen-go
-RUN go get google.golang.org/genproto/googleapis/rpc/status
-RUN go get google.golang.org/grpc/binarylog/grpc_binarylog_v1
+FROM base AS build-env
 
 # Copy files
 ADD rw_core $GOPATH/src/github.com/opencord/voltha-go/rw_core
 ADD common $GOPATH/src/github.com/opencord/voltha-go/common
 ADD db $GOPATH/src/github.com/opencord/voltha-go/db
 ADD kafka $GOPATH/src/github.com/opencord/voltha-go/kafka
-ADD vendor $GOPATH/src/github.com/opencord/voltha-go/vendor
 ADD afrouter $GOPATH/src/github.com/opencord/voltha-go/afrouter
 
-
 # Copy required proto files
 # ... VOLTHA proos
+# Repeat here even if it's done in the base
 ADD protos/*.proto /src/protos/
 ADD protos/scripts/* /src/protos/
 ADD afrouter/arouter.json /src
@@ -38,21 +21,13 @@
 # Copy generated executables here
 WORKDIR $GOPATH/src/github.com/opencord/voltha-go
 
-#RUN ls -ltrR /go/src/github.com/opencord/voltha-go
-
-# Install golang protobuf
-#RUN go get github.com/golang/protobuf/protoc-gen-go
-#RUN go get google.golang.org/genproto/googleapis/rpc/status
-#RUN go get google.golang.org/grpc/binarylog/grpc_binarylog_v1
-RUN go install ./vendor/github.com/golang/protobuf/protoc-gen-go
-
 # Compile protobuf files
+# Repeat here even if it's done in the base
 RUN sh /src/protos/build_protos.sh /src/protos
 
 # Build rw_core
 RUN cd afrouter && go build -o /src/afrouter
 
-
 # -------------
 # Image creation stage
 
diff --git a/docker/Dockerfile.arouterd b/docker/Dockerfile.arouterd
index eba62e1..ad95713 100644
--- a/docker/Dockerfile.arouterd
+++ b/docker/Dockerfile.arouterd
@@ -1,40 +1,21 @@
 # -------------
 # Build stage
 
-FROM golang:1.10-alpine AS build-env
+FROM base AS build-env
 
 
-# Install required packages
-RUN apk add --no-cache wget git make build-base protobuf protobuf-dev curl
-
-RUN curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
-
-RUN git clone https://github.com/googleapis/googleapis.git /usr/local/include/googleapis
-
-# Prepare directory structure
-RUN ["mkdir", "-p", "/src", "src/protos"]
-RUN ["mkdir", "-p", "$GOPATH/src", "$GOPATH/pkg", "$GOPATH/bin"]
-RUN ["mkdir", "-p", "$GOPATH/src/github.com/opencord/voltha/protos/go"]
-
-# Install golang protobuf
-RUN go get github.com/golang/protobuf/protoc-gen-go
-RUN go get google.golang.org/genproto/googleapis/rpc/status
-RUN go get google.golang.org/grpc/binarylog/grpc_binarylog_v1
-
 # Copy files
 ADD rw_core $GOPATH/src/github.com/opencord/voltha-go/rw_core
 ADD common $GOPATH/src/github.com/opencord/voltha-go/common
 ADD db $GOPATH/src/github.com/opencord/voltha-go/db
 ADD kafka $GOPATH/src/github.com/opencord/voltha-go/kafka
-ADD vendor $GOPATH/src/github.com/opencord/voltha-go/vendor
 ADD afrouter $GOPATH/src/github.com/opencord/voltha-go/afrouter
 ADD arouterd $GOPATH/src/github.com/opencord/voltha-go/arouterd
-ADD Gopkg.lock $GOPATH/src/github.com/opencord/voltha-go
-ADD Gopkg.toml $GOPATH/src/github.com/opencord/voltha-go
 
 
 # Copy required proto files
 # ... VOLTHA proos
+# Repeate here even if done in base file
 ADD protos/*.proto /src/protos/
 ADD protos/scripts/* /src/protos/
 ADD afrouter/arouter.json /src
@@ -42,23 +23,14 @@
 #
 # Copy generated executables here
 WORKDIR $GOPATH/src/github.com/opencord/voltha-go
-#RUN $GOPATH/bin/dep ensure -add github.com/coreos/etcd
-
-#RUN ls -ltrR /go/src/github.com/opencord/voltha-go
-
-# Install golang protobuf
-#RUN go get github.com/golang/protobuf/protoc-gen-go
-#RUN go get google.golang.org/genproto/googleapis/rpc/status
-#RUN go get google.golang.org/grpc/binarylog/grpc_binarylog_v1
-RUN go install ./vendor/github.com/golang/protobuf/protoc-gen-go
 
 # Compile protobuf files
+# Repeate here even if done in base file
 RUN sh /src/protos/build_protos.sh /src/protos
 
 # Build rw_core
 RUN cd arouterd && go build -o /src/arouterd
 
-
 # -------------
 # Image creation stage
 
diff --git a/docker/Dockerfile.base b/docker/Dockerfile.base
new file mode 100644
index 0000000..0a37a23
--- /dev/null
+++ b/docker/Dockerfile.base
@@ -0,0 +1,74 @@
+# -------------
+# Build stage
+
+FROM golang:1.10-alpine
+
+
+# Install required packages
+RUN apk add --no-cache wget git make build-base protobuf protobuf-dev
+
+RUN git clone https://github.com/googleapis/googleapis.git /usr/local/include/googleapis
+
+# Prepare directory structure
+RUN ["mkdir", "-p", "/src", "src/protos"]
+RUN ["mkdir", "-p", "$GOPATH/src", "$GOPATH/pkg", "$GOPATH/bin"]
+RUN ["mkdir", "-p", "$GOPATH/src/github.com/opencord/voltha/protos/go"]
+
+# Install golang protobuf
+#RUN go get github.com/golang/protobuf/protoc-gen-go
+#RUN go get google.golang.org/genproto/googleapis/rpc/status
+#RUN go get google.golang.org/grpc/binarylog/grpc_binarylog_v1
+
+# Copy files
+#ADD rw_core $GOPATH/src/github.com/opencord/voltha-go/rw_core
+#ADD common $GOPATH/src/github.com/opencord/voltha-go/common
+#ADD db $GOPATH/src/github.com/opencord/voltha-go/db
+#ADD kafka $GOPATH/src/github.com/opencord/voltha-go/kafka
+ADD vendor $GOPATH/src/github.com/opencord/voltha-go/vendor
+#ADD afrouter $GOPATH/src/github.com/opencord/voltha-go/afrouter
+
+
+# Copy required proto files
+# ... VOLTHA proos
+ADD protos/*.proto /src/protos/
+ADD protos/scripts/* /src/protos/
+ADD afrouter/arouter.json /src
+
+#
+# Copy generated executables here
+WORKDIR $GOPATH/src/github.com/opencord/voltha-go
+
+#RUN ls -ltrR /go/src/github.com/opencord/voltha-go
+
+# Install golang protobuf
+#RUN go get github.com/golang/protobuf/protoc-gen-go
+#RUN go get google.golang.org/genproto/googleapis/rpc/status
+#RUN go get google.golang.org/grpc/binarylog/grpc_binarylog_v1
+RUN go install ./vendor/github.com/golang/protobuf/protoc-gen-go
+
+# Compile protobuf files
+RUN sh /src/protos/build_protos.sh /src/protos
+
+# Build rw_core
+#RUN cd afrouter && go build -o /src/afrouter
+
+
+# -------------
+# Image creation stage
+
+#FROM alpine:3.6
+
+# Set the working directory
+#WORKDIR /app
+
+# Copy required files
+#COPY --from=build-env /src/afrouter /app/
+#COPY --from=build-env /src/arouter.json /app/
+#COPY --from=build-env /src/protos/voltha.pb /app/
+#WORKDIR config
+#WORKDIR /app
+
+#CMD cd /app && ./arouter -config config/arouter.voltha2.json
+
+# Set the config volume
+