VOL-617 - ability to build without VM

Change-Id: Iec79d66b7ab98a5421eabe7819fa6325ff6690ce
diff --git a/docker/Dockerfile.cli_d b/docker/Dockerfile.cli_d
new file mode 100755
index 0000000..80db472
--- /dev/null
+++ b/docker/Dockerfile.cli_d
@@ -0,0 +1,53 @@
+# Copyright 2016 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+ARG TAG=latest
+ARG REGISTRY=
+ARG REPOSITORY=
+
+FROM ${REGISTRY}${REPOSITORY}voltha-protos:${TAG} as protos
+FROM ${REGISTRY}${REPOSITORY}voltha-base:${TAG}
+
+MAINTAINER Sergio Slobodrian <sslobodr@ciena.com>
+
+# Bundle app source
+RUN mkdir /cli && touch /cli/__init__.py
+ENV PYTHONPATH=/cli
+COPY common /cli/common
+COPY cli /cli/cli
+COPY voltha /cli/voltha
+COPY --from=protos /protos/voltha /cli/voltha/protos
+COPY --from=protos /protos/google/api /cli/voltha/protos/third_party/google/api
+COPY --from=protos /protos/asfvolt16_olt /cli/voltha/adapters/asfvolt16_olt/protos
+RUN useradd -b /home -d /home/voltha voltha -s /bin/bash
+RUN mkdir /home/voltha
+RUN chown voltha.voltha /home/voltha
+RUN echo "voltha:admin" | chpasswd
+RUN apt-get update && apt-get install -y openssh-server
+RUN apt-get update && apt-get install -y openssh-server
+RUN mkdir /var/run/sshd
+RUN echo 'root:screencast' | chpasswd
+RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
+
+# SSH login fix. Otherwise user is kicked off after login
+RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
+
+ENV NOTVISIBLE "in users profile"
+RUN echo "export VISIBLE=now" >> /etc/profile
+
+EXPOSE 22
+
+# Exposing process and default entry point
+ENTRYPOINT ["/usr/bin/dumb-init", "--"]
+
+CMD ["/cli/cli/setup.sh"]
diff --git a/docker/Dockerfile.envoy_d b/docker/Dockerfile.envoy_d
new file mode 100644
index 0000000..57843bf
--- /dev/null
+++ b/docker/Dockerfile.envoy_d
@@ -0,0 +1,43 @@
+# Copyright 2018 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+ARG REGISTRY=
+ARG REPOSITORY=
+ARG TAG=latest
+ARG HTTP_PROXY=
+ARG HTTPS_PROXY=
+
+FROM grpc/python as protos
+COPY voltha/protos/*.proto /voltha/protos/
+COPY voltha/protos/third_party/google/api/*.proto /voltha/protos/third_party/google/api/
+#RUN protoc -I/voltha/protos -I/voltha/protos/third_party --include_imports --include_source_info --descriptor_set_out=/proto.pb /voltha/protos/*.proto
+RUN python -m grpc.tools.protoc -I/voltha/protos -I/voltha/protos/third_party --include_imports --include_source_info --descriptor_set_out=/proto.pb /voltha/protos/*.proto
+
+FROM ${REGISTRY}${REPOSITORY}voltha-go-builder:${TAG} as build
+ENV http_proxy ${HTTP_PROXY}
+ENV https_proxy ${HTTPS_PROXY}
+
+COPY envoy/go/envoyd/*.go /src/
+RUN mkdir /output
+RUN OUTPUT=/ /build.sh
+RUN ls /output
+
+FROM lyft/envoy:29361deae91575a1d46c7a21e913f19e75622ebe
+
+RUN apt-get update && apt-get -q install -y curl
+COPY envoy/front-proxy /envoy
+COPY --from=protos /proto.pb /envoy/
+COPY pki /envoy/
+COPY --from=build /envoyd /usr/local/bin/envoyd
+
+CMD /usr/local/bin/envoy -c /envoy/front-proxy/voltha-grpc-proxy.json
diff --git a/docker/Dockerfile.netconf_d b/docker/Dockerfile.netconf_d
new file mode 100644
index 0000000..56e1c7a
--- /dev/null
+++ b/docker/Dockerfile.netconf_d
@@ -0,0 +1,45 @@
+# Copyright 2018 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+ARG TAG=latest
+ARG REGISTRY=
+ARG REPOSITORY=
+FROM ${REGISTRY}${REPOSITORY}voltha-protos:${TAG} as protos
+FROM ${REGISTRY}${REPOSITORY}voltha-base:${TAG}
+
+MAINTAINER Voltha Community <info@opennetworking.org>
+
+# Install protoc version 3.0.0; this is not yet the supported
+# version on xenial, so we need to "backport" it
+RUN apt-get update && \
+    apt-get install -y zlib1g-dev wget && \
+    wget http://ftp.us.debian.org/debian/pool/main/p/protobuf/libprotoc10_3.0.0-9_amd64.deb && \
+    wget http://ftp.us.debian.org/debian/pool/main/p/protobuf/libprotobuf-lite10_3.0.0-9_amd64.deb && \
+    wget http://ftp.us.debian.org/debian/pool/main/p/protobuf/libprotobuf-dev_3.0.0-9_amd64.deb && \
+    wget http://ftp.us.debian.org/debian/pool/main/p/protobuf/libprotobuf10_3.0.0-9_amd64.deb && \
+    wget http://ftp.us.debian.org/debian/pool/main/p/protobuf/protobuf-compiler_3.0.0-9_amd64.deb && \
+    dpkg -i *.deb && \
+    protoc --version && \
+    rm -f *.deb
+
+# Bundle app source
+RUN mkdir /netconf && touch /netconf/__init__.py
+ENV PYTHONPATH=/netconf
+COPY common /netconf/common
+COPY netconf /netconf/netconf
+COPY --from=protos /protos/voltha /netconf/netconf/protos
+COPY --from=protos /protos/google/api /netconf/netconf/protos/third_party/google/api
+COPY --from=protos /protos/voltha/yang_options* /netconf/netconf/protoc_plugins/
+
+# Exposing process and default entry point
+CMD ["python", "netconf/netconf/main.py"]
diff --git a/docker/Dockerfile.ofagent_d b/docker/Dockerfile.ofagent_d
new file mode 100644
index 0000000..6c9fa86
--- /dev/null
+++ b/docker/Dockerfile.ofagent_d
@@ -0,0 +1,53 @@
+# Copyright 2016 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+ARG TAG=latest
+ARG REGISTRY=
+ARG REPOSITORY=
+
+FROM ${REGISTRY}${REPOSITORY}voltha-protos:${TAG} as protos
+FROM ${REGISTRY}${REPOSITORY}voltha-base:${TAG}
+
+MAINTAINER Zsolt Haraszti <zharaszt@ciena.com>
+MAINTAINER Ali Al-Shabibi <ali.al-shabibi@onlab.us>
+MAINTAINER Nathan Knuth   <nathan.knuth@tibitcom.com>
+
+# Install protoc version 3.0.0; this is not yet the supported
+# version on xenial, so we need to "backport" it
+RUN apt-get update && \
+    apt-get install -y zlib1g-dev wget && \
+    wget http://ftp.us.debian.org/debian/pool/main/p/protobuf/libprotoc10_3.0.0-9_amd64.deb && \
+    wget http://ftp.us.debian.org/debian/pool/main/p/protobuf/libprotobuf-lite10_3.0.0-9_amd64.deb && \
+    wget http://ftp.us.debian.org/debian/pool/main/p/protobuf/libprotobuf-dev_3.0.0-9_amd64.deb && \
+    wget http://ftp.us.debian.org/debian/pool/main/p/protobuf/libprotobuf10_3.0.0-9_amd64.deb && \
+    wget http://ftp.us.debian.org/debian/pool/main/p/protobuf/protobuf-compiler_3.0.0-9_amd64.deb && \
+    dpkg -i *.deb && \
+    protoc --version && \
+    rm -f *.deb
+
+# Bundle app source
+RUN mkdir -p /ofagent/ofagent/protos/third_party/google/api  && \
+	touch	/ofagent/__init__.py \
+		/ofagent/ofagent/protos/third_party/google/__init__.py \
+		/ofagent/ofagent/protos/third_party/google/api/__init__.py
+ENV PYTHONPATH=/ofagent
+COPY common /ofagent/common
+COPY ofagent /ofagent/ofagent
+COPY pki /ofagent/pki
+COPY --from=protos /protos/voltha /ofagent/ofagent/protos
+COPY --from=protos /protos/google/api /ofagent/ofagent/protos/third_party/google/api
+
+ENTRYPOINT ["/usr/bin/dumb-init", "--"]
+
+# Exposing process and default entry point
+CMD ["dumb-init", "python", "ofagent/ofagent/main.py"]
diff --git a/docker/Dockerfile.portainer_d b/docker/Dockerfile.portainer_d
new file mode 100644
index 0000000..ec69bfa
--- /dev/null
+++ b/docker/Dockerfile.portainer_d
@@ -0,0 +1,49 @@
+# Copyright 2018 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+FROM ${REGISTRY}portainer/portainer:1.15.2 as base
+
+FROM ${REGISTRY}alpine:3.6 as work
+COPY --from=base / /work
+RUN find /work  -print
+
+RUN sed -i \
+-e 's~constant("DOCKER_ENDPOINT","api/docker")~constant("DOCKER_ENDPOINT","docker/api/docker")~' \
+-e 's~constant("CONFIG_ENDPOINT","api/settings")~constant("CONFIG_ENDPOINT","docker/api/settings")~' \
+-e 's~constant("AUTH_ENDPOINT","api/auth")~constant("AUTH_ENDPOINT","docker/api/auth")~' \
+-e 's~constant("USERS_ENDPOINT","api/users")~constant("USERS_ENDPOINT","docker/api/users")~' \
+-e 's~constant("ENDPOINTS_ENDPOINT","api/endpoints")~constant("ENDPOINTS_ENDPOINT","docker/api/endpoints")~' \
+-e 's~constant("TEMPLATES_ENDPOINT","api/templates")~constant("TEMPLATES_ENDPOINT","docker/api/templates")~' \
+/work/public/js/app.*.js
+
+RUN sed -i \
+-e 's~href="~href="docker/~' \
+-e 's~href='\''~href='\''docker/~' \
+-e 's~src="~src="docker/~' \
+-e 's~src='\''~src='\''docker/~' \
+-e 's~"images/logo.png"~"docker/images/logo.png"~' \
+/work/public/index.html
+
+FROM centurylink/ca-certs
+MAINTAINER Voltha Community <info@opennetworking.org>
+
+COPY --from=work /work /
+
+VOLUME /data
+
+WORKDIR /
+
+EXPOSE 9000
+
+ENTRYPOINT ["/portainer"]
diff --git a/docker/Dockerfile.protoc b/docker/Dockerfile.protoc
new file mode 100644
index 0000000..f9cd10f
--- /dev/null
+++ b/docker/Dockerfile.protoc
@@ -0,0 +1,39 @@
+# Copyright 2018 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+ARG REGISTRY=
+ARG PROTOC_PREFIX=/usr/local
+ARG ROTOC_LIBDIR=${PROTOC_PREFIX}/lib
+ARG PROTOC=${PROTOC_PREFIX}/bin/protoc
+ARG PROTOC_VERSION=3.3.0
+
+FROM ${REGISTRY}debian:stretch-slim
+MAINTAINER Voltha Community <info@opennetworking.org>
+
+ENV PROTOC_PREFIX=/usr/local
+ENV ROTOC_LIBDIR=${PROTOC_PREFIX}/lib
+ENV PROTOC=${PROTOC_PREFIX}/bin/protoc
+ENV PROTOC_VERSION=3.3.0
+ENV PROTOC_DOWNLOAD_PREFIX=https://github.com/google/protobuf/releases/download
+ENV PROTOC_DIR=protobuf-${PROTOC_VERSION}
+ENV PROTOC_TARBALL=protobuf-python-${PROTOC_VERSION}.tar.gz
+ENV PROTOC_DOWNLOAD_URI=${PROTOC_DOWNLOAD_PREFIX}/v${PROTOC_VERSION}/${PROTOC_TARBALL}
+
+RUN apt-get update -y && apt-get install -y wget build-essential python-dev python-pip
+RUN pip install --upgrade pip && pip install grpcio-tools==1.3.5
+WORKDIR /build
+RUN wget -q --no-check-certificate ${PROTOC_DOWNLOAD_URI}
+RUN tar --strip-components=1 -zxf ${PROTOC_TARBALL}
+RUN ./configure --prefix=${PROTOC_PREFIX}
+RUN make install
diff --git a/docker/Dockerfile.protos b/docker/Dockerfile.protos
new file mode 100644
index 0000000..745e166
--- /dev/null
+++ b/docker/Dockerfile.protos
@@ -0,0 +1,40 @@
+# Copyright 2018 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+ARG REGISTRY=
+ARG REPOSITORY=
+ARG TAG=latest
+
+FROM ${REGISTRY}${REPOSITORY}voltha-protoc:${TAG} as builder
+MAINTAINER Voltha Community <info@opennetworking.org>
+
+COPY voltha/protos/third_party/google/api/*.proto /protos/google/api/
+COPY docker/config/Makefile.protos /protos/google/api/Makefile.protos
+WORKDIR /protos
+RUN make -f google/api/Makefile.protos google_api
+RUN touch /protos/google/__init__.py /protos/google/api/__init__.py
+
+COPY voltha/protos/*.proto /protos/voltha/
+COPY docker/config/Makefile.protos /protos/voltha/Makefile.protos
+WORKDIR /protos/voltha
+RUN make -f Makefile.protos build
+
+COPY voltha/adapters/asfvolt16_olt/protos/*.proto /protos/asfvolt16_olt/
+COPY docker/config/Makefile.protos /protos/asfvolt16_olt/Makefile.protos
+WORKDIR /protos/asfvolt16_olt
+RUN make -f Makefile.protos build
+
+# Copy the files to a scrach based container to minimize its size
+FROM ${REGISTRY}scratch
+COPY --from=builder /protos/ /protos/
diff --git a/docker/Dockerfile.test_runner b/docker/Dockerfile.test_runner
new file mode 100644
index 0000000..72ea3d2
--- /dev/null
+++ b/docker/Dockerfile.test_runner
@@ -0,0 +1,37 @@
+# Copyright 2018 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+ARG TAG=latest
+ARG REGISTRY=
+ARG REPOSITORY=
+
+FROM ${REGISTRY}${REPOSITORY}voltha-protos:${TAG} as protos
+FROM ${REGISTRY}${REPOSITORY}voltha-base:${TAG}
+MAINTAINER Voltha Community <info@opennetworking.org>
+
+RUN apt-get update -y && apt-get install -y curl jq kafkacat make
+RUN curl -sSL get.docker.io | CHANNEL=stable bash
+RUN apt-get install -y docker-compose
+
+COPY ./ /work/
+WORKDIR /work
+
+# Copy in the generated GRPC proto code
+COPY --from=protos /protos/voltha /work/voltha/protos
+COPY --from=protos /protos/google/api /work/voltha/protos/third_party/google/api
+
+COPY --from=protos /protos/asfvolt16_olt /work/voltha/adapters/asfvolt16_olt/protos
+
+COPY --from=protos /protos/voltha /work/ofagent/protos
+COPY --from=protos /protos/google/api /work/ofagent/protos/third_party/google/api
diff --git a/docker/Dockerfile.voltha_d b/docker/Dockerfile.voltha_d
new file mode 100644
index 0000000..0032232
--- /dev/null
+++ b/docker/Dockerfile.voltha_d
@@ -0,0 +1,37 @@
+# Copyright 2018 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+ARG TAG=latest
+ARG REGISTRY=
+ARG REPOSITORY=
+
+FROM ${REGISTRY}${REPOSITORY}voltha-protos:${TAG} as protos
+FROM ${REGISTRY}${REPOSITORY}voltha-base:${TAG}
+MAINTAINER Voltha Community <info@opennetworking.org>
+
+# Bundle app source
+RUN mkdir /voltha && touch /voltha/__init__.py
+ENV PYTHONPATH=/voltha
+COPY common /voltha/common
+COPY voltha /voltha/voltha
+COPY pki /voltha/pki
+
+# Copy in the generated GRPC proto code
+COPY --from=protos /protos/voltha /voltha/voltha/protos
+COPY --from=protos /protos/google/api /voltha/voltha/protos/third_party/google/api
+COPY --from=protos /protos/asfvolt16_olt /voltha/voltha/adapters/asfvolt16_olt/protos
+
+# Exposing process and default entry point
+# EXPOSE 8000
+CMD ["python", "voltha/voltha/main.py"]
diff --git a/docker/config/Makefile.protos b/docker/config/Makefile.protos
new file mode 100644
index 0000000..12ff9e3
--- /dev/null
+++ b/docker/config/Makefile.protos
@@ -0,0 +1,59 @@
+#
+# Copyright 2017 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Makefile to build all protobuf and gRPC related artifacts
+
+default: build
+
+PROTO_FILES := $(wildcard *.proto)
+PROTO_ALL_FILES := $(PROTO_FILES) $(PROTO_GOOGLE_API)
+PROTO_PB2_FILES := $(foreach f,$(PROTO_FILES),$(subst .proto,_pb2.py,$(f)))
+PROTO_PB2_GOOGLE_API := $(foreach f,$(PROTO_GOOGLE_API),$(subst .proto,_pb2.py,$(f)))
+PROTO_All_PB2_C_FILES := $(foreach f,$(PROTO_ALL_FILES),$(subst .proto,_pb2.pyc,$(f)))
+PROTO_ALL_PB2_GPRC_FILES := $(foreach f,$(PROTO_ALL_FILES),$(subst .proto,_pb2_grpc.py,$(f)))
+PROTO_ALL_DESC_FILES := $(foreach f,$(PROTO_ALL_FILES),$(subst .proto,.desc,$(f)))
+
+# Google API needs to be built from within the third party directory
+#
+google_api:
+	python -m grpc.tools.protoc \
+	    -I. \
+            --python_out=. \
+            --grpc_python_out=. \
+            --descriptor_set_out=google/api/annotations.desc \
+            --include_imports \
+            --include_source_info \
+        google/api/annotations.proto google/api/http.proto
+
+build: $(PROTO_PB2_FILES)
+
+%_pb2.py: %.proto
+	python -m grpc.tools.protoc \
+                -I. \
+                -I/protos \
+                --python_out=. \
+                --grpc_python_out=. \
+                --descriptor_set_out=$(basename $<).desc \
+                --include_imports \
+                --include_source_info \
+                $<
+
+clean:
+	rm -f $(PROTO_PB2_FILES) \
+		$(PROTO_ALL_DESC_FILES) \
+		$(PROTO_ALL_PB2_GPRC_FILES) \
+		$(PROTO_All_PB2_C_FILES) \
+		$(PROTO_PB2_GOOGLE_API)