blob: 1cba5c37719233521d941939d6d00c36c7f175e3 [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. Bainbridgeda617722018-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. Bainbridgeda617722018-01-29 09:54:40 -080021endif
Nathan Knuthedc88da2016-09-17 00:28:05 -070022
David K. Bainbridge12463052018-01-19 09:26:09 -080023ifeq ($(TAG),)
24TAG := latest
25endif
26
David K. Bainbridge52c25df2018-01-19 16:41:38 -080027ifeq ($(TARGET_TAG),)
28TARGET_TAG := latest
29endif
30
David K. Bainbridgeda617722018-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 Droogenbroeckcb3507d2017-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. Bainbridgeda617722018-01-29 09:54:40 -080051
52DOCKER_BUILD_ARGS = \
53 --build-arg TAG=$(TAG) \
David K. Bainbridge3d5b22d2018-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 Droogenbroeckcb3507d2017-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. Bainbridge52c25df2018-01-19 16:41:38 -080062DOCKER_IMAGE_LIST = \
63 base \
David K. Bainbridgeda617722018-01-29 09:54:40 -080064 protoc \
65 protos \
David K. Bainbridge52c25df2018-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 \
82 tester \
83 config-push \
David K. Bainbridgeda617722018-01-29 09:54:40 -080084 j2 \
85 test_runner
David K. Bainbridge52c25df2018-01-19 16:41:38 -080086
David K. Bainbridgeda617722018-01-29 09:54:40 -080087# The following list was scavanged from the compose / stack files as well as
88# from the Dockerfiles. If nothing else it highlights that VOLTHA is not
89# using consistent versions for some of the containers.
90
91# 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'
92FETCH_BUILD_IMAGE_LIST = \
93 alpine:3.6 \
94 centos:7 \
95 centurylink/ca-certs:latest \
96 consul:0.9.2 \
97 debian:stretch-slim \
98 docker.elastic.co/logstash/logstash:5.6.0 \
99 fluent/fluentd:v0.12.42 \
100 gliderlabs/registrator:v7 \
101 golang:1.9.2 \
102 grpc/python:latest \
103 kamon/grafana_graphite:3.0 \
104 lyft/envoy:29361deae91575a1d46c7a21e913f19e75622ebe \
105 maven:3-jdk-8-alpine \
106 onosproject/onos:1.10.9 \
107 opennms/horizon-core-web:19.0.1-1 \
108 portainer/portainer:1.15.2 \
109 ubuntu:xenial
110
111# 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'
112FETCH_COMPOSE_IMAGE_LIST = \
113 consul:0.9.2 \
114 docker.elastic.co/elasticsearch/elasticsearch:5.6.0 \
115 fluent/fluentd:latest \
116 fluent/fluentd:v0.12.42 \
117 gliderlabs/registrator:latest \
118 kamon/grafana_graphite:latest \
119 marcelmaatkamp/freeradius:latest \
120 postgres:9.6.1 \
121 quay.io/coreos/etcd:v3.2.9 \
122 registry:2 \
123 tianon/true:latest \
124 wurstmeister/kafka:latest \
125 wurstmeister/zookeeper:latest
126
127# 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'
128# Manually remove some image from this list as they don't reflect the new
129# naming conventions for the VOLTHA build
130FETCH_K8S_IMAGE_LIST = \
131 consul:0.9.2 \
132 quay.io/coreos/etcd-operator:v0.7.2 \
133 wurstmeister/kafka:1.0.0 \
134 zookeeper:3.4.11
135
136FETCH_IMAGE_LIST = $(shell echo $(FETCH_BUILD_IMAGE_LIST) $(FETCH_COMPOSE_IMAGE_LIST) $(FETCH_K8S_IMAGE_LIST) | tr ' ' '\n' | sort -u)
137
138.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 start stop tag push pull
Nathan Knuth84dfd2e2016-09-16 15:06:34 -0700139
ggowdru9974f212017-06-06 23:31:25 -0700140# This should to be the first and default target in this Makefile
141help:
142 @echo "Usage: make [<target>]"
143 @echo "where available targets are:"
144 @echo
145 @echo "build : Build the Voltha protos and docker images.\n\
146 If this is the first time you are building, choose \"make build\" option."
Sergio Slobodrian7a7091c2017-06-21 23:45:45 -0400147 @echo "production : Build voltha for production deployment"
ggowdru9974f212017-06-06 23:31:25 -0700148 @echo "clean : Remove files created by the build and tests"
149 @echo "distclean : Remove venv directory"
150 @echo "fetch : Pre-fetch artifacts for subsequent local builds"
151 @echo "flake8 : Run specifically flake8 tests"
152 @echo "help : Print this help"
David K. Bainbridgeda617722018-01-29 09:54:40 -0800153 @echo "protoc : Build a container with protoc installed"
ggowdru9974f212017-06-06 23:31:25 -0700154 @echo "protos : Compile all grpc/protobuf files"
155 @echo "rebuild-venv : Rebuild local Python virtualenv from scratch"
156 @echo "venv : Build local Python virtualenv if did not exist yet"
157 @echo "utest : Run all unit tests"
158 @echo "itest : Run all integration tests"
159 @echo "containers : Build all the docker containers"
David K. Bainbridgeda617722018-01-29 09:54:40 -0800160 @echo "base : Build the base docker container used by all other dockers"
ggowdru9974f212017-06-06 23:31:25 -0700161 @echo "voltha : Build the voltha docker container"
ggowdru9974f212017-06-06 23:31:25 -0700162 @echo "ofagent : Build the ofagent docker container"
ggowdru9974f212017-06-06 23:31:25 -0700163 @echo "netconf : Build the netconf docker container"
164 @echo "shovel : Build the shovel docker container"
165 @echo "onos : Build the onos docker container"
166 @echo "dashd : Build the dashd docker container"
David K. Bainbridge12463052018-01-19 09:26:09 -0800167 @echo "cli : Build the cli docker container"
ggowdru9974f212017-06-06 23:31:25 -0700168 @echo "portainer : Build the portainer docker container"
169 @echo "grafana : Build the grafana docker container"
170 @echo "nginx : Build the nginx docker container"
schowdhury40739212017-06-12 07:40:31 -0700171 @echo "consul : Build the consul docker container"
David K. Bainbridge215e0242017-09-05 23:18:24 -0700172 @echo "unum : Build the unum docker container"
David K. Bainbridge12463052018-01-19 09:26:09 -0800173 @echo "j2 : Build the Jinja2 template container"
David K. Bainbridgeda617722018-01-29 09:54:40 -0800174 @echo "test_runner : Build a container from which tests are run"
David K. Bainbridge12463052018-01-19 09:26:09 -0800175 @echo "start : Start VOLTHA on the current system"
176 @echo "stop : Stop VOLTHA on the current system"
David K. Bainbridge52c25df2018-01-19 16:41:38 -0800177 @echo "tag : Tag a set of images"
178 @echo "push : Push the docker images to an external repository"
179 @echo "pull : Pull the docker images from a repository"
ggowdru9974f212017-06-06 23:31:25 -0700180 @echo
Nathan Knuth5157de02016-09-16 15:20:37 -0700181
Nathan Knuth84dfd2e2016-09-16 15:06:34 -0700182## New directories can be added here
183DIRS:=\
Nathan Knuthedc88da2016-09-17 00:28:05 -0700184voltha/northbound/openflow \
185voltha/northbound/openflow/agent \
186voltha/northbound/openflow/oftest
Nathan Knuth84dfd2e2016-09-16 15:06:34 -0700187
188## If one directory depends on another directory that
189## dependency can be expressed here
190##
191## For example, if the Tibit directory depended on the eoam
192## directory being built first, then that can be expressed here.
193## driver/tibit: eoam
194
195# Parallel Build
196$(DIRS):
197 @echo " MK $@"
198 $(Q)$(MAKE) -C $@
199
200# Parallel Clean
201DIRS_CLEAN = $(addsuffix .clean,$(DIRS))
202$(DIRS_CLEAN):
203 @echo " CLEAN $(basename $@)"
204 $(Q)$(MAKE) -C $(basename $@) clean
205
206# Parallel Flake8
207DIRS_FLAKE8 = $(addsuffix .flake8,$(DIRS))
208$(DIRS_FLAKE8):
209 @echo " FLAKE8 $(basename $@)"
Nathan Knuth950dff22016-09-17 16:12:34 -0700210 -$(Q)$(MAKE) -C $(basename $@) flake8
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -0700211
David K. Bainbridgeda617722018-01-29 09:54:40 -0800212build: protoc protos go-builder containers
Zsolt Haraszti32dda552016-09-27 09:17:29 -0700213
David K. Bainbridgeda617722018-01-29 09:54:40 -0800214production: protoc protos go-builder prod-containers
Sergio Slobodrian7a7091c2017-06-21 23:45:45 -0400215
David K. Bainbridgeda617722018-01-29 09:54:40 -0800216jenkins: build
khenaidoofe874ae2017-07-14 18:07:27 -0400217
David K. Bainbridgeda617722018-01-29 09:54:40 -0800218jenkins-containers: base voltha ofagent netconf consul cli envoy fluentd unum j2
Sergio Slobodrian7a7091c2017-06-21 23:45:45 -0400219
David K. Bainbridgeda617722018-01-29 09:54:40 -0800220prod-containers: base voltha ofagent netconf shovel onos dashd cli grafana consul tools envoy fluentd unum j2
Sergio Slobodrian7a7091c2017-06-21 23:45:45 -0400221
David K. Bainbridgeda617722018-01-29 09:54:40 -0800222containers: base voltha ofagent netconf shovel onos tester config-push dashd cli portainer grafana nginx consul tools envoy fluentd unum j2 test_runner
Khen Nursimuluaaac7ee2016-12-11 22:03:52 -0500223
David K. Bainbridgeda617722018-01-29 09:54:40 -0800224base:
David K. Bainbridge3d5b22d2018-01-22 12:57:52 -0800225 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-base:${TAG} -f docker/Dockerfile.base .
Zsolt Haraszti51af3392016-09-10 22:18:45 -0700226
David K. Bainbridgeda617722018-01-29 09:54:40 -0800227ifneq ($(VOLTHA_BUILD),docker)
Shad Ansari83777cb2017-06-02 14:56:08 -0700228voltha: voltha-adapters
David K. Bainbridge3d5b22d2018-01-22 12:57:52 -0800229 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-voltha:${TAG} -f docker/Dockerfile.voltha .
David K. Bainbridgeda617722018-01-29 09:54:40 -0800230else
231voltha:
232 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-voltha:${TAG} -f docker/Dockerfile.voltha_d .
233endif
Zsolt Harasztidb892332017-01-09 11:08:38 -0800234
Shad Ansari83777cb2017-06-02 14:56:08 -0700235voltha-adapters:
236 make -C voltha/adapters/asfvolt16_olt
237
Zsolt Harasztidb892332017-01-09 11:08:38 -0800238ofagent:
David K. Bainbridgeda617722018-01-29 09:54:40 -0800239ifneq ($(VOLTHA_BUILD),docker)
David K. Bainbridge3d5b22d2018-01-22 12:57:52 -0800240 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-ofagent:${TAG} -f docker/Dockerfile.ofagent .
David K. Bainbridgeda617722018-01-29 09:54:40 -0800241else
242 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-ofagent:${TAG} -f docker/Dockerfile.ofagent_d .
243endif
Zsolt Harasztidb892332017-01-09 11:08:38 -0800244
Sergio Slobodriancab0a392017-07-13 08:42:10 -0400245tools:
David K. Bainbridge3d5b22d2018-01-22 12:57:52 -0800246 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-tools:${TAG} -f docker/Dockerfile.tools .
Sergio Slobodriancab0a392017-07-13 08:42:10 -0400247
sathishgb5d1c182017-07-13 14:20:19 +0530248fluentd:
David K. Bainbridge3d5b22d2018-01-22 12:57:52 -0800249 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-fluentd:${TAG} -f docker/Dockerfile.fluentd .
sathishgb5d1c182017-07-13 14:20:19 +0530250
David K. Bainbridgeda617722018-01-29 09:54:40 -0800251envoy: envoyd
252ifneq ($(VOLTHA_BUILD),docker)
David K. Bainbridge3d5b22d2018-01-22 12:57:52 -0800253 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-envoy:${TAG} -f docker/Dockerfile.envoy .
David K. Bainbridgeda617722018-01-29 09:54:40 -0800254else
255 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-envoy:${TAG} -f docker/Dockerfile.envoy_d .
256endif
Sergio Slobodriancab0a392017-07-13 08:42:10 -0400257
Sergio Slobodrianbe829272017-07-17 14:45:45 -0400258envoyd:
David K. Bainbridgeda617722018-01-29 09:54:40 -0800259ifneq ($(VOLTHA_BUILD),docker)
Sergio Slobodrian6570c742017-08-07 23:11:33 -0400260 make -C envoy
Sergio Slobodrianbe829272017-07-17 14:45:45 -0400261 make -C envoy/go/envoyd
David K. Bainbridgeda617722018-01-29 09:54:40 -0800262endif
Sergio Slobodrianbe829272017-07-17 14:45:45 -0400263
David K. Bainbridgeda617722018-01-29 09:54:40 -0800264go-builder:
David K. Bainbridge3d5b22d2018-01-22 12:57:52 -0800265 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 -0400266
Zsolt Harasztidb892332017-01-09 11:08:38 -0800267netconf:
David K. Bainbridgeda617722018-01-29 09:54:40 -0800268ifneq ($(VOLTHA_BUILD),docker)
David K. Bainbridge3d5b22d2018-01-22 12:57:52 -0800269 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-netconf:${TAG} -f docker/Dockerfile.netconf .
David K. Bainbridgeda617722018-01-29 09:54:40 -0800270else
271 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-netconf:${TAG} -f docker/Dockerfile.netconf_d .
272endif
Zsolt Harasztidb892332017-01-09 11:08:38 -0800273
Stephane Barbarie14088962017-06-01 16:56:55 -0400274netopeer:
David K. Bainbridge3d5b22d2018-01-22 12:57:52 -0800275 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-netopeer:${TAG} -f docker/Dockerfile.netopeer .
Stephane Barbarie14088962017-06-01 16:56:55 -0400276
Zsolt Harasztidb892332017-01-09 11:08:38 -0800277shovel:
David K. Bainbridge3d5b22d2018-01-22 12:57:52 -0800278 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-shovel:${TAG} -f docker/Dockerfile.shovel .
Zsolt Harasztidb892332017-01-09 11:08:38 -0800279
Sergio Slobodrian9358bd42017-03-10 22:52:24 -0500280dashd:
David K. Bainbridge3d5b22d2018-01-22 12:57:52 -0800281 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-dashd:${TAG} -f docker/Dockerfile.dashd .
Sergio Slobodrian9358bd42017-03-10 22:52:24 -0500282
David K. Bainbridge12463052018-01-19 09:26:09 -0800283cli:
David K. Bainbridgeda617722018-01-29 09:54:40 -0800284ifneq ($(VOLTHA_BUILD),docker)
David K. Bainbridge3d5b22d2018-01-22 12:57:52 -0800285 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-cli:${TAG} -f docker/Dockerfile.cli .
David K. Bainbridgeda617722018-01-29 09:54:40 -0800286else
287 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-cli:${TAG} -f docker/Dockerfile.cli_d .
288endif
Sergio Slobodrianab11c642017-04-24 07:16:58 -0400289
Sergio Slobodrian4d307102017-04-24 10:19:00 -0400290portainer:
David K. Bainbridgeda617722018-01-29 09:54:40 -0800291ifneq ($(VOLTHA_BUILD),docker)
David K. Bainbridge3d5b22d2018-01-22 12:57:52 -0800292 REGISTRY=${REGISTRY} REPOSITORY=${REPOSITORY} TAG=${TAG} portainer/buildPortainer.sh
David K. Bainbridgeda617722018-01-29 09:54:40 -0800293else
294 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-portainer:${TAG} -f docker/Dockerfile.portainer_d .
295endif
Sergio Slobodrian4d307102017-04-24 10:19:00 -0400296
Sergio Slobodrianff52e1b2017-04-24 12:39:08 -0400297nginx:
David K. Bainbridge3d5b22d2018-01-22 12:57:52 -0800298 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-nginx:${TAG} -f docker/Dockerfile.nginx .
Sergio Slobodrianff52e1b2017-04-24 12:39:08 -0400299
schowdhury40739212017-06-12 07:40:31 -0700300consul:
David K. Bainbridge3d5b22d2018-01-22 12:57:52 -0800301 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-consul:${TAG} -f docker/Dockerfile.consul .
schowdhury40739212017-06-12 07:40:31 -0700302
Sergio Slobodrianff52e1b2017-04-24 12:39:08 -0400303grafana:
David K. Bainbridge3d5b22d2018-01-22 12:57:52 -0800304 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-grafana:${TAG} -f docker/Dockerfile.grafana .
Sergio Slobodrianff52e1b2017-04-24 12:39:08 -0400305
Zsolt Harasztidb892332017-01-09 11:08:38 -0800306onos:
David K. Bainbridge3d5b22d2018-01-22 12:57:52 -0800307 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-onos:${TAG} -f docker/Dockerfile.onos docker
Zsolt Harasztidb892332017-01-09 11:08:38 -0800308
David K. Bainbridge215e0242017-09-05 23:18:24 -0700309unum:
David K. Bainbridge3d5b22d2018-01-22 12:57:52 -0800310 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-unum:${TAG} -f unum/Dockerfile ./unum
David K. Bainbridge215e0242017-09-05 23:18:24 -0700311
alshabib5e180572017-01-10 23:59:47 -0600312tester:
David K. Bainbridge3d5b22d2018-01-22 12:57:52 -0800313 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-tester:${TAG} -f docker/Dockerfile.tester docker
alshabib5e180572017-01-10 23:59:47 -0600314
alshabiba5514082017-03-31 11:08:27 -0500315config-push:
David K. Bainbridge3d5b22d2018-01-22 12:57:52 -0800316 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-config-push:${TAG} -f docker/Dockerfile.configpush docker
alshabiba5514082017-03-31 11:08:27 -0500317
Stephane Barbarie95507c42017-09-19 10:41:04 -0400318opennms:
David K. Bainbridge3d5b22d2018-01-22 12:57:52 -0800319 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-opennms:${TAG} -f docker/Dockerfile.opennms .
Stephane Barbarie95507c42017-09-19 10:41:04 -0400320
321logstash:
David K. Bainbridge3d5b22d2018-01-22 12:57:52 -0800322 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-logstash:${TAG} -f docker/Dockerfile.logstash .
David K. Bainbridge12463052018-01-19 09:26:09 -0800323
324j2:
David K. Bainbridge3d5b22d2018-01-22 12:57:52 -0800325 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-j2:${TAG} -f docker/Dockerfile.j2 docker
David K. Bainbridge12463052018-01-19 09:26:09 -0800326
David K. Bainbridgeda617722018-01-29 09:54:40 -0800327test_runner:
328ifeq ($(VOLTHA_BUILD),docker)
329 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-test_runner:${TAG} -f docker/Dockerfile.test_runner .
330endif
331
David K. Bainbridge12463052018-01-19 09:26:09 -0800332start:
333 bash -c 'echo $$VOLTHA_LOGS && TMP_STACK_FILE=$$(mktemp -u) && \
334 echo $$TMP_STACK_FILE && \
335 SWARM_MANAGER_COUNT=$$(docker node ls | grep Ready | egrep "(Leader)|(Reachable)" | wc -l | sed -e "s/ //g") && \
David K. Bainbridge3d5b22d2018-01-22 12:57:52 -0800336 cat ./compose/voltha-stack.yml.j2 2>&1 | docker run -e RADIUS_ROOT=$$RADIUS_ROOT -e CONSUL_ROOT=$$CONSUL_ROOT -e VOLTHA_LOGS=$$VOLTHA_LOGS -e SWARM_MANAGER_COUNT=$$SWARM_MANAGER_COUNT --rm -i ${REGISTRY}${REPOSITORY}voltha-j2:${TAG} - 2>&1 > $$TMP_STACK_FILE && \
David K. Bainbridge12463052018-01-19 09:26:09 -0800337 docker stack deploy -c $$TMP_STACK_FILE voltha && \
338 rm -f $$TMP_STACK_FILE'
339
340stop:
341 docker stack rm voltha
Sergio Slobodrianff52e1b2017-04-24 12:39:08 -0400342
David K. Bainbridge52c25df2018-01-19 16:41:38 -0800343tag: $(patsubst %,%.tag,$(DOCKER_IMAGE_LIST))
344
345push: tag $(patsubst %,%.push,$(DOCKER_IMAGE_LIST))
346
347pull: $(patsubst %,%.pull,$(DOCKER_IMAGE_LIST))
348
349%.tag:
350 docker tag ${REGISTRY}${REPOSITORY}voltha-$(subst .tag,,$@):${TAG} ${TARGET_REGISTRY}${TARGET_REPOSITORY}voltha-$(subst .tag,,$@):${TARGET_TAG}
351
352%.push:
353 docker push ${TARGET_REGISTRY}${TARGET_REPOSITORY}voltha-$(subst .push,,$@):${TARGET_TAG}
354
355%.pull:
356 docker pull ${REGISTRY}${REPOSITORY}voltha-$(subst .pull,,$@):${TAG}
357
David K. Bainbridgeda617722018-01-29 09:54:40 -0800358protoc:
359ifeq ($(VOLTHA_BUILD),docker)
360 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-protoc:${TAG} -f docker/Dockerfile.protoc .
361endif
362
Zsolt Haraszti5cd64702016-09-27 13:48:35 -0700363protos:
David K. Bainbridgeda617722018-01-29 09:54:40 -0800364ifneq ($(VOLTHA_BUILD),docker)
Zsolt Haraszti5cd64702016-09-27 13:48:35 -0700365 make -C voltha/protos
Zsolt Haraszti023ea7c2016-10-16 19:30:34 -0700366 make -C ofagent/protos
Khen Nursimuluaaac7ee2016-12-11 22:03:52 -0500367 make -C netconf/protos
David K. Bainbridgeda617722018-01-29 09:54:40 -0800368else
369 docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-protos:${TAG} -f docker/Dockerfile.protos .
370endif
Zsolt Harasztia54f2ac2016-09-21 15:54:15 -0700371
372install-protoc:
Zsolt Haraszti5cd64702016-09-27 13:48:35 -0700373 make -C voltha/protos install-protoc
Zsolt Harasztia54f2ac2016-09-21 15:54:15 -0700374
Zsolt Harasztib71c2a02016-09-12 13:12:07 -0700375clean:
376 find voltha -name '*.pyc' | xargs rm -f
377
Nathan Knutha6b09e32016-09-21 16:26:09 -0700378distclean: clean
379 rm -rf ${VENVDIR}
380
Zsolt Haraszti51af3392016-09-10 22:18:45 -0700381fetch:
David K. Bainbridgeda617722018-01-29 09:54:40 -0800382 @bash -c ' \
383 for i in $(FETCH_IMAGE_LIST); do \
384 docker pull $$i; \
385 done'
386
387fetch-jenkins: fetch
Zsolt Haraszti51af3392016-09-10 22:18:45 -0700388
389purge-venv:
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -0700390 rm -fr ${VENVDIR}
Zsolt Haraszti51af3392016-09-10 22:18:45 -0700391
392rebuild-venv: purge-venv venv
393
David K. Bainbridgeda617722018-01-29 09:54:40 -0800394ifneq ($(VOLTHA_BUILD),docker)
Zsolt Haraszti51af3392016-09-10 22:18:45 -0700395venv: ${VENVDIR}/.built
David K. Bainbridgeda617722018-01-29 09:54:40 -0800396else
397venv:
398endif
Zsolt Haraszti51af3392016-09-10 22:18:45 -0700399
400${VENVDIR}/.built:
401 @ virtualenv ${VENVDIR}
402 @ . ${VENVDIR}/bin/activate && \
Zsolt Haraszti41612482016-09-21 12:26:20 -0700403 pip install --upgrade pip; \
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -0700404 if ! pip install -r requirements.txt; \
405 then \
406 echo "On MAC OS X, if the installation failed with an error \n'<openssl/opensslv.h>': file not found,"; \
407 echo "see the BUILD.md file for a workaround"; \
Zsolt Haraszti51af3392016-09-10 22:18:45 -0700408 else \
Zsolt Haraszti41612482016-09-21 12:26:20 -0700409 uname -s > ${VENVDIR}/.built; \
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -0700410 fi
411
David K. Bainbridgeda617722018-01-29 09:54:40 -0800412ifneq ($(VOLTHA_BUILD),docker)
Khen Nursimulu34e7ebb2016-11-10 13:38:44 -0800413test: venv protos run-as-root-tests
414 @ echo "Executing all tests"
415 . ${VENVDIR}/bin/activate && \
416 nosetests -s tests \
417 --exclude-dir=./tests/itests/run_as_root/
David K. Bainbridgeda617722018-01-29 09:54:40 -0800418else
419test: protos test_runner run-as-root-tests
420 docker run \
421 -e VOLTHA_BUILD=docker \
422 -e REGISTRY=${REGISTRY} \
423 -e REPOSITORY=${REPOSITORY} \
424 -e TAG=${TAG} \
425 -e DOCKER_HOST_IP=${DOCKER_HOST_IP} \
426 --rm --net=host -v /var/run/docker.sock:/var/run/docker.sock \
427 ${REGISTRY}${REPSOITORY}voltha-test_runner:${TAG} \
428 nosetests -s tests --exclude-dir=./tests/itests/run_as_root/
429endif
Khen Nursimulu34e7ebb2016-11-10 13:38:44 -0800430
David K. Bainbridgeda617722018-01-29 09:54:40 -0800431ifneq ($(VOLTHA_BUILD),docker)
Zsolt Haraszti66186622016-11-08 14:24:00 -0800432utest: venv protos
Zsolt Haraszti51af3392016-09-10 22:18:45 -0700433 @ echo "Executing all unit tests"
434 . ${VENVDIR}/bin/activate && \
Kim Kempf8c2812c2017-10-23 15:07:50 -0700435 for d in $$(find ./tests/utests -type d|sort -nr); do echo $$d:; nosetests $$d; done
David K. Bainbridgeda617722018-01-29 09:54:40 -0800436else
437utest: protos test_runner
438 docker run \
439 -e VOLTHA_BUILD=docker \
440 -e REGISTRY=${REGISTRY} \
441 -e REPOSITORY=${REPOSITORY} \
442 -e TAG=${TAG} \
443 -e DOCKER_HOST_IP=${DOCKER_HOST_IP} \
444 --rm --net=host -v /var/run/docker.sock:/var/run/docker.sock \
445 ${REGISTRY}${REPSOITORY}voltha-test_runner:${TAG} \
446 bash -c \
447 'for d in $$(find ./tests/utests -type d|sort -nr); do \
448 echo $$d:; \
449 nosetests $$d; \
450 done'
451endif
alshabib29a3ed52017-01-23 14:29:21 -0800452
David K. Bainbridgeda617722018-01-29 09:54:40 -0800453ifneq ($(VOLTHA_BUILD),docker)
alshabib29a3ed52017-01-23 14:29:21 -0800454utest-with-coverage: venv protos
455 @ echo "Executing all unit tests and producing coverage results"
456 . ${VENVDIR}/bin/activate && \
Kim Kempf8c2812c2017-10-23 15:07:50 -0700457 for d in $$(find ./tests/utests -type d|sort -nr); do echo $$d:; \
khenaidoo079a7762017-10-26 21:42:05 -0400458 nosetests --with-xcoverage --with-xunit --cover-package=voltha,common,ofagent $$d; done
David K. Bainbridgeda617722018-01-29 09:54:40 -0800459else
460utest-with-coverage: protos test_runner
461 @echo "Executing all unit tests and producing coverage results"
462 docker run \
463 -e VOLTHA_BUILD=docker \
464 -e REGISTRY=${REGISTRY} \
465 -e REPOSITORY=${REPOSITORY} \
466 -e TAG=${TAG} \
467 -e DOCKER_HOST_IP=${DOCKER_HOST_IP} \
468 --rm --net=host -v /var/run/docker.sock:/var/run/docker.sock \
469 ${REGISTRY}${REPSOITORY}voltha-test_runner:${TAG} \
470 bash -c \
471 'for d in $$(find ./tests/utests -type d|sort -nr); do \
472 echo $$d:; \
473 nosetests --with-xcoverage --with-xunit --cover-package=voltha,common,ofagent $$d; \
474 done'
475endif
Khen Nursimulu37a9bf82016-10-16 20:11:31 -0400476
David K. Bainbridgeda617722018-01-29 09:54:40 -0800477ifneq ($(VOLTHA_BUILD),docker)
Zsolt Haraszti348d1932016-12-10 01:10:07 -0800478itest: venv run-as-root-tests
Khen Nursimulu34e7ebb2016-11-10 13:38:44 -0800479 @ echo "Executing all integration tests"
480 . ${VENVDIR}/bin/activate && \
David K. Bainbridgeda617722018-01-29 09:54:40 -0800481 rm -rf /tmp/fluentd/* && \
482 REGISTRY=${REGISTRY} \
483 REPOSITORY=${REPOSITORY} \
484 TAG=${TAG} \
485 DOCKER_HOST_IP=${DOCKER_HOST_IP} \
Khen Nursimulu34e7ebb2016-11-10 13:38:44 -0800486 nosetests -s \
David K. Bainbridgeda617722018-01-29 09:54:40 -0800487 tests/itests/docutests/build_md_test.py \
488 --exclude-dir=./tests/utests/ \
489 --exclude-dir=./tests/itests/run_as_root/
490else
491itest: protos test_runner
492 @ echo "Executing all integration tests"
493 docker run \
494 -e VOLTHA_BUILD=docker \
495 -e REGISTRY=${REGISTRY} \
496 -e REPOSITORY=${REPOSITORY} \
497 -e TAG=${TAG} \
498 -e DOCKER_HOST_IP=${DOCKER_HOST_IP} \
499 --rm --net=host -v /var/run/docker.sock:/var/run/docker.sock \
500 ${REGISTRY}${REPSOITORY}voltha-test_runner:${TAG} \
501 nosetests -s \
502 tests/itests/docutests/build_md_test.py \
503 --exclude-dir=./tests/utests/ \
504 --exclude-dir=./tests/itests/run_as_root/
505endif
Khen Nursimulu34e7ebb2016-11-10 13:38:44 -0800506
David K. Bainbridgeda617722018-01-29 09:54:40 -0800507ifneq ($(VOLTHA_BUILD),docker)
Zsolt Haraszti348d1932016-12-10 01:10:07 -0800508smoke-test: venv run-as-root-tests
Khen Nursimulu34e7ebb2016-11-10 13:38:44 -0800509 @ echo "Executing smoke tests"
Khen Nursimulu96bb5322016-11-09 20:16:03 -0800510 . ${VENVDIR}/bin/activate && \
David K. Bainbridgeda617722018-01-29 09:54:40 -0800511 rm -rf /tmp/fluentd/* && \
512 REGISTRY=${REGISTRY} \
513 REPOSITORY=${REPOSITORY} \
514 TAG=${TAG} \
515 DOCKER_HOST_IP=${DOCKER_HOST_IP} \
Khen Nursimulu96bb5322016-11-09 20:16:03 -0800516 nosetests -s \
517 tests/itests/docutests/build_md_test.py:BuildMdTests.test_07_start_all_containers \
Khen Nursimulu34e7ebb2016-11-10 13:38:44 -0800518 --exclude-dir=./tests/itests/run_as_root/
David K. Bainbridgeda617722018-01-29 09:54:40 -0800519else
520smoke-test: protos test_runner run-as-root-tests
521 @ echo "Executing smoke tests"
522 docker run \
523 -e VOLTHA_BUILD=docker \
524 -e REGISTRY=${REGISTRY} \
525 -e REPOSITORY=${REPOSITORY} \
526 -e TAG=${TAG} \
527 -e DOCKER_HOST_IP=${DOCKER_HOST_IP} \
528 --rm --net=host -v /var/run/docker.sock:/var/run/docker.sock \
529 ${REGISTRY}${REPSOITORY}voltha-test_runner:${TAG} \
530 nosetests -s \
531 tests/itests/docutests/build_md_test.py:BuildMdTests.test_07_start_all_containers \
532 --exclude-dir=./tests/itests/run_as_root/
533endif
Khen Nursimulu96bb5322016-11-09 20:16:03 -0800534
David K. Bainbridgeda617722018-01-29 09:54:40 -0800535ifneq ($(VOLTHA_BUILD),docker)
khenaidoo1243ee92017-07-17 15:54:06 -0400536jenkins-test: venv
537 @ echo "Executing jenkins smoke tests"
538 . ${VENVDIR}/bin/activate && \
David K. Bainbridgeda617722018-01-29 09:54:40 -0800539 rm -rf /tmp/fluentd/* && \
540 REGISTRY=${REGISTRY} \
541 REPOSITORY=${REPOSITORY} \
542 TAG=${TAG} \
543 DOCKER_HOST_IP=${DOCKER_HOST_IP} \
khenaidoo1243ee92017-07-17 15:54:06 -0400544 nosetests -s \
David K. Bainbridgeda617722018-01-29 09:54:40 -0800545 tests/itests/docutests/build_md_test.py:BuildMdTests.test_07_start_all_containers \
546 --exclude-dir=./tests/itests/run_as_root/
547else
548jenkins-test: protos test_runner
549 @ echo "Executing jenkins smoke tests"
550 @ echo "Starting VOLTHA as docker-compose services"
551 docker run \
552 -e REGISTRY=${REGISTRY} \
553 -e REPOSITORY=${REPOSITORY} \
554 -e TAG=${TAG} \
555 -e DOCKER_HOST_IP=${DOCKER_HOST_IP} \
556 --rm --net=host -v /var/run/docker.sock:/var/run/docker.sock \
557 ${REGISTRY}${REPSOITORY}voltha-test_runner:${TAG} \
558 nosetests -s \
559 tests/itests/docutests/build_md_test.py:BuildMdTests.test_07_start_all_containers \
560 --exclude-dir=./tests/itests/run_as_root/
561endif
khenaidoo1243ee92017-07-17 15:54:06 -0400562
David K. Bainbridgeda617722018-01-29 09:54:40 -0800563ifneq ($(VOLTHA_BUILD),docker)
Khen Nursimulu34e7ebb2016-11-10 13:38:44 -0800564run-as-root-tests:
David K. Bainbridge3d5b22d2018-01-22 12:57:52 -0800565 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. Bainbridgeda617722018-01-29 09:54:40 -0800566else
567run-as-root-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 --privileged \
575 ${REGISTRY}${REPOSITORY}voltha-test_runner:${TAG} \
576 env PYTHONPATH=/work python tests/itests/run_as_root/test_frameio.py
577endif
Nathan Knuth84dfd2e2016-09-16 15:06:34 -0700578
579flake8: $(DIRS_FLAKE8)
Nathan Knuth220a6772016-10-11 08:10:46 -0700580
581# end file