blob: d9b70fb157619766144cadf68ad3a20bf5106242 [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))
32DOCKER_LABEL_VCS_REF ?= $(shell git diff-index --quiet HEAD -- && git rev-parse HEAD || echo "unknown")
33DOCKER_LABEL_COMMIT_DATE ?= $(shell git diff-index --quiet HEAD -- && git show -s --format=%cd --date=iso-strict HEAD || echo "unknown" )
34DOCKER_LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ")
35
36.PHONY: docker-build
37
38# This should to be the first and default target in this Makefile
39help:
40 @echo "Usage: make [<target>]"
41 @echo "where available targets are:"
42 @echo
43 @echo "build : Build the onos docker image with olt apps built-in"
44 @echo "help : Print this help"
45 @echo "docker-push : Push the docker images to an external repository"
46 @echo "clean : Delete any locally copied oar files in local_imports"
47 @echo
48
49
50## Docker targets
51
52build: docker-build
53
54local-onosapps:
55 mkdir -p local_imports/oar
56ifdef LOCAL_ONOSAPPS
57 ./get-local-oars.sh
58endif
59
60docker-build: local-onosapps
61 docker build $(DOCKER_BUILD_ARGS) \
62 -t ${ONOS_IMAGENAME} \
63 --build-arg LOCAL_ONOSAPPS=$(LOCAL_ONOSAPPS) \
64 --build-arg org_label_schema_version="${VERSION}" \
65 --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \
66 --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \
67 --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \
68 --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \
69 -f Dockerfile.voltha-onos .
70
71docker-push:
72 docker push ${ONOS_IMAGENAME}
73
74clean:
75 rm -rf local_imports
76
77# end file