blob: 3d4c5bb7fa587fa5d1d5f50f8b66cede09fdefa6 [file] [log] [blame]
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -07001#
2# Copyright 2016 the original author or authors.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -080017ifneq ($(VOLTHA_BUILD),docker)
Nathan Knuthedc88da2016-09-17 00:28:05 -070018ifeq ($(VOLTHA_BASE)_set,_set)
19$(error To get started, please source the env.sh file)
20endif
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -080021endif
Nathan Knuthedc88da2016-09-17 00:28:05 -070022
David K. Bainbridgebba65ff2018-01-19 09:26:09 -080023ifeq ($(TAG),)
24TAG := latest
25endif
26
David K. Bainbridge03ad7412018-01-19 16:41:38 -080027ifeq ($(TARGET_TAG),)
28TARGET_TAG := latest
29endif
30
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -080031# If no DOCKER_HOST_IP is specified grab a v4 IP address associated with
32# the default gateway
33ifeq ($(DOCKER_HOST_IP),)
34DOCKER_HOST_IP := $(shell ifconfig $$(netstat -rn | grep -E '^(default|0.0.0.0)' | head -1 | awk '{print $$NF}') | grep inet | awk '{print $$2}' | sed -e 's/addr://g')
35endif
36
Nathan Knuth84dfd2e2016-09-16 15:06:34 -070037include setup.mk
38
Gertjan Van Droogenbroecke0c9acb2017-11-16 16:54:22 +010039ifneq ($(http_proxy)$(https_proxy),)
40# Include proxies from the environment
41DOCKER_PROXY_ARGS = \
42 --build-arg http_proxy=$(http_proxy) \
43 --build-arg https_proxy=$(https_proxy) \
44 --build-arg ftp_proxy=$(ftp_proxy) \
45 --build-arg no_proxy=$(no_proxy) \
46 --build-arg HTTP_PROXY=$(HTTP_PROXY) \
47 --build-arg HTTPS_PROXY=$(HTTPS_PROXY) \
48 --build-arg FTP_PROXY=$(FTP_PROXY) \
49 --build-arg NO_PROXY=$(NO_PROXY)
50endif
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -080051
52DOCKER_BUILD_ARGS = \
53 --build-arg TAG=$(TAG) \
David K. Bainbridge737b74f2018-01-22 12:57:52 -080054 --build-arg REGISTRY=$(REGISTRY) \
55 --build-arg REPOSITORY=$(REPOSITORY) \
56 $(DOCKER_PROXY_ARGS) $(DOCKER_CACHE_ARG) \
57 --rm --force-rm \
Shad Ansari32993eb2019-04-01 11:57:56 -070058 --no-cache \
David K. Bainbridge737b74f2018-01-22 12:57:52 -080059 $(DOCKER_BUILD_EXTRA_ARGS)
Gertjan Van Droogenbroecke0c9acb2017-11-16 16:54:22 +010060
Zsolt Haraszti41612482016-09-21 12:26:20 -070061VENVDIR := venv-$(shell uname -s | tr '[:upper:]' '[:lower:]')
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -070062
David K. Bainbridge03ad7412018-01-19 16:41:38 -080063DOCKER_IMAGE_LIST = \
64 base \
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -080065 protoc \
66 protos \
David K. Bainbridge03ad7412018-01-19 16:41:38 -080067 voltha \
68 ofagent \
69 tools \
70 fluentd \
71 envoy \
72 go-builder \
73 netconf \
74 shovel \
75 dashd \
76 cli \
77 portainer \
78 nginx \
79 consul \
80 grafana \
81 onos \
82 unum \
Stephane Barbarie35595062018-02-08 08:34:39 -050083 ponsim \
David K. Bainbridge03ad7412018-01-19 16:41:38 -080084 tester \
85 config-push \
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -080086 j2 \
Scott Baker45190782018-09-18 15:48:43 -070087 alarm-generator \
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -080088 test_runner
David K. Bainbridge03ad7412018-01-19 16:41:38 -080089
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -080090# The following list was scavanged from the compose / stack files as well as
91# from the Dockerfiles. If nothing else it highlights that VOLTHA is not
92# using consistent versions for some of the containers.
93
94# grep -i "^FROM" docker/Dockerfile.* | grep -v voltha- | sed -e 's/ as .*$//g' -e 's/\${REGISTRY}//g' | awk '{print $NF}' | grep -v '^scratch' | sed '/:.*$/!s/$/:latest/g' | sort -u | sed -e 's/^/ /g' -e 's/$/ \\/g'
95FETCH_BUILD_IMAGE_LIST = \
96 alpine:3.6 \
97 centos:7 \
98 centurylink/ca-certs:latest \
99 consul:0.9.2 \
100 debian:stretch-slim \
101 docker.elastic.co/logstash/logstash:5.6.0 \
102 fluent/fluentd:v0.12.42 \
103 gliderlabs/registrator:v7 \
104 golang:1.9.2 \
105 grpc/python:latest \
106 kamon/grafana_graphite:3.0 \
107 lyft/envoy:29361deae91575a1d46c7a21e913f19e75622ebe \
108 maven:3-jdk-8-alpine \
109 onosproject/onos:1.10.9 \
110 opennms/horizon-core-web:19.0.1-1 \
111 portainer/portainer:1.15.2 \
112 ubuntu:xenial
113
114# find compose -type f | xargs grep image: | awk '{print $NF}' | grep -v voltha- | sed -e 's/\"//g' -e 's/\${REGISTRY}//g' -e 's/:\${.*:-/:/g' -e 's/\}//g' -e '/:.*$/!s/$/:latest/g' | sort -u | sed -e 's/^/ /g' -e 's/$/ \\/g'
115FETCH_COMPOSE_IMAGE_LIST = \
116 consul:0.9.2 \
117 docker.elastic.co/elasticsearch/elasticsearch:5.6.0 \
118 fluent/fluentd:latest \
119 fluent/fluentd:v0.12.42 \
120 gliderlabs/registrator:latest \
121 kamon/grafana_graphite:latest \
122 marcelmaatkamp/freeradius:latest \
123 postgres:9.6.1 \
124 quay.io/coreos/etcd:v3.2.9 \
125 registry:2 \
126 tianon/true:latest \
127 wurstmeister/kafka:latest \
128 wurstmeister/zookeeper:latest
129
130# find k8s -type f | xargs grep image: | awk '{print $NF}' | sed -e 's/\"//g' | sed '/:.*$/!s/$/:latest/g' | sort -u | sed -e 's/^/ /g' -e 's/$/ \\/g'
131# Manually remove some image from this list as they don't reflect the new
132# naming conventions for the VOLTHA build
133FETCH_K8S_IMAGE_LIST = \
Stephane Barbarie2cbffca2018-03-26 16:20:03 -0400134 alpine:3.6 \
Stephane Barbarie78d9fa62018-04-19 14:11:05 -0400135 busybox:latest \
136 nginx:1.13 \
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800137 consul:0.9.2 \
Stephane Barbarie2cbffca2018-03-26 16:20:03 -0400138 fluent/fluentd:v0.12.42 \
139 gcr.io/google_containers/defaultbackend:1.4 \
Stephane Barbarie78d9fa62018-04-19 14:11:05 -0400140 gcr.io/google_containers/kubernetes-dashboard-amd64:v1.8.3 \
Stephane Barbarie2cbffca2018-03-26 16:20:03 -0400141 k8s.gcr.io/fluentd-gcp:1.30 \
142 kamon/grafana_graphite:3.0 \
143 marcelmaatkamp/freeradius:latest \
Stephane Barbarie78d9fa62018-04-19 14:11:05 -0400144 gcr.io/google-containers/hyperkube:v1.9.5 \
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800145 quay.io/coreos/etcd-operator:v0.7.2 \
Stephane Barbarie78d9fa62018-04-19 14:11:05 -0400146 quay.io/coreos/etcd:v3.2.9 \
Stephane Barbarie2cbffca2018-03-26 16:20:03 -0400147 quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.10.2 \
Stephane Barbarie30f64b82018-03-28 16:26:12 -0400148 wurstmeister/kafka:1.0.0 \
149 zookeeper:3.4.11
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800150
151FETCH_IMAGE_LIST = $(shell echo $(FETCH_BUILD_IMAGE_LIST) $(FETCH_COMPOSE_IMAGE_LIST) $(FETCH_K8S_IMAGE_LIST) | tr ' ' '\n' | sort -u)
152
Scott Baker45190782018-09-18 15:48:43 -0700153.PHONY: $(DIRS) $(DIRS_CLEAN) $(DIRS_FLAKE8) flake8 base voltha ofagent netconf shovel onos dashd cli alarm-generator portainer grafana nginx consul envoy go-builder envoyd tools opennms logstash unum ponsim start stop tag push pull
Nathan Knuth84dfd2e2016-09-16 15:06:34 -0700154
ggowdru9974f212017-06-06 23:31:25 -0700155# This should to be the first and default target in this Makefile
156help:
157 @echo "Usage: make [<target>]"
158 @echo "where available targets are:"
159 @echo
160 @echo "build : Build the Voltha protos and docker images.\n\
161 If this is the first time you are building, choose \"make build\" option."
Sergio Slobodrian7a7091c2017-06-21 23:45:45 -0400162 @echo "production : Build voltha for production deployment"
ggowdru9974f212017-06-06 23:31:25 -0700163 @echo "clean : Remove files created by the build and tests"
164 @echo "distclean : Remove venv directory"
165 @echo "fetch : Pre-fetch artifacts for subsequent local builds"
166 @echo "flake8 : Run specifically flake8 tests"
167 @echo "help : Print this help"
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800168 @echo "protoc : Build a container with protoc installed"
ggowdru9974f212017-06-06 23:31:25 -0700169 @echo "protos : Compile all grpc/protobuf files"
170 @echo "rebuild-venv : Rebuild local Python virtualenv from scratch"
171 @echo "venv : Build local Python virtualenv if did not exist yet"
172 @echo "utest : Run all unit tests"
173 @echo "itest : Run all integration tests"
174 @echo "containers : Build all the docker containers"
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800175 @echo "base : Build the base docker container used by all other dockers"
ggowdru9974f212017-06-06 23:31:25 -0700176 @echo "voltha : Build the voltha docker container"
ggowdru9974f212017-06-06 23:31:25 -0700177 @echo "ofagent : Build the ofagent docker container"
ggowdru9974f212017-06-06 23:31:25 -0700178 @echo "netconf : Build the netconf docker container"
179 @echo "shovel : Build the shovel docker container"
180 @echo "onos : Build the onos docker container"
181 @echo "dashd : Build the dashd docker container"
David K. Bainbridgebba65ff2018-01-19 09:26:09 -0800182 @echo "cli : Build the cli docker container"
ggowdru9974f212017-06-06 23:31:25 -0700183 @echo "portainer : Build the portainer docker container"
184 @echo "grafana : Build the grafana docker container"
185 @echo "nginx : Build the nginx docker container"
schowdhury40739212017-06-12 07:40:31 -0700186 @echo "consul : Build the consul docker container"
David K. Bainbridge215e0242017-09-05 23:18:24 -0700187 @echo "unum : Build the unum docker container"
Stephane Barbarie35595062018-02-08 08:34:39 -0500188 @echo "ponsim : Build the ponsim docker container"
David K. Bainbridgebba65ff2018-01-19 09:26:09 -0800189 @echo "j2 : Build the Jinja2 template container"
balajikp9be9fd42019-01-23 15:40:21 -0600190 @echo "alarm-generator : Build the alarm-generator container"
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800191 @echo "test_runner : Build a container from which tests are run"
David K. Bainbridgebba65ff2018-01-19 09:26:09 -0800192 @echo "start : Start VOLTHA on the current system"
193 @echo "stop : Stop VOLTHA on the current system"
David K. Bainbridge03ad7412018-01-19 16:41:38 -0800194 @echo "tag : Tag a set of images"
195 @echo "push : Push the docker images to an external repository"
196 @echo "pull : Pull the docker images from a repository"
ggowdru9974f212017-06-06 23:31:25 -0700197 @echo
Nathan Knuth5157de02016-09-16 15:20:37 -0700198
Nathan Knuth84dfd2e2016-09-16 15:06:34 -0700199## New directories can be added here
200DIRS:=\
Nathan Knuthedc88da2016-09-17 00:28:05 -0700201voltha/northbound/openflow \
202voltha/northbound/openflow/agent \
203voltha/northbound/openflow/oftest
Nathan Knuth84dfd2e2016-09-16 15:06:34 -0700204
205## If one directory depends on another directory that
206## dependency can be expressed here
207##
208## For example, if the Tibit directory depended on the eoam
209## directory being built first, then that can be expressed here.
210## driver/tibit: eoam
211
212# Parallel Build
213$(DIRS):
214 @echo " MK $@"
215 $(Q)$(MAKE) -C $@
216
217# Parallel Clean
218DIRS_CLEAN = $(addsuffix .clean,$(DIRS))
219$(DIRS_CLEAN):
220 @echo " CLEAN $(basename $@)"
221 $(Q)$(MAKE) -C $(basename $@) clean
222
223# Parallel Flake8
224DIRS_FLAKE8 = $(addsuffix .flake8,$(DIRS))
225$(DIRS_FLAKE8):
226 @echo " FLAKE8 $(basename $@)"
Nathan Knuth950dff22016-09-17 16:12:34 -0700227 -$(Q)$(MAKE) -C $(basename $@) flake8
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -0700228
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800229build: protoc protos go-builder containers
Zsolt Haraszti32dda552016-09-27 09:17:29 -0700230
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800231production: protoc protos go-builder prod-containers
Sergio Slobodrian7a7091c2017-06-21 23:45:45 -0400232
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800233jenkins: build
khenaidoofe874ae2017-07-14 18:07:27 -0400234
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800235jenkins-containers: base voltha ofagent netconf consul cli envoy fluentd unum j2
Sergio Slobodrian7a7091c2017-06-21 23:45:45 -0400236
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800237prod-containers: base voltha ofagent netconf shovel onos dashd cli grafana consul tools envoy fluentd unum j2
Sergio Slobodrian7a7091c2017-06-21 23:45:45 -0400238
Scott Baker45190782018-09-18 15:48:43 -0700239containers: base voltha ofagent netconf shovel onos tester config-push dashd cli portainer grafana nginx consul tools envoy fluentd unum ponsim j2 alarm-generator test_runner
Khen Nursimuluaaac7ee2016-12-11 22:03:52 -0500240
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800241base:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800242 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-base:${TAG} -f docker/Dockerfile.base .
Zsolt Haraszti51af3392016-09-10 22:18:45 -0700243
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800244ifneq ($(VOLTHA_BUILD),docker)
Shad Ansari83777cb2017-06-02 14:56:08 -0700245voltha: voltha-adapters
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800246 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-voltha:${TAG} -f docker/Dockerfile.voltha .
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800247else
248voltha:
249 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-voltha:${TAG} -f docker/Dockerfile.voltha_d .
250endif
Zsolt Harasztidb892332017-01-09 11:08:38 -0800251
Shad Ansari83777cb2017-06-02 14:56:08 -0700252voltha-adapters:
253 make -C voltha/adapters/asfvolt16_olt
Shad Ansari2825d012018-02-22 23:57:46 +0000254 make -C voltha/adapters/openolt
Shad Ansari83777cb2017-06-02 14:56:08 -0700255
Zsolt Harasztidb892332017-01-09 11:08:38 -0800256ofagent:
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800257ifneq ($(VOLTHA_BUILD),docker)
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800258 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-ofagent:${TAG} -f docker/Dockerfile.ofagent .
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800259else
260 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-ofagent:${TAG} -f docker/Dockerfile.ofagent_d .
261endif
Zsolt Harasztidb892332017-01-09 11:08:38 -0800262
Sergio Slobodriancab0a392017-07-13 08:42:10 -0400263tools:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800264 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-tools:${TAG} -f docker/Dockerfile.tools .
Sergio Slobodriancab0a392017-07-13 08:42:10 -0400265
sathishgb5d1c182017-07-13 14:20:19 +0530266fluentd:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800267 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-fluentd:${TAG} -f docker/Dockerfile.fluentd .
sathishgb5d1c182017-07-13 14:20:19 +0530268
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800269envoy: envoyd
270ifneq ($(VOLTHA_BUILD),docker)
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800271 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-envoy:${TAG} -f docker/Dockerfile.envoy .
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800272else
273 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-envoy:${TAG} -f docker/Dockerfile.envoy_d .
274endif
Sergio Slobodriancab0a392017-07-13 08:42:10 -0400275
Sergio Slobodrianbe829272017-07-17 14:45:45 -0400276envoyd:
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800277ifneq ($(VOLTHA_BUILD),docker)
Sergio Slobodrian6570c742017-08-07 23:11:33 -0400278 make -C envoy
Sergio Slobodrianbe829272017-07-17 14:45:45 -0400279 make -C envoy/go/envoyd
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800280endif
Sergio Slobodrianbe829272017-07-17 14:45:45 -0400281
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800282go-builder:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800283 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-go-builder:${TAG} -f envoy/go/golang-builder/Dockerfile ./envoy/go/golang-builder
Sergio Slobodrianbe829272017-07-17 14:45:45 -0400284
Zsolt Harasztidb892332017-01-09 11:08:38 -0800285netconf:
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800286ifneq ($(VOLTHA_BUILD),docker)
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800287 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-netconf:${TAG} -f docker/Dockerfile.netconf .
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800288else
289 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-netconf:${TAG} -f docker/Dockerfile.netconf_d .
290endif
Zsolt Harasztidb892332017-01-09 11:08:38 -0800291
Stephane Barbarie14088962017-06-01 16:56:55 -0400292netopeer:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800293 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-netopeer:${TAG} -f docker/Dockerfile.netopeer .
Stephane Barbarie14088962017-06-01 16:56:55 -0400294
Zsolt Harasztidb892332017-01-09 11:08:38 -0800295shovel:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800296 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-shovel:${TAG} -f docker/Dockerfile.shovel .
Zsolt Harasztidb892332017-01-09 11:08:38 -0800297
Sergio Slobodrian9358bd42017-03-10 22:52:24 -0500298dashd:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800299 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-dashd:${TAG} -f docker/Dockerfile.dashd .
Sergio Slobodrian9358bd42017-03-10 22:52:24 -0500300
David K. Bainbridgebba65ff2018-01-19 09:26:09 -0800301cli:
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800302ifneq ($(VOLTHA_BUILD),docker)
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800303 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-cli:${TAG} -f docker/Dockerfile.cli .
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800304else
305 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-cli:${TAG} -f docker/Dockerfile.cli_d .
306endif
Sergio Slobodrianab11c642017-04-24 07:16:58 -0400307
David K. Bainbridge60fdad72018-02-20 11:17:38 -0500308custom_cli: cli
309ifeq ($(CUSTOM_CLI_LABEL),)
310 docker build ${DOCKER_BUILD_ARGS} -t ${REGISTRY}${REPOSITORY}voltha-cli-custom:${TAG} -f docker/Dockerfile.cli_custom .
311else
312 docker build ${DOCKER_BUILD_ARGS} -t ${REGISTRY}${REPOSITORY}voltha-cli${CUSTOM_CLI_LABEL}:${TAG} -f docker/Dockerfile.cli_custom .
313endif
314
Sergio Slobodrian4d307102017-04-24 10:19:00 -0400315portainer:
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800316ifneq ($(VOLTHA_BUILD),docker)
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800317 REGISTRY=${REGISTRY} REPOSITORY=${REPOSITORY} TAG=${TAG} portainer/buildPortainer.sh
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800318else
319 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-portainer:${TAG} -f docker/Dockerfile.portainer_d .
320endif
Sergio Slobodrian4d307102017-04-24 10:19:00 -0400321
Sergio Slobodrianff52e1b2017-04-24 12:39:08 -0400322nginx:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800323 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-nginx:${TAG} -f docker/Dockerfile.nginx .
Sergio Slobodrianff52e1b2017-04-24 12:39:08 -0400324
schowdhury40739212017-06-12 07:40:31 -0700325consul:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800326 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-consul:${TAG} -f docker/Dockerfile.consul .
schowdhury40739212017-06-12 07:40:31 -0700327
Sergio Slobodrianff52e1b2017-04-24 12:39:08 -0400328grafana:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800329 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-grafana:${TAG} -f docker/Dockerfile.grafana .
Sergio Slobodrianff52e1b2017-04-24 12:39:08 -0400330
Zsolt Harasztidb892332017-01-09 11:08:38 -0800331onos:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800332 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-onos:${TAG} -f docker/Dockerfile.onos docker
Zsolt Harasztidb892332017-01-09 11:08:38 -0800333
David K. Bainbridge215e0242017-09-05 23:18:24 -0700334unum:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800335 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-unum:${TAG} -f unum/Dockerfile ./unum
David K. Bainbridge215e0242017-09-05 23:18:24 -0700336
alshabib5e180572017-01-10 23:59:47 -0600337tester:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800338 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-tester:${TAG} -f docker/Dockerfile.tester docker
alshabib5e180572017-01-10 23:59:47 -0600339
alshabiba5514082017-03-31 11:08:27 -0500340config-push:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800341 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-config-push:${TAG} -f docker/Dockerfile.configpush docker
alshabiba5514082017-03-31 11:08:27 -0500342
Stephane Barbarie95507c42017-09-19 10:41:04 -0400343opennms:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800344 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-opennms:${TAG} -f docker/Dockerfile.opennms .
Stephane Barbarie95507c42017-09-19 10:41:04 -0400345
346logstash:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800347 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-logstash:${TAG} -f docker/Dockerfile.logstash .
David K. Bainbridgebba65ff2018-01-19 09:26:09 -0800348
Stephane Barbarie35595062018-02-08 08:34:39 -0500349ponsim:
350 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-ponsim:${TAG} -f docker/Dockerfile.ponsim .
351
David K. Bainbridgebba65ff2018-01-19 09:26:09 -0800352j2:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800353 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-j2:${TAG} -f docker/Dockerfile.j2 docker
David K. Bainbridgebba65ff2018-01-19 09:26:09 -0800354
Scott Baker45190782018-09-18 15:48:43 -0700355alarm-generator:
356ifneq ($(VOLTHA_BUILD),docker)
357 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-alarm-generator:${TAG} -f docker/Dockerfile.alarm-generator .
358else
359 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-alarm-generator:${TAG} -f docker/Dockerfile.alarm-generator_d .
360endif
361
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800362test_runner:
363ifeq ($(VOLTHA_BUILD),docker)
364 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-test_runner:${TAG} -f docker/Dockerfile.test_runner .
365endif
366
Jonathan Hart2dd29dd2018-02-08 17:18:28 -0800367@MAKE_ENV := $(shell echo '$(.VARIABLES)' | awk -v RS=' ' '/^[a-zA-Z0-9]+$$/')
368@SHELL_EXPORT := $(foreach v,$(MAKE_ENV),$(v)='$($(v))')
David K. Bainbridgebba65ff2018-01-19 09:26:09 -0800369start:
Jonathan Hart2dd29dd2018-02-08 17:18:28 -0800370 $(SHELL_EXPORT) STACK_TEMPLATE=./compose/voltha-stack.yml.j2 ./scripts/run-voltha.sh start
371
David K. Bainbridgebba65ff2018-01-19 09:26:09 -0800372stop:
Jonathan Hart2dd29dd2018-02-08 17:18:28 -0800373 ./scripts/run-voltha.sh stop
Sergio Slobodrianff52e1b2017-04-24 12:39:08 -0400374
David K. Bainbridge03ad7412018-01-19 16:41:38 -0800375tag: $(patsubst %,%.tag,$(DOCKER_IMAGE_LIST))
376
377push: tag $(patsubst %,%.push,$(DOCKER_IMAGE_LIST))
378
379pull: $(patsubst %,%.pull,$(DOCKER_IMAGE_LIST))
380
381%.tag:
382 docker tag ${REGISTRY}${REPOSITORY}voltha-$(subst .tag,,$@):${TAG} ${TARGET_REGISTRY}${TARGET_REPOSITORY}voltha-$(subst .tag,,$@):${TARGET_TAG}
383
384%.push:
385 docker push ${TARGET_REGISTRY}${TARGET_REPOSITORY}voltha-$(subst .push,,$@):${TARGET_TAG}
386
387%.pull:
388 docker pull ${REGISTRY}${REPOSITORY}voltha-$(subst .pull,,$@):${TAG}
389
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800390protoc:
391ifeq ($(VOLTHA_BUILD),docker)
392 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-protoc:${TAG} -f docker/Dockerfile.protoc .
393endif
394
Zsolt Haraszti5cd64702016-09-27 13:48:35 -0700395protos:
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800396ifneq ($(VOLTHA_BUILD),docker)
Zsolt Haraszti5cd64702016-09-27 13:48:35 -0700397 make -C voltha/protos
Zsolt Haraszti023ea7c2016-10-16 19:30:34 -0700398 make -C ofagent/protos
Khen Nursimuluaaac7ee2016-12-11 22:03:52 -0500399 make -C netconf/protos
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800400else
401 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-protos:${TAG} -f docker/Dockerfile.protos .
402endif
Zsolt Harasztia54f2ac2016-09-21 15:54:15 -0700403
404install-protoc:
Zsolt Haraszti5cd64702016-09-27 13:48:35 -0700405 make -C voltha/protos install-protoc
Zsolt Harasztia54f2ac2016-09-21 15:54:15 -0700406
Zsolt Harasztib71c2a02016-09-12 13:12:07 -0700407clean:
408 find voltha -name '*.pyc' | xargs rm -f
409
Nathan Knutha6b09e32016-09-21 16:26:09 -0700410distclean: clean
411 rm -rf ${VENVDIR}
412
Zsolt Haraszti51af3392016-09-10 22:18:45 -0700413fetch:
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800414 @bash -c ' \
415 for i in $(FETCH_IMAGE_LIST); do \
416 docker pull $$i; \
417 done'
418
419fetch-jenkins: fetch
Zsolt Haraszti51af3392016-09-10 22:18:45 -0700420
421purge-venv:
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -0700422 rm -fr ${VENVDIR}
Zsolt Haraszti51af3392016-09-10 22:18:45 -0700423
424rebuild-venv: purge-venv venv
425
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800426ifneq ($(VOLTHA_BUILD),docker)
Zsolt Haraszti51af3392016-09-10 22:18:45 -0700427venv: ${VENVDIR}/.built
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800428else
429venv:
430endif
Zsolt Haraszti51af3392016-09-10 22:18:45 -0700431
balajikp9be9fd42019-01-23 15:40:21 -0600432VENV_BIN ?= virtualenv
433VENV_OPTS ?=
434
Zsolt Haraszti51af3392016-09-10 22:18:45 -0700435${VENVDIR}/.built:
balajikp9be9fd42019-01-23 15:40:21 -0600436 @ $(VENV_BIN) ${VENV_OPTS} ${VENVDIR}
437 @ $(VENV_BIN) ${VENV_OPTS} --relocatable ${VENVDIR}
Zsolt Haraszti51af3392016-09-10 22:18:45 -0700438 @ . ${VENVDIR}/bin/activate && \
Zsolt Haraszti41612482016-09-21 12:26:20 -0700439 pip install --upgrade pip; \
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -0700440 if ! pip install -r requirements.txt; \
441 then \
442 echo "On MAC OS X, if the installation failed with an error \n'<openssl/opensslv.h>': file not found,"; \
443 echo "see the BUILD.md file for a workaround"; \
Zsolt Haraszti51af3392016-09-10 22:18:45 -0700444 else \
Zsolt Haraszti41612482016-09-21 12:26:20 -0700445 uname -s > ${VENVDIR}/.built; \
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -0700446 fi
balajikp9be9fd42019-01-23 15:40:21 -0600447 @ $(VENV_BIN) ${VENV_OPTS} --relocatable ${VENVDIR}
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -0700448
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800449ifneq ($(VOLTHA_BUILD),docker)
Khen Nursimulu34e7ebb2016-11-10 13:38:44 -0800450test: venv protos run-as-root-tests
451 @ echo "Executing all tests"
452 . ${VENVDIR}/bin/activate && \
453 nosetests -s tests \
454 --exclude-dir=./tests/itests/run_as_root/
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800455else
456test: protos test_runner run-as-root-tests
457 docker run \
458 -e VOLTHA_BUILD=docker \
459 -e REGISTRY=${REGISTRY} \
460 -e REPOSITORY=${REPOSITORY} \
461 -e TAG=${TAG} \
462 -e DOCKER_HOST_IP=${DOCKER_HOST_IP} \
463 --rm --net=host -v /var/run/docker.sock:/var/run/docker.sock \
464 ${REGISTRY}${REPSOITORY}voltha-test_runner:${TAG} \
465 nosetests -s tests --exclude-dir=./tests/itests/run_as_root/
466endif
Khen Nursimulu34e7ebb2016-11-10 13:38:44 -0800467
Adam Dyessdddbd082019-02-11 10:06:33 -0600468.PHONY: utest-adapters
balajikp9be9fd42019-01-23 15:40:21 -0600469TEST_ADAPTERS := $(shell find ./voltha/adapters -name test.mk)
Adam Dyessdddbd082019-02-11 10:06:33 -0600470TESTABLE_ADAPTERS:= $(patsubst %.mk,%_target,$(TEST_ADAPTERS))
471
472%_target : %.mk
473 @ echo Test Adapter \($<\)
474 @ $(MAKE) -f $<
475
476utest-adapters: $(TESTABLE_ADAPTERS)
477 @ echo Completed utest of Testable Adapters
478
balajikp9be9fd42019-01-23 15:40:21 -0600479
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800480ifneq ($(VOLTHA_BUILD),docker)
Zsolt Haraszti66186622016-11-08 14:24:00 -0800481utest: venv protos
Zsolt Haraszti51af3392016-09-10 22:18:45 -0700482 @ echo "Executing all unit tests"
balajikp9be9fd42019-01-23 15:40:21 -0600483 @ . ${VENVDIR}/bin/activate && nosetests ./tests/utests
Adam Dyessdddbd082019-02-11 10:06:33 -0600484 @ $(MAKE) utest-adapters
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800485else
486utest: protos test_runner
487 docker run \
488 -e VOLTHA_BUILD=docker \
489 -e REGISTRY=${REGISTRY} \
490 -e REPOSITORY=${REPOSITORY} \
491 -e TAG=${TAG} \
492 -e DOCKER_HOST_IP=${DOCKER_HOST_IP} \
493 --rm --net=host -v /var/run/docker.sock:/var/run/docker.sock \
494 ${REGISTRY}${REPSOITORY}voltha-test_runner:${TAG} \
495 bash -c \
balajikp9be9fd42019-01-23 15:40:21 -0600496 '. ${VENVDIR}/bin/activate && nosetests ./tests/utests; \
Adam Dyessdddbd082019-02-11 10:06:33 -0600497 $(MAKE) utest-adapters'
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800498endif
alshabib29a3ed52017-01-23 14:29:21 -0800499
balajikp9be9fd42019-01-23 15:40:21 -0600500COVERAGE_OPTS=--with-xcoverage --with-xunit --cover-package=voltha,common,ofagent --cover-html\
501 --cover-html-dir=tmp/cover
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800502ifneq ($(VOLTHA_BUILD),docker)
alshabib29a3ed52017-01-23 14:29:21 -0800503utest-with-coverage: venv protos
504 @ echo "Executing all unit tests and producing coverage results"
balajikp9be9fd42019-01-23 15:40:21 -0600505 @ . ${VENVDIR}/bin/activate && nosetests $(COVERAGE_OPTS) ./tests/utests
Adam Dyessdddbd082019-02-11 10:06:33 -0600506 @ $(MAKE) utest-adapters
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800507else
508utest-with-coverage: protos test_runner
509 @echo "Executing all unit tests and producing coverage results"
510 docker run \
511 -e VOLTHA_BUILD=docker \
512 -e REGISTRY=${REGISTRY} \
513 -e REPOSITORY=${REPOSITORY} \
514 -e TAG=${TAG} \
515 -e DOCKER_HOST_IP=${DOCKER_HOST_IP} \
516 --rm --net=host -v /var/run/docker.sock:/var/run/docker.sock \
517 ${REGISTRY}${REPSOITORY}voltha-test_runner:${TAG} \
518 bash -c \
balajikp9be9fd42019-01-23 15:40:21 -0600519 'nosetests ${COVERAGE_OPTS} ./tests/utests; \
Adam Dyessdddbd082019-02-11 10:06:33 -0600520 $(MAKE) utest-adapters'
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800521endif
Khen Nursimulu37a9bf82016-10-16 20:11:31 -0400522
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800523ifneq ($(VOLTHA_BUILD),docker)
Zsolt Haraszti348d1932016-12-10 01:10:07 -0800524itest: venv run-as-root-tests
Khen Nursimulu34e7ebb2016-11-10 13:38:44 -0800525 @ echo "Executing all integration tests"
526 . ${VENVDIR}/bin/activate && \
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800527 rm -rf /tmp/fluentd/* && \
528 REGISTRY=${REGISTRY} \
529 REPOSITORY=${REPOSITORY} \
530 TAG=${TAG} \
531 DOCKER_HOST_IP=${DOCKER_HOST_IP} \
Khen Nursimulu34e7ebb2016-11-10 13:38:44 -0800532 nosetests -s \
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800533 tests/itests/docutests/build_md_test.py \
534 --exclude-dir=./tests/utests/ \
535 --exclude-dir=./tests/itests/run_as_root/
536else
537itest: protos test_runner
538 @ echo "Executing all integration tests"
539 docker run \
540 -e VOLTHA_BUILD=docker \
541 -e REGISTRY=${REGISTRY} \
542 -e REPOSITORY=${REPOSITORY} \
543 -e TAG=${TAG} \
544 -e DOCKER_HOST_IP=${DOCKER_HOST_IP} \
545 --rm --net=host -v /var/run/docker.sock:/var/run/docker.sock \
546 ${REGISTRY}${REPSOITORY}voltha-test_runner:${TAG} \
547 nosetests -s \
548 tests/itests/docutests/build_md_test.py \
549 --exclude-dir=./tests/utests/ \
550 --exclude-dir=./tests/itests/run_as_root/
551endif
Khen Nursimulu34e7ebb2016-11-10 13:38:44 -0800552
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800553ifneq ($(VOLTHA_BUILD),docker)
Zsolt Haraszti348d1932016-12-10 01:10:07 -0800554smoke-test: venv run-as-root-tests
Khen Nursimulu34e7ebb2016-11-10 13:38:44 -0800555 @ echo "Executing smoke tests"
Khen Nursimulu96bb5322016-11-09 20:16:03 -0800556 . ${VENVDIR}/bin/activate && \
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800557 rm -rf /tmp/fluentd/* && \
558 REGISTRY=${REGISTRY} \
559 REPOSITORY=${REPOSITORY} \
560 TAG=${TAG} \
561 DOCKER_HOST_IP=${DOCKER_HOST_IP} \
Khen Nursimulu96bb5322016-11-09 20:16:03 -0800562 nosetests -s \
563 tests/itests/docutests/build_md_test.py:BuildMdTests.test_07_start_all_containers \
Khen Nursimulu34e7ebb2016-11-10 13:38:44 -0800564 --exclude-dir=./tests/itests/run_as_root/
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800565else
566smoke-test: protos test_runner run-as-root-tests
567 @ echo "Executing smoke tests"
568 docker run \
569 -e VOLTHA_BUILD=docker \
570 -e REGISTRY=${REGISTRY} \
571 -e REPOSITORY=${REPOSITORY} \
572 -e TAG=${TAG} \
573 -e DOCKER_HOST_IP=${DOCKER_HOST_IP} \
574 --rm --net=host -v /var/run/docker.sock:/var/run/docker.sock \
575 ${REGISTRY}${REPSOITORY}voltha-test_runner:${TAG} \
576 nosetests -s \
577 tests/itests/docutests/build_md_test.py:BuildMdTests.test_07_start_all_containers \
578 --exclude-dir=./tests/itests/run_as_root/
579endif
Khen Nursimulu96bb5322016-11-09 20:16:03 -0800580
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800581ifneq ($(VOLTHA_BUILD),docker)
khenaidoo1243ee92017-07-17 15:54:06 -0400582jenkins-test: venv
583 @ echo "Executing jenkins smoke tests"
584 . ${VENVDIR}/bin/activate && \
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800585 rm -rf /tmp/fluentd/* && \
586 REGISTRY=${REGISTRY} \
587 REPOSITORY=${REPOSITORY} \
588 TAG=${TAG} \
589 DOCKER_HOST_IP=${DOCKER_HOST_IP} \
khenaidoo1243ee92017-07-17 15:54:06 -0400590 nosetests -s \
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800591 tests/itests/docutests/build_md_test.py:BuildMdTests.test_07_start_all_containers \
592 --exclude-dir=./tests/itests/run_as_root/
593else
594jenkins-test: protos test_runner
595 @ echo "Executing jenkins smoke tests"
596 @ echo "Starting VOLTHA as docker-compose services"
597 docker run \
598 -e REGISTRY=${REGISTRY} \
599 -e REPOSITORY=${REPOSITORY} \
600 -e TAG=${TAG} \
601 -e DOCKER_HOST_IP=${DOCKER_HOST_IP} \
602 --rm --net=host -v /var/run/docker.sock:/var/run/docker.sock \
603 ${REGISTRY}${REPSOITORY}voltha-test_runner:${TAG} \
604 nosetests -s \
605 tests/itests/docutests/build_md_test.py:BuildMdTests.test_07_start_all_containers \
606 --exclude-dir=./tests/itests/run_as_root/
607endif
khenaidoo1243ee92017-07-17 15:54:06 -0400608
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800609ifneq ($(VOLTHA_BUILD),docker)
Khen Nursimulu34e7ebb2016-11-10 13:38:44 -0800610run-as-root-tests:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800611 docker run -i --rm -v /cord/incubator/voltha:/voltha --privileged ${REGISTRY}${REPOSITORY}voltha-base:${TAG} env PYTHONPATH=/voltha python /voltha/tests/itests/run_as_root/test_frameio.py
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800612else
613run-as-root-tests:
614 docker run \
615 -e VOLTHA_BUILD=docker \
616 -e REGISTRY=${REGISTRY} \
617 -e REPOSITORY=${REPOSITORY} \
618 -e TAG=${TAG} \
619 -e DOCKER_HOST_IP=${DOCKER_HOST_IP} \
620 --rm --privileged \
621 ${REGISTRY}${REPOSITORY}voltha-test_runner:${TAG} \
622 env PYTHONPATH=/work python tests/itests/run_as_root/test_frameio.py
623endif
Nathan Knuth84dfd2e2016-09-16 15:06:34 -0700624
625flake8: $(DIRS_FLAKE8)
Nathan Knuth220a6772016-10-11 08:10:46 -0700626
627# end file