VOL-1500 VOL-1475 Updated the remaining python containers in voltha-go to use pyvoltha and voltha-protos
Changed the build system to have separate flags for local pyvoltha and local protos.
Cleared out now unneeded python libraries and protos from voltha-go
PonSim was tested by launching the system-test-ponsim.yml and making sure the ponsim enables.
This was tested on docker-compose and k8s.
Let me know if there are other cases to test.
Change-Id: Ie2d5a19900fcfc93b96aba2981efb18fd9e649bb
diff --git a/python/docker/Dockerfile.adapter_openolt b/python/docker/Dockerfile.adapter_openolt
deleted file mode 100644
index 4b814bd..0000000
--- a/python/docker/Dockerfile.adapter_openolt
+++ /dev/null
@@ -1,42 +0,0 @@
-# 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 Voltha Community <info@opennetworking.org>
-
-# Bundle app source
-RUN mkdir /voltha && touch /voltha/__init__.py
-ENV PYTHONPATH=/voltha
-COPY common /voltha/python/common/
-COPY adapters/common /voltha/python/adapters/common/
-COPY adapters/kafka /voltha/python/adapters/kafka
-COPY adapters/*.py /voltha/python/adapters/
-COPY adapters/openolt /voltha/python/adapters/openolt
-RUN touch /voltha/python/__init__.py
-RUN touch /voltha/python/adapters/__init__.py
-
-# Copy in the generated GRPC proto code
-COPY --from=protos /protos/voltha /voltha/python/protos
-COPY --from=protos /protos/google/api /voltha/python/protos/third_party/google/api
-COPY protos/third_party/__init__.py /voltha/python/protos/third_party
-RUN touch /voltha/python/protos/__init__.py
-RUN touch /voltha/python/protos/third_party/google/__init__.py
-
-# Exposing process and default entry point
-# CMD ["python", "/voltha/python/adapters/openolt/main.py"]
diff --git a/python/docker/Dockerfile.adapter_ponsim_olt b/python/docker/Dockerfile.adapter_ponsim_olt
index 0c869de..2d6c033 100644
--- a/python/docker/Dockerfile.adapter_ponsim_olt
+++ b/python/docker/Dockerfile.adapter_ponsim_olt
@@ -15,7 +15,6 @@
ARG REGISTRY=
ARG REPOSITORY=
-FROM ${REGISTRY}${REPOSITORY}voltha-protos:${TAG} as protos
FROM ${REGISTRY}${REPOSITORY}voltha-base:${TAG}
MAINTAINER Voltha Community <info@opennetworking.org>
@@ -23,20 +22,9 @@
# Bundle app source
RUN mkdir /voltha && touch /voltha/__init__.py
ENV PYTHONPATH=/voltha
-COPY common /voltha/python/common/
-COPY adapters/common /voltha/python/adapters/common/
-COPY adapters/kafka /voltha/python/adapters/kafka
-COPY adapters/*.py /voltha/python/adapters/
COPY adapters/ponsim_olt /voltha/python/adapters/ponsim_olt
RUN touch /voltha/python/__init__.py
RUN touch /voltha/python/adapters/__init__.py
-# Copy in the generated GRPC proto code
-COPY --from=protos /protos/voltha /voltha/python/protos
-COPY --from=protos /protos/google/api /voltha/python/protos/third_party/google/api
-COPY protos/third_party/__init__.py /voltha/python/protos/third_party
-RUN touch /voltha/python/protos/__init__.py
-RUN touch /voltha/python/protos/third_party/google/__init__.py
-
# Exposing process and default entry point
-# CMD ["python", "/voltha/python/adapters/ponsim_olt/main.py"]
+CMD ["python", "/voltha/python/adapters/ponsim_olt/main.py"]
diff --git a/python/docker/Dockerfile.adapter_ponsim_onu b/python/docker/Dockerfile.adapter_ponsim_onu
index c8d19f8..e34483e 100644
--- a/python/docker/Dockerfile.adapter_ponsim_onu
+++ b/python/docker/Dockerfile.adapter_ponsim_onu
@@ -15,7 +15,6 @@
ARG REGISTRY=
ARG REPOSITORY=
-FROM ${REGISTRY}${REPOSITORY}voltha-protos:${TAG} as protos
FROM ${REGISTRY}${REPOSITORY}voltha-base:${TAG}
MAINTAINER Voltha Community <info@opennetworking.org>
@@ -23,20 +22,9 @@
# Bundle app source
RUN mkdir /voltha && touch /voltha/__init__.py
ENV PYTHONPATH=/voltha
-COPY common /voltha/python/common/
-COPY adapters/common /voltha/python/adapters/common/
-COPY adapters/kafka /voltha/python/adapters/kafka
-COPY adapters/*.py /voltha/python/adapters/
COPY adapters/ponsim_onu /voltha/python/adapters/ponsim_onu
RUN touch /voltha/python/__init__.py
RUN touch /voltha/python/adapters/__init__.py
-# Copy in the generated GRPC proto code
-COPY --from=protos /protos/voltha /voltha/python/protos
-COPY --from=protos /protos/google/api /voltha/python/protos/third_party/google/api
-COPY protos/third_party/__init__.py /voltha/python/protos/third_party
-RUN touch /voltha/python/protos/__init__.py
-RUN touch /voltha/python/protos/third_party/google/__init__.py
-
# Exposing process and default entry point
-# CMD ["python", "/voltha/python/adapters/ponsim_onu/main.py"]
+CMD ["python", "/voltha/python/adapters/ponsim_onu/main.py"]
diff --git a/python/docker/Dockerfile.base b/python/docker/Dockerfile.base
index 1b912e0..70f4c3f 100644
--- a/python/docker/Dockerfile.base
+++ b/python/docker/Dockerfile.base
@@ -16,6 +16,9 @@
MAINTAINER Voltha Community <info@opennetworking.org>
+ARG LOCAL_PYVOLTHA
+ARG LOCAL_PROTOS
+
# Update to have latest images
RUN apt-get update && \
apt-get install -y python python-pip openssl iproute2 libpcap-dev wget
@@ -29,6 +32,20 @@
rm -f *.deb && \
apt-get update && \
apt-get install -y wget build-essential make gcc binutils python-dev libffi-dev libssl-dev git && \
- pip install -r /tmp/requirements.txt && \
- apt-get purge -y wget build-essential make gcc binutils python-dev libffi-dev libssl-dev git && \
+ pip install -r /tmp/requirements.txt
+
+#COPY POTENTIAL LOCAL IMPORTS
+COPY local_imports/ /local_imports/
+
+RUN if [ -n "$LOCAL_PYVOLTHA" ] ; then \
+ pip install /local_imports/pyvoltha/dist/*.tar.gz ; \
+fi
+
+RUN if [ -n "$LOCAL_PROTOS" ] ; then \
+ pip install /local_imports/voltha-protos/dist/*.tar.gz ; \
+fi
+
+RUN apt-get purge -y wget build-essential make gcc binutils python-dev libffi-dev libssl-dev git && \
apt-get autoremove -y
+
+
diff --git a/python/docker/Dockerfile.base_local b/python/docker/Dockerfile.base_local
deleted file mode 100644
index b71627b..0000000
--- a/python/docker/Dockerfile.base_local
+++ /dev/null
@@ -1,43 +0,0 @@
-# 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.
-
-FROM ubuntu:xenial
-
-MAINTAINER Voltha Community <info@opennetworking.org>
-
-# Update to have latest images
-RUN apt-get update && \
- apt-get install -y python python-pip openssl iproute2 libpcap-dev wget
-
-COPY requirements.txt /tmp/requirements.txt
-
-# pip install cython enum34 six && \
-# Install app dependencies
-RUN wget https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \
- dpkg -i *.deb && \
- rm -f *.deb && \
- apt-get update && \
- apt-get install -y wget build-essential make gcc binutils python-dev libffi-dev libssl-dev git && \
- pip install -r /tmp/requirements.txt
-
-# Install local pyvoltha
-COPY pyvoltha/dist /pyvoltha/dist
-RUN pip install /pyvoltha/dist/*.tar.gz
-
-# Install local voltha-protos
-COPY voltha-protos/dist /voltha-protos/dist
-RUN pip install /voltha-protos/dist/*.tar.gz
-
-RUN apt-get purge -y wget build-essential make gcc binutils python-dev libffi-dev libssl-dev git && \
- apt-get autoremove -y
diff --git a/python/docker/Dockerfile.cli b/python/docker/Dockerfile.cli
index 4e2d925..42a3c65 100644
--- a/python/docker/Dockerfile.cli
+++ b/python/docker/Dockerfile.cli
@@ -15,7 +15,6 @@
ARG REGISTRY=
ARG REPOSITORY=
-FROM ${REGISTRY}${REPOSITORY}voltha-protos:${TAG} as protos
FROM ${REGISTRY}${REPOSITORY}voltha-base:${TAG}
MAINTAINER Voltha Community <info@opennetworking.org>
diff --git a/python/docker/Dockerfile.ofagent b/python/docker/Dockerfile.ofagent
index dee28ed..564da05 100644
--- a/python/docker/Dockerfile.ofagent
+++ b/python/docker/Dockerfile.ofagent
@@ -15,35 +15,17 @@
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 -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
+RUN mkdir /ofagent && \
+ touch /ofagent/__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", "--"]
diff --git a/python/docker/Dockerfile.protoc b/python/docker/Dockerfile.protoc
deleted file mode 100644
index eef6f54..0000000
--- a/python/docker/Dockerfile.protoc
+++ /dev/null
@@ -1,39 +0,0 @@
-# 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 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/python/docker/Dockerfile.protos b/python/docker/Dockerfile.protos
deleted file mode 100644
index db70d13..0000000
--- a/python/docker/Dockerfile.protos
+++ /dev/null
@@ -1,36 +0,0 @@
-# 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 protos/third_party/google/api/*.proto /protos/google/api/
-COPY docker/config/Makefile.protos /protos/google/api/Makefile.protos
-COPY protos/*.proto /protos/voltha/
-COPY docker/config/Makefile.protos /protos/voltha/Makefile.protos
-
-WORKDIR /protos
-RUN make -f google/api/Makefile.protos google_api
-RUN touch /protos/google/__init__.py /protos/google/api/__init__.py
-
-WORKDIR /protos/voltha
-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/python/docker/config/Makefile.protos b/python/docker/config/Makefile.protos
deleted file mode 100644
index 12ff9e3..0000000
--- a/python/docker/config/Makefile.protos
+++ /dev/null
@@ -1,59 +0,0 @@
-#
-# 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)