blob: 6e6112153d4e1193faa4de3fdb9a386c68574aff [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 \
58 $(DOCKER_BUILD_EXTRA_ARGS)
Gertjan Van Droogenbroecke0c9acb2017-11-16 16:54:22 +010059
Zsolt Haraszti41612482016-09-21 12:26:20 -070060VENVDIR := venv-$(shell uname -s | tr '[:upper:]' '[:lower:]')
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -070061
David K. Bainbridge03ad7412018-01-19 16:41:38 -080062DOCKER_IMAGE_LIST = \
63 base \
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -080064 protoc \
65 protos \
David K. Bainbridge03ad7412018-01-19 16:41:38 -080066 voltha \
67 ofagent \
68 tools \
69 fluentd \
70 envoy \
71 go-builder \
72 netconf \
73 shovel \
74 dashd \
75 cli \
76 portainer \
77 nginx \
78 consul \
79 grafana \
80 onos \
81 unum \
Stephane Barbarie35595062018-02-08 08:34:39 -050082 ponsim \
David K. Bainbridge03ad7412018-01-19 16:41:38 -080083 tester \
84 config-push \
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -080085 j2 \
86 test_runner
David K. Bainbridge03ad7412018-01-19 16:41:38 -080087
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -080088# The following list was scavanged from the compose / stack files as well as
89# from the Dockerfiles. If nothing else it highlights that VOLTHA is not
90# using consistent versions for some of the containers.
91
92# 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'
93FETCH_BUILD_IMAGE_LIST = \
94 alpine:3.6 \
95 centos:7 \
96 centurylink/ca-certs:latest \
97 consul:0.9.2 \
98 debian:stretch-slim \
99 docker.elastic.co/logstash/logstash:5.6.0 \
100 fluent/fluentd:v0.12.42 \
101 gliderlabs/registrator:v7 \
102 golang:1.9.2 \
103 grpc/python:latest \
104 kamon/grafana_graphite:3.0 \
105 lyft/envoy:29361deae91575a1d46c7a21e913f19e75622ebe \
106 maven:3-jdk-8-alpine \
107 onosproject/onos:1.10.9 \
108 opennms/horizon-core-web:19.0.1-1 \
109 portainer/portainer:1.15.2 \
110 ubuntu:xenial
111
112# 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'
113FETCH_COMPOSE_IMAGE_LIST = \
114 consul:0.9.2 \
115 docker.elastic.co/elasticsearch/elasticsearch:5.6.0 \
116 fluent/fluentd:latest \
117 fluent/fluentd:v0.12.42 \
118 gliderlabs/registrator:latest \
119 kamon/grafana_graphite:latest \
120 marcelmaatkamp/freeradius:latest \
121 postgres:9.6.1 \
122 quay.io/coreos/etcd:v3.2.9 \
123 registry:2 \
124 tianon/true:latest \
125 wurstmeister/kafka:latest \
126 wurstmeister/zookeeper:latest
127
128# 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'
129# Manually remove some image from this list as they don't reflect the new
130# naming conventions for the VOLTHA build
131FETCH_K8S_IMAGE_LIST = \
132 consul:0.9.2 \
133 quay.io/coreos/etcd-operator:v0.7.2 \
134 wurstmeister/kafka:1.0.0 \
135 zookeeper:3.4.11
136
137FETCH_IMAGE_LIST = $(shell echo $(FETCH_BUILD_IMAGE_LIST) $(FETCH_COMPOSE_IMAGE_LIST) $(FETCH_K8S_IMAGE_LIST) | tr ' ' '\n' | sort -u)
138
Stephane Barbarie35595062018-02-08 08:34:39 -0500139.PHONY: $(DIRS) $(DIRS_CLEAN) $(DIRS_FLAKE8) flake8 base voltha ofagent netconf shovel onos dashd cli 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 -0700140
ggowdru9974f212017-06-06 23:31:25 -0700141# This should to be the first and default target in this Makefile
142help:
143 @echo "Usage: make [<target>]"
144 @echo "where available targets are:"
145 @echo
146 @echo "build : Build the Voltha protos and docker images.\n\
147 If this is the first time you are building, choose \"make build\" option."
Sergio Slobodrian7a7091c2017-06-21 23:45:45 -0400148 @echo "production : Build voltha for production deployment"
ggowdru9974f212017-06-06 23:31:25 -0700149 @echo "clean : Remove files created by the build and tests"
150 @echo "distclean : Remove venv directory"
151 @echo "fetch : Pre-fetch artifacts for subsequent local builds"
152 @echo "flake8 : Run specifically flake8 tests"
153 @echo "help : Print this help"
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800154 @echo "protoc : Build a container with protoc installed"
ggowdru9974f212017-06-06 23:31:25 -0700155 @echo "protos : Compile all grpc/protobuf files"
156 @echo "rebuild-venv : Rebuild local Python virtualenv from scratch"
157 @echo "venv : Build local Python virtualenv if did not exist yet"
158 @echo "utest : Run all unit tests"
159 @echo "itest : Run all integration tests"
160 @echo "containers : Build all the docker containers"
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800161 @echo "base : Build the base docker container used by all other dockers"
ggowdru9974f212017-06-06 23:31:25 -0700162 @echo "voltha : Build the voltha docker container"
ggowdru9974f212017-06-06 23:31:25 -0700163 @echo "ofagent : Build the ofagent docker container"
ggowdru9974f212017-06-06 23:31:25 -0700164 @echo "netconf : Build the netconf docker container"
165 @echo "shovel : Build the shovel docker container"
166 @echo "onos : Build the onos docker container"
167 @echo "dashd : Build the dashd docker container"
David K. Bainbridgebba65ff2018-01-19 09:26:09 -0800168 @echo "cli : Build the cli docker container"
ggowdru9974f212017-06-06 23:31:25 -0700169 @echo "portainer : Build the portainer docker container"
170 @echo "grafana : Build the grafana docker container"
171 @echo "nginx : Build the nginx docker container"
schowdhury40739212017-06-12 07:40:31 -0700172 @echo "consul : Build the consul docker container"
David K. Bainbridge215e0242017-09-05 23:18:24 -0700173 @echo "unum : Build the unum docker container"
Stephane Barbarie35595062018-02-08 08:34:39 -0500174 @echo "ponsim : Build the ponsim docker container"
David K. Bainbridgebba65ff2018-01-19 09:26:09 -0800175 @echo "j2 : Build the Jinja2 template container"
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800176 @echo "test_runner : Build a container from which tests are run"
David K. Bainbridgebba65ff2018-01-19 09:26:09 -0800177 @echo "start : Start VOLTHA on the current system"
178 @echo "stop : Stop VOLTHA on the current system"
David K. Bainbridge03ad7412018-01-19 16:41:38 -0800179 @echo "tag : Tag a set of images"
180 @echo "push : Push the docker images to an external repository"
181 @echo "pull : Pull the docker images from a repository"
ggowdru9974f212017-06-06 23:31:25 -0700182 @echo
Nathan Knuth5157de02016-09-16 15:20:37 -0700183
Nathan Knuth84dfd2e2016-09-16 15:06:34 -0700184## New directories can be added here
185DIRS:=\
Nathan Knuthedc88da2016-09-17 00:28:05 -0700186voltha/northbound/openflow \
187voltha/northbound/openflow/agent \
188voltha/northbound/openflow/oftest
Nathan Knuth84dfd2e2016-09-16 15:06:34 -0700189
190## If one directory depends on another directory that
191## dependency can be expressed here
192##
193## For example, if the Tibit directory depended on the eoam
194## directory being built first, then that can be expressed here.
195## driver/tibit: eoam
196
197# Parallel Build
198$(DIRS):
199 @echo " MK $@"
200 $(Q)$(MAKE) -C $@
201
202# Parallel Clean
203DIRS_CLEAN = $(addsuffix .clean,$(DIRS))
204$(DIRS_CLEAN):
205 @echo " CLEAN $(basename $@)"
206 $(Q)$(MAKE) -C $(basename $@) clean
207
208# Parallel Flake8
209DIRS_FLAKE8 = $(addsuffix .flake8,$(DIRS))
210$(DIRS_FLAKE8):
211 @echo " FLAKE8 $(basename $@)"
Nathan Knuth950dff22016-09-17 16:12:34 -0700212 -$(Q)$(MAKE) -C $(basename $@) flake8
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -0700213
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800214build: protoc protos go-builder containers
Zsolt Haraszti32dda552016-09-27 09:17:29 -0700215
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800216production: protoc protos go-builder prod-containers
Sergio Slobodrian7a7091c2017-06-21 23:45:45 -0400217
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800218jenkins: build
khenaidoofe874ae2017-07-14 18:07:27 -0400219
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800220jenkins-containers: base voltha ofagent netconf consul cli envoy fluentd unum j2
Sergio Slobodrian7a7091c2017-06-21 23:45:45 -0400221
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800222prod-containers: base voltha ofagent netconf shovel onos dashd cli grafana consul tools envoy fluentd unum j2
Sergio Slobodrian7a7091c2017-06-21 23:45:45 -0400223
Stephane Barbarie35595062018-02-08 08:34:39 -0500224containers: base voltha ofagent netconf shovel onos tester config-push dashd cli portainer grafana nginx consul tools envoy fluentd unum ponsim j2 test_runner
Khen Nursimuluaaac7ee2016-12-11 22:03:52 -0500225
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800226base:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800227 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-base:${TAG} -f docker/Dockerfile.base .
Zsolt Haraszti51af3392016-09-10 22:18:45 -0700228
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800229ifneq ($(VOLTHA_BUILD),docker)
Shad Ansari83777cb2017-06-02 14:56:08 -0700230voltha: voltha-adapters
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800231 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-voltha:${TAG} -f docker/Dockerfile.voltha .
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800232else
233voltha:
234 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-voltha:${TAG} -f docker/Dockerfile.voltha_d .
235endif
Zsolt Harasztidb892332017-01-09 11:08:38 -0800236
Shad Ansari83777cb2017-06-02 14:56:08 -0700237voltha-adapters:
238 make -C voltha/adapters/asfvolt16_olt
239
Zsolt Harasztidb892332017-01-09 11:08:38 -0800240ofagent:
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800241ifneq ($(VOLTHA_BUILD),docker)
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800242 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-ofagent:${TAG} -f docker/Dockerfile.ofagent .
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800243else
244 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-ofagent:${TAG} -f docker/Dockerfile.ofagent_d .
245endif
Zsolt Harasztidb892332017-01-09 11:08:38 -0800246
Sergio Slobodriancab0a392017-07-13 08:42:10 -0400247tools:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800248 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-tools:${TAG} -f docker/Dockerfile.tools .
Sergio Slobodriancab0a392017-07-13 08:42:10 -0400249
sathishgb5d1c182017-07-13 14:20:19 +0530250fluentd:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800251 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-fluentd:${TAG} -f docker/Dockerfile.fluentd .
sathishgb5d1c182017-07-13 14:20:19 +0530252
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800253envoy: envoyd
254ifneq ($(VOLTHA_BUILD),docker)
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800255 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-envoy:${TAG} -f docker/Dockerfile.envoy .
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800256else
257 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-envoy:${TAG} -f docker/Dockerfile.envoy_d .
258endif
Sergio Slobodriancab0a392017-07-13 08:42:10 -0400259
Sergio Slobodrianbe829272017-07-17 14:45:45 -0400260envoyd:
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800261ifneq ($(VOLTHA_BUILD),docker)
Sergio Slobodrian6570c742017-08-07 23:11:33 -0400262 make -C envoy
Sergio Slobodrianbe829272017-07-17 14:45:45 -0400263 make -C envoy/go/envoyd
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800264endif
Sergio Slobodrianbe829272017-07-17 14:45:45 -0400265
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800266go-builder:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800267 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 -0400268
Zsolt Harasztidb892332017-01-09 11:08:38 -0800269netconf:
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800270ifneq ($(VOLTHA_BUILD),docker)
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800271 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-netconf:${TAG} -f docker/Dockerfile.netconf .
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800272else
273 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-netconf:${TAG} -f docker/Dockerfile.netconf_d .
274endif
Zsolt Harasztidb892332017-01-09 11:08:38 -0800275
Stephane Barbarie14088962017-06-01 16:56:55 -0400276netopeer:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800277 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-netopeer:${TAG} -f docker/Dockerfile.netopeer .
Stephane Barbarie14088962017-06-01 16:56:55 -0400278
Zsolt Harasztidb892332017-01-09 11:08:38 -0800279shovel:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800280 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-shovel:${TAG} -f docker/Dockerfile.shovel .
Zsolt Harasztidb892332017-01-09 11:08:38 -0800281
Sergio Slobodrian9358bd42017-03-10 22:52:24 -0500282dashd:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800283 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-dashd:${TAG} -f docker/Dockerfile.dashd .
Sergio Slobodrian9358bd42017-03-10 22:52:24 -0500284
David K. Bainbridgebba65ff2018-01-19 09:26:09 -0800285cli:
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-cli:${TAG} -f docker/Dockerfile.cli .
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800288else
289 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-cli:${TAG} -f docker/Dockerfile.cli_d .
290endif
Sergio Slobodrianab11c642017-04-24 07:16:58 -0400291
Sergio Slobodrian4d307102017-04-24 10:19:00 -0400292portainer:
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800293ifneq ($(VOLTHA_BUILD),docker)
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800294 REGISTRY=${REGISTRY} REPOSITORY=${REPOSITORY} TAG=${TAG} portainer/buildPortainer.sh
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800295else
296 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-portainer:${TAG} -f docker/Dockerfile.portainer_d .
297endif
Sergio Slobodrian4d307102017-04-24 10:19:00 -0400298
Sergio Slobodrianff52e1b2017-04-24 12:39:08 -0400299nginx:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800300 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-nginx:${TAG} -f docker/Dockerfile.nginx .
Sergio Slobodrianff52e1b2017-04-24 12:39:08 -0400301
schowdhury40739212017-06-12 07:40:31 -0700302consul:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800303 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-consul:${TAG} -f docker/Dockerfile.consul .
schowdhury40739212017-06-12 07:40:31 -0700304
Sergio Slobodrianff52e1b2017-04-24 12:39:08 -0400305grafana:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800306 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-grafana:${TAG} -f docker/Dockerfile.grafana .
Sergio Slobodrianff52e1b2017-04-24 12:39:08 -0400307
Zsolt Harasztidb892332017-01-09 11:08:38 -0800308onos:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800309 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-onos:${TAG} -f docker/Dockerfile.onos docker
Zsolt Harasztidb892332017-01-09 11:08:38 -0800310
David K. Bainbridge215e0242017-09-05 23:18:24 -0700311unum:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800312 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-unum:${TAG} -f unum/Dockerfile ./unum
David K. Bainbridge215e0242017-09-05 23:18:24 -0700313
alshabib5e180572017-01-10 23:59:47 -0600314tester:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800315 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-tester:${TAG} -f docker/Dockerfile.tester docker
alshabib5e180572017-01-10 23:59:47 -0600316
alshabiba5514082017-03-31 11:08:27 -0500317config-push:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800318 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-config-push:${TAG} -f docker/Dockerfile.configpush docker
alshabiba5514082017-03-31 11:08:27 -0500319
Stephane Barbarie95507c42017-09-19 10:41:04 -0400320opennms:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800321 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-opennms:${TAG} -f docker/Dockerfile.opennms .
Stephane Barbarie95507c42017-09-19 10:41:04 -0400322
323logstash:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800324 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-logstash:${TAG} -f docker/Dockerfile.logstash .
David K. Bainbridgebba65ff2018-01-19 09:26:09 -0800325
Stephane Barbarie35595062018-02-08 08:34:39 -0500326ponsim:
327 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-ponsim:${TAG} -f docker/Dockerfile.ponsim .
328
David K. Bainbridgebba65ff2018-01-19 09:26:09 -0800329j2:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800330 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-j2:${TAG} -f docker/Dockerfile.j2 docker
David K. Bainbridgebba65ff2018-01-19 09:26:09 -0800331
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800332test_runner:
333ifeq ($(VOLTHA_BUILD),docker)
334 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-test_runner:${TAG} -f docker/Dockerfile.test_runner .
335endif
336
Jonathan Hart2dd29dd2018-02-08 17:18:28 -0800337@MAKE_ENV := $(shell echo '$(.VARIABLES)' | awk -v RS=' ' '/^[a-zA-Z0-9]+$$/')
338@SHELL_EXPORT := $(foreach v,$(MAKE_ENV),$(v)='$($(v))')
David K. Bainbridgebba65ff2018-01-19 09:26:09 -0800339start:
Jonathan Hart2dd29dd2018-02-08 17:18:28 -0800340 $(SHELL_EXPORT) STACK_TEMPLATE=./compose/voltha-stack.yml.j2 ./scripts/run-voltha.sh start
341
David K. Bainbridgebba65ff2018-01-19 09:26:09 -0800342stop:
Jonathan Hart2dd29dd2018-02-08 17:18:28 -0800343 ./scripts/run-voltha.sh stop
Sergio Slobodrianff52e1b2017-04-24 12:39:08 -0400344
David K. Bainbridge03ad7412018-01-19 16:41:38 -0800345tag: $(patsubst %,%.tag,$(DOCKER_IMAGE_LIST))
346
347push: tag $(patsubst %,%.push,$(DOCKER_IMAGE_LIST))
348
349pull: $(patsubst %,%.pull,$(DOCKER_IMAGE_LIST))
350
351%.tag:
352 docker tag ${REGISTRY}${REPOSITORY}voltha-$(subst .tag,,$@):${TAG} ${TARGET_REGISTRY}${TARGET_REPOSITORY}voltha-$(subst .tag,,$@):${TARGET_TAG}
353
354%.push:
355 docker push ${TARGET_REGISTRY}${TARGET_REPOSITORY}voltha-$(subst .push,,$@):${TARGET_TAG}
356
357%.pull:
358 docker pull ${REGISTRY}${REPOSITORY}voltha-$(subst .pull,,$@):${TAG}
359
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800360protoc:
361ifeq ($(VOLTHA_BUILD),docker)
362 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-protoc:${TAG} -f docker/Dockerfile.protoc .
363endif
364
Zsolt Haraszti5cd64702016-09-27 13:48:35 -0700365protos:
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800366ifneq ($(VOLTHA_BUILD),docker)
Zsolt Haraszti5cd64702016-09-27 13:48:35 -0700367 make -C voltha/protos
Zsolt Haraszti023ea7c2016-10-16 19:30:34 -0700368 make -C ofagent/protos
Khen Nursimuluaaac7ee2016-12-11 22:03:52 -0500369 make -C netconf/protos
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800370else
371 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-protos:${TAG} -f docker/Dockerfile.protos .
372endif
Zsolt Harasztia54f2ac2016-09-21 15:54:15 -0700373
374install-protoc:
Zsolt Haraszti5cd64702016-09-27 13:48:35 -0700375 make -C voltha/protos install-protoc
Zsolt Harasztia54f2ac2016-09-21 15:54:15 -0700376
Zsolt Harasztib71c2a02016-09-12 13:12:07 -0700377clean:
378 find voltha -name '*.pyc' | xargs rm -f
379
Nathan Knutha6b09e32016-09-21 16:26:09 -0700380distclean: clean
381 rm -rf ${VENVDIR}
382
Zsolt Haraszti51af3392016-09-10 22:18:45 -0700383fetch:
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800384 @bash -c ' \
385 for i in $(FETCH_IMAGE_LIST); do \
386 docker pull $$i; \
387 done'
388
389fetch-jenkins: fetch
Zsolt Haraszti51af3392016-09-10 22:18:45 -0700390
391purge-venv:
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -0700392 rm -fr ${VENVDIR}
Zsolt Haraszti51af3392016-09-10 22:18:45 -0700393
394rebuild-venv: purge-venv venv
395
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800396ifneq ($(VOLTHA_BUILD),docker)
Zsolt Haraszti51af3392016-09-10 22:18:45 -0700397venv: ${VENVDIR}/.built
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800398else
399venv:
400endif
Zsolt Haraszti51af3392016-09-10 22:18:45 -0700401
402${VENVDIR}/.built:
403 @ virtualenv ${VENVDIR}
404 @ . ${VENVDIR}/bin/activate && \
Zsolt Haraszti41612482016-09-21 12:26:20 -0700405 pip install --upgrade pip; \
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -0700406 if ! pip install -r requirements.txt; \
407 then \
408 echo "On MAC OS X, if the installation failed with an error \n'<openssl/opensslv.h>': file not found,"; \
409 echo "see the BUILD.md file for a workaround"; \
Zsolt Haraszti51af3392016-09-10 22:18:45 -0700410 else \
Zsolt Haraszti41612482016-09-21 12:26:20 -0700411 uname -s > ${VENVDIR}/.built; \
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -0700412 fi
413
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800414ifneq ($(VOLTHA_BUILD),docker)
Khen Nursimulu34e7ebb2016-11-10 13:38:44 -0800415test: venv protos run-as-root-tests
416 @ echo "Executing all tests"
417 . ${VENVDIR}/bin/activate && \
418 nosetests -s tests \
419 --exclude-dir=./tests/itests/run_as_root/
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800420else
421test: protos test_runner run-as-root-tests
422 docker run \
423 -e VOLTHA_BUILD=docker \
424 -e REGISTRY=${REGISTRY} \
425 -e REPOSITORY=${REPOSITORY} \
426 -e TAG=${TAG} \
427 -e DOCKER_HOST_IP=${DOCKER_HOST_IP} \
428 --rm --net=host -v /var/run/docker.sock:/var/run/docker.sock \
429 ${REGISTRY}${REPSOITORY}voltha-test_runner:${TAG} \
430 nosetests -s tests --exclude-dir=./tests/itests/run_as_root/
431endif
Khen Nursimulu34e7ebb2016-11-10 13:38:44 -0800432
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800433ifneq ($(VOLTHA_BUILD),docker)
Zsolt Haraszti66186622016-11-08 14:24:00 -0800434utest: venv protos
Zsolt Haraszti51af3392016-09-10 22:18:45 -0700435 @ echo "Executing all unit tests"
436 . ${VENVDIR}/bin/activate && \
Kim Kempf8c2812c2017-10-23 15:07:50 -0700437 for d in $$(find ./tests/utests -type d|sort -nr); do echo $$d:; nosetests $$d; done
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800438else
439utest: protos test_runner
440 docker run \
441 -e VOLTHA_BUILD=docker \
442 -e REGISTRY=${REGISTRY} \
443 -e REPOSITORY=${REPOSITORY} \
444 -e TAG=${TAG} \
445 -e DOCKER_HOST_IP=${DOCKER_HOST_IP} \
446 --rm --net=host -v /var/run/docker.sock:/var/run/docker.sock \
447 ${REGISTRY}${REPSOITORY}voltha-test_runner:${TAG} \
448 bash -c \
449 'for d in $$(find ./tests/utests -type d|sort -nr); do \
450 echo $$d:; \
451 nosetests $$d; \
452 done'
453endif
alshabib29a3ed52017-01-23 14:29:21 -0800454
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800455ifneq ($(VOLTHA_BUILD),docker)
alshabib29a3ed52017-01-23 14:29:21 -0800456utest-with-coverage: venv protos
457 @ echo "Executing all unit tests and producing coverage results"
458 . ${VENVDIR}/bin/activate && \
Kim Kempf8c2812c2017-10-23 15:07:50 -0700459 for d in $$(find ./tests/utests -type d|sort -nr); do echo $$d:; \
khenaidoo079a7762017-10-26 21:42:05 -0400460 nosetests --with-xcoverage --with-xunit --cover-package=voltha,common,ofagent $$d; done
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800461else
462utest-with-coverage: protos test_runner
463 @echo "Executing all unit tests and producing coverage results"
464 docker run \
465 -e VOLTHA_BUILD=docker \
466 -e REGISTRY=${REGISTRY} \
467 -e REPOSITORY=${REPOSITORY} \
468 -e TAG=${TAG} \
469 -e DOCKER_HOST_IP=${DOCKER_HOST_IP} \
470 --rm --net=host -v /var/run/docker.sock:/var/run/docker.sock \
471 ${REGISTRY}${REPSOITORY}voltha-test_runner:${TAG} \
472 bash -c \
473 'for d in $$(find ./tests/utests -type d|sort -nr); do \
474 echo $$d:; \
475 nosetests --with-xcoverage --with-xunit --cover-package=voltha,common,ofagent $$d; \
476 done'
477endif
Khen Nursimulu37a9bf82016-10-16 20:11:31 -0400478
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800479ifneq ($(VOLTHA_BUILD),docker)
Zsolt Haraszti348d1932016-12-10 01:10:07 -0800480itest: venv run-as-root-tests
Khen Nursimulu34e7ebb2016-11-10 13:38:44 -0800481 @ echo "Executing all integration tests"
482 . ${VENVDIR}/bin/activate && \
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800483 rm -rf /tmp/fluentd/* && \
484 REGISTRY=${REGISTRY} \
485 REPOSITORY=${REPOSITORY} \
486 TAG=${TAG} \
487 DOCKER_HOST_IP=${DOCKER_HOST_IP} \
Khen Nursimulu34e7ebb2016-11-10 13:38:44 -0800488 nosetests -s \
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800489 tests/itests/docutests/build_md_test.py \
490 --exclude-dir=./tests/utests/ \
491 --exclude-dir=./tests/itests/run_as_root/
492else
493itest: protos test_runner
494 @ echo "Executing all integration tests"
495 docker run \
496 -e VOLTHA_BUILD=docker \
497 -e REGISTRY=${REGISTRY} \
498 -e REPOSITORY=${REPOSITORY} \
499 -e TAG=${TAG} \
500 -e DOCKER_HOST_IP=${DOCKER_HOST_IP} \
501 --rm --net=host -v /var/run/docker.sock:/var/run/docker.sock \
502 ${REGISTRY}${REPSOITORY}voltha-test_runner:${TAG} \
503 nosetests -s \
504 tests/itests/docutests/build_md_test.py \
505 --exclude-dir=./tests/utests/ \
506 --exclude-dir=./tests/itests/run_as_root/
507endif
Khen Nursimulu34e7ebb2016-11-10 13:38:44 -0800508
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800509ifneq ($(VOLTHA_BUILD),docker)
Zsolt Haraszti348d1932016-12-10 01:10:07 -0800510smoke-test: venv run-as-root-tests
Khen Nursimulu34e7ebb2016-11-10 13:38:44 -0800511 @ echo "Executing smoke tests"
Khen Nursimulu96bb5322016-11-09 20:16:03 -0800512 . ${VENVDIR}/bin/activate && \
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800513 rm -rf /tmp/fluentd/* && \
514 REGISTRY=${REGISTRY} \
515 REPOSITORY=${REPOSITORY} \
516 TAG=${TAG} \
517 DOCKER_HOST_IP=${DOCKER_HOST_IP} \
Khen Nursimulu96bb5322016-11-09 20:16:03 -0800518 nosetests -s \
519 tests/itests/docutests/build_md_test.py:BuildMdTests.test_07_start_all_containers \
Khen Nursimulu34e7ebb2016-11-10 13:38:44 -0800520 --exclude-dir=./tests/itests/run_as_root/
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800521else
522smoke-test: protos test_runner run-as-root-tests
523 @ echo "Executing smoke tests"
524 docker run \
525 -e VOLTHA_BUILD=docker \
526 -e REGISTRY=${REGISTRY} \
527 -e REPOSITORY=${REPOSITORY} \
528 -e TAG=${TAG} \
529 -e DOCKER_HOST_IP=${DOCKER_HOST_IP} \
530 --rm --net=host -v /var/run/docker.sock:/var/run/docker.sock \
531 ${REGISTRY}${REPSOITORY}voltha-test_runner:${TAG} \
532 nosetests -s \
533 tests/itests/docutests/build_md_test.py:BuildMdTests.test_07_start_all_containers \
534 --exclude-dir=./tests/itests/run_as_root/
535endif
Khen Nursimulu96bb5322016-11-09 20:16:03 -0800536
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800537ifneq ($(VOLTHA_BUILD),docker)
khenaidoo1243ee92017-07-17 15:54:06 -0400538jenkins-test: venv
539 @ echo "Executing jenkins smoke tests"
540 . ${VENVDIR}/bin/activate && \
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800541 rm -rf /tmp/fluentd/* && \
542 REGISTRY=${REGISTRY} \
543 REPOSITORY=${REPOSITORY} \
544 TAG=${TAG} \
545 DOCKER_HOST_IP=${DOCKER_HOST_IP} \
khenaidoo1243ee92017-07-17 15:54:06 -0400546 nosetests -s \
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800547 tests/itests/docutests/build_md_test.py:BuildMdTests.test_07_start_all_containers \
548 --exclude-dir=./tests/itests/run_as_root/
549else
550jenkins-test: protos test_runner
551 @ echo "Executing jenkins smoke tests"
552 @ echo "Starting VOLTHA as docker-compose services"
553 docker run \
554 -e REGISTRY=${REGISTRY} \
555 -e REPOSITORY=${REPOSITORY} \
556 -e TAG=${TAG} \
557 -e DOCKER_HOST_IP=${DOCKER_HOST_IP} \
558 --rm --net=host -v /var/run/docker.sock:/var/run/docker.sock \
559 ${REGISTRY}${REPSOITORY}voltha-test_runner:${TAG} \
560 nosetests -s \
561 tests/itests/docutests/build_md_test.py:BuildMdTests.test_07_start_all_containers \
562 --exclude-dir=./tests/itests/run_as_root/
563endif
khenaidoo1243ee92017-07-17 15:54:06 -0400564
David K. Bainbridge10a7a7e2018-01-29 09:54:40 -0800565ifneq ($(VOLTHA_BUILD),docker)
Khen Nursimulu34e7ebb2016-11-10 13:38:44 -0800566run-as-root-tests:
David K. Bainbridge737b74f2018-01-22 12:57:52 -0800567 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 -0800568else
569run-as-root-tests:
570 docker run \
571 -e VOLTHA_BUILD=docker \
572 -e REGISTRY=${REGISTRY} \
573 -e REPOSITORY=${REPOSITORY} \
574 -e TAG=${TAG} \
575 -e DOCKER_HOST_IP=${DOCKER_HOST_IP} \
576 --rm --privileged \
577 ${REGISTRY}${REPOSITORY}voltha-test_runner:${TAG} \
578 env PYTHONPATH=/work python tests/itests/run_as_root/test_frameio.py
579endif
Nathan Knuth84dfd2e2016-09-16 15:06:34 -0700580
581flake8: $(DIRS_FLAKE8)
Nathan Knuth220a6772016-10-11 08:10:46 -0700582
583# end file