VOL-1449 Create docker images including pyvoltha
Creates a base and pyvoltha docker image with installed
using a newer version of pip. Also include the README.md
file as pip install needed it inside the docker build.
Change-Id: I5450de4a855ed40f2eb611c55726dfcba720f41f
diff --git a/MANIFEST.in b/MANIFEST.in
index c0f8fc5..4d08bc6 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,2 +1,2 @@
-include requirements.txt license.txt VERSION
-recursive-include pyvoltha *.proto
\ No newline at end of file
+include requirements.txt license.txt VERSION README.md
+recursive-include pyvoltha *.proto
diff --git a/Makefile b/Makefile
index cb917b6..dfed663 100644
--- a/Makefile
+++ b/Makefile
@@ -13,27 +13,63 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+
+ifeq ($(TAG),)
+TAG := latest
+endif
+
+ifeq ($(TARGET_TAG),)
+TARGET_TAG := latest
+endif
+
+ifneq ($(http_proxy)$(https_proxy),)
+# Include proxies from the environment
+DOCKER_PROXY_ARGS = \
+ --build-arg http_proxy=$(http_proxy) \
+ --build-arg https_proxy=$(https_proxy) \
+ --build-arg ftp_proxy=$(ftp_proxy) \
+ --build-arg no_proxy=$(no_proxy) \
+ --build-arg HTTP_PROXY=$(HTTP_PROXY) \
+ --build-arg HTTPS_PROXY=$(HTTPS_PROXY) \
+ --build-arg FTP_PROXY=$(FTP_PROXY) \
+ --build-arg NO_PROXY=$(NO_PROXY)
+endif
+
+DOCKER_BUILD_ARGS = \
+ --build-arg TAG=$(TAG) \
+ --build-arg REGISTRY=$(REGISTRY) \
+ --build-arg REPOSITORY=$(REPOSITORY) \
+ $(DOCKER_PROXY_ARGS) $(DOCKER_CACHE_ARG) \
+ --rm --force-rm \
+ $(DOCKER_BUILD_EXTRA_ARGS)
+
+DOCKER_IMAGE_LIST = \
+ pyvoltha-base \
+ pyvoltha
+
VENVDIR := venv-$(shell uname -s | tr '[:upper:]' '[:lower:]')
VENV_BIN ?= virtualenv
VENV_OPTS ?=
-.PHONY: $(DIRS) $(DIRS_CLEAN) $(DIRS_FLAKE8) flake8 protos venv rebuild-venv clean distclean build test
+.PHONY: $(DIRS) $(DIRS_CLEAN) $(DIRS_FLAKE8) flake8 protos venv rebuild-venv clean distclean build test docker_base_img docker_image
# This should to be the first and default target in this Makefile
help:
@echo "Usage: make [<target>]"
@echo "where available targets are:"
@echo
- @echo "build : Build the protos"
- @echo "dist : Build the protos and create the python package"
- @echo "test : Run all unit test"
- @echo "clean : Remove files created by the build and tests"
- @echo "distclean : Remove venv directory"
- @echo "help : Print this help"
- @echo "protos : Compile all grpc/protobuf files"
- @echo "rebuild-venv : Rebuild local Python virtualenv from scratch"
- @echo "venv : Build local Python virtualenv if did not exist yet"
+ @echo "build : Build the protos"
+ @echo "dist : Build the protos and create the python package"
+ @echo "docker_base_img : Build a base docker image with a modern version of pip and requirements.txt installed"
+ @echo "docker_image : Build a docker image with pyvoltha installed"
+ @echo "test : Run all unit test"
+ @echo "clean : Remove files created by the build and tests"
+ @echo "distclean : Remove venv directory"
+ @echo "help : Print this help"
+ @echo "protos : Compile all grpc/protobuf files"
+ @echo "rebuild-venv : Rebuild local Python virtualenv from scratch"
+ @echo "venv : Build local Python virtualenv if did not exist yet"
@echo
## New directories can be added here
@@ -77,6 +113,12 @@
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
twine upload dist/*
+docker_base_img:
+ docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}pyvoltha-base:${TAG} -f docker/Dockerfile.base .
+
+docker_image: docker_base_img dist
+ docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}pyvoltha:${TAG} -f docker/Dockerfile.pyvoltha .
+
install-protoc:
make -C pyvoltha/protos install-protoc
diff --git a/docker/Dockerfile.base b/docker/Dockerfile.base
new file mode 100644
index 0000000..fe8879c
--- /dev/null
+++ b/docker/Dockerfile.base
@@ -0,0 +1,28 @@
+# 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 openssl iproute2 libpcap-dev wget build-essential git binutils python-dev libffi-dev libssl-dev
+
+# Install current version of pip rather than outdated pip from apt
+RUN wget -O /tmp/get-pip.py https://bootstrap.pypa.io/get-pip.py
+RUN python /tmp/get-pip.py
+
+COPY requirements.txt /tmp/requirements.txt
+RUN pip install -r /tmp/requirements.txt
diff --git a/docker/Dockerfile.pyvoltha b/docker/Dockerfile.pyvoltha
new file mode 100644
index 0000000..4497934
--- /dev/null
+++ b/docker/Dockerfile.pyvoltha
@@ -0,0 +1,24 @@
+# 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}pyvoltha-base:${TAG}
+
+MAINTAINER Voltha Community <info@opennetworking.org>
+
+COPY dist /pyvoltha/dist
+RUN pip install /pyvoltha/dist/*.tar.gz
+