blob: 418688a76545f3b38e38267dbb301f1599d06f32 [file] [log] [blame]
Matt Jeanneretc7b437c2019-05-13 12:33:08 -04001#
Joey Armstrong4048c1f2022-12-17 22:24:42 -05002# Copyright 2016-2022 Open Networking Foundation (ONF) and the ONF Contributors
Matt Jeanneretc7b437c2019-05-13 12:33:08 -04003#
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
Matteo Scandoloc209e802021-06-07 16:59:30 +020043# For each makefile target, add ## <description> on the target line and it will be listed by 'make help'
44help: ## Print help for each Makefile target
Matt Jeanneretc7b437c2019-05-13 12:33:08 -040045 @echo "Usage: make [<target>]"
46 @echo "where available targets are:"
47 @echo
Matteo Scandoloc209e802021-06-07 16:59:30 +020048 @grep '^[[:alpha:]_-]*:.* ##' $(MAKEFILE_LIST) \
49 | sort | awk 'BEGIN {FS=":.* ## "}; {printf "%-25s : %s\n", $$1, $$2};'
Matt Jeanneretc7b437c2019-05-13 12:33:08 -040050
51## Docker targets
52
Matteo Scandoloc209e802021-06-07 16:59:30 +020053build: docker-build ## alias for "docker-build"
Matt Jeanneretc7b437c2019-05-13 12:33:08 -040054
Matteo Scandoloc209e802021-06-07 16:59:30 +020055local-onosapps: ## if LOCAL_ONOSAPPS=true runs the get-local-oars.sh
Matt Jeanneretc7b437c2019-05-13 12:33:08 -040056 mkdir -p local_imports/oar
57ifdef LOCAL_ONOSAPPS
Joey Armstrong4048c1f2022-12-17 22:24:42 -050058 $(RM) -r local_imports/oar
Matt Jeanneretc7b437c2019-05-13 12:33:08 -040059 ./get-local-oars.sh
60endif
61
Matteo Scandoloc209e802021-06-07 16:59:30 +020062docker-build: local-onosapps ## build docker image: use DOCKER_REGISTRY, DOCKER_REPOSITORY and DOCKER_TAG to customize
Matt Jeanneretc7b437c2019-05-13 12:33:08 -040063 docker build $(DOCKER_BUILD_ARGS) \
64 -t ${ONOS_IMAGENAME} \
65 --build-arg LOCAL_ONOSAPPS=$(LOCAL_ONOSAPPS) \
66 --build-arg org_label_schema_version="${VERSION}" \
67 --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \
68 --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \
69 --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \
70 --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \
71 -f Dockerfile.voltha-onos .
72
Matteo Scandoloc209e802021-06-07 16:59:30 +020073test: ## verify that if the version is released we're not pointing to SNAPSHOT apps
74 bash tests/version-check.sh
75
76docker-push: ## push to docker registy: use DOCKER_REGISTRY, DOCKER_REPOSITORY and DOCKER_TAG to customize
Matt Jeanneretc7b437c2019-05-13 12:33:08 -040077 docker push ${ONOS_IMAGENAME}
78
Matteo Scandoloc209e802021-06-07 16:59:30 +020079clean: ## clean the build environment
Joey Armstrong4048c1f2022-12-17 22:24:42 -050080 $(RM) -r local_imports
Matt Jeanneretc7b437c2019-05-13 12:33:08 -040081
82# end file