blob: d54f4f457695ed938d60bc6ea42ca507cd2db2ec [file] [log] [blame]
Matt Jeanneretc7b437c2019-05-13 12:33:08 -04001#
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
17# set default shell
18SHELL = bash -e -o pipefail
19
20# Variables
21VERSION ?= $(shell cat ./VERSION)
22
23## Docker related
24DOCKER_REGISTRY ?=
25DOCKER_REPOSITORY ?=
26DOCKER_BUILD_ARGS ?=
27DOCKER_TAG ?= ${VERSION}
28ONOS_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}voltha-onos:${DOCKER_TAG}
29
30## Docker labels. Only set ref and commit date if committed
31DOCKER_LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote))
Matt Jeanneretc7b437c2019-05-13 12:33:08 -040032DOCKER_LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ")
Matt Jeanneret805f76e2019-05-16 16:18:26 -040033DOCKER_LABEL_COMMIT_DATE = $(shell git show -s --format=%cd --date=iso-strict HEAD)
34
35ifeq ($(shell git ls-files --others --modified --exclude-standard 2>/dev/null | wc -l | sed -e 's/ //g'),0)
36 DOCKER_LABEL_VCS_REF = $(shell git rev-parse HEAD)
37else
38 DOCKER_LABEL_VCS_REF = $(shell git rev-parse HEAD)+dirty
39endif
Matt Jeanneretc7b437c2019-05-13 12:33:08 -040040
41.PHONY: docker-build
42
43# This should to be the first and default target in this Makefile
44help:
45 @echo "Usage: make [<target>]"
46 @echo "where available targets are:"
47 @echo
48 @echo "build : Build the onos docker image with olt apps built-in"
49 @echo "help : Print this help"
50 @echo "docker-push : Push the docker images to an external repository"
51 @echo "clean : Delete any locally copied oar files in local_imports"
52 @echo
53
54
55## Docker targets
56
57build: docker-build
58
59local-onosapps:
60 mkdir -p local_imports/oar
61ifdef LOCAL_ONOSAPPS
62 ./get-local-oars.sh
63endif
64
65docker-build: local-onosapps
66 docker build $(DOCKER_BUILD_ARGS) \
67 -t ${ONOS_IMAGENAME} \
68 --build-arg LOCAL_ONOSAPPS=$(LOCAL_ONOSAPPS) \
69 --build-arg org_label_schema_version="${VERSION}" \
70 --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \
71 --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \
72 --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \
73 --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \
74 -f Dockerfile.voltha-onos .
75
76docker-push:
77 docker push ${ONOS_IMAGENAME}
78
79clean:
80 rm -rf local_imports
81
82# end file