Joey Armstrong | 695ba5c | 2023-01-20 11:17:49 -0500 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # ----------------------------------------------------------------------- |
| 3 | # Copyright 2016-2023 Open Networking Foundation (ONF) and the ONF Contributors |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
Joey Armstrong | 695ba5c | 2023-01-20 11:17:49 -0500 | [diff] [blame] | 16 | # ----------------------------------------------------------------------- |
| 17 | |
| 18 | .PHONY: help |
| 19 | .DEFAULT_GOAL := help |
| 20 | |
Joey Armstrong | 695ba5c | 2023-01-20 11:17:49 -0500 | [diff] [blame] | 21 | ##--------------------## |
| 22 | ##---] INCLUDES [---## |
| 23 | ##--------------------## |
Joey Armstrong | 99a72d0 | 2023-06-09 10:26:42 -0400 | [diff] [blame] | 24 | include config.mk |
| 25 | include makefiles/include.mk |
Joey Armstrong | 695ba5c | 2023-01-20 11:17:49 -0500 | [diff] [blame] | 26 | |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 27 | # Variables |
| 28 | VERSION ?= $(shell cat ./VERSION) |
| 29 | |
| 30 | ## Docker related |
| 31 | DOCKER_REGISTRY ?= |
| 32 | DOCKER_REPOSITORY ?= |
| 33 | DOCKER_BUILD_ARGS ?= |
| 34 | DOCKER_TAG ?= ${VERSION} |
| 35 | ONOS_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}voltha-onos:${DOCKER_TAG} |
| 36 | |
| 37 | ## Docker labels. Only set ref and commit date if committed |
| 38 | DOCKER_LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote)) |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 39 | DOCKER_LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ") |
Matt Jeanneret | 805f76e | 2019-05-16 16:18:26 -0400 | [diff] [blame] | 40 | DOCKER_LABEL_COMMIT_DATE = $(shell git show -s --format=%cd --date=iso-strict HEAD) |
| 41 | |
| 42 | ifeq ($(shell git ls-files --others --modified --exclude-standard 2>/dev/null | wc -l | sed -e 's/ //g'),0) |
| 43 | DOCKER_LABEL_VCS_REF = $(shell git rev-parse HEAD) |
| 44 | else |
| 45 | DOCKER_LABEL_VCS_REF = $(shell git rev-parse HEAD)+dirty |
| 46 | endif |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 47 | |
| 48 | .PHONY: docker-build |
| 49 | |
Matteo Scandolo | c209e80 | 2021-06-07 16:59:30 +0200 | [diff] [blame] | 50 | # For each makefile target, add ## <description> on the target line and it will be listed by 'make help' |
Joey Armstrong | 695ba5c | 2023-01-20 11:17:49 -0500 | [diff] [blame] | 51 | help :: ## Print help for each Makefile target |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 52 | @echo |
Joey Armstrong | 695ba5c | 2023-01-20 11:17:49 -0500 | [diff] [blame] | 53 | @grep --no-filename '^[[:alpha:]_-]*:.* ##' $(MAKEFILE_LIST) \ |
| 54 | | sort \ |
| 55 | | awk 'BEGIN {FS=":.* ## "}; {printf " %-25s : %s\n", $$1, $$2};' |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 56 | |
| 57 | ## Docker targets |
| 58 | |
Joey Armstrong | 7c3a1e0 | 2023-07-01 16:21:24 -0400 | [diff] [blame] | 59 | ## ----------------------------------------------------------------------- |
| 60 | ## ----------------------------------------------------------------------- |
Matteo Scandolo | c209e80 | 2021-06-07 16:59:30 +0200 | [diff] [blame] | 61 | build: docker-build ## alias for "docker-build" |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 62 | |
Joey Armstrong | 7c3a1e0 | 2023-07-01 16:21:24 -0400 | [diff] [blame] | 63 | ## ----------------------------------------------------------------------- |
| 64 | ## ----------------------------------------------------------------------- |
Matteo Scandolo | c209e80 | 2021-06-07 16:59:30 +0200 | [diff] [blame] | 65 | local-onosapps: ## if LOCAL_ONOSAPPS=true runs the get-local-oars.sh |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 66 | mkdir -p local_imports/oar |
| 67 | ifdef LOCAL_ONOSAPPS |
Joey Armstrong | 4048c1f | 2022-12-17 22:24:42 -0500 | [diff] [blame] | 68 | $(RM) -r local_imports/oar |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 69 | ./get-local-oars.sh |
| 70 | endif |
| 71 | |
Joey Armstrong | 7c3a1e0 | 2023-07-01 16:21:24 -0400 | [diff] [blame] | 72 | ## ----------------------------------------------------------------------- |
| 73 | ## Intent: build docker image |
| 74 | ## use DOCKER_REGISTRY, DOCKER_REPOSITORY and DOCKER_TAG to customize |
| 75 | ## ----------------------------------------------------------------------- |
| 76 | docker-build: local-onosapps ## build docker image |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 77 | docker build $(DOCKER_BUILD_ARGS) \ |
| 78 | -t ${ONOS_IMAGENAME} \ |
| 79 | --build-arg LOCAL_ONOSAPPS=$(LOCAL_ONOSAPPS) \ |
| 80 | --build-arg org_label_schema_version="${VERSION}" \ |
| 81 | --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \ |
| 82 | --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \ |
| 83 | --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \ |
| 84 | --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \ |
| 85 | -f Dockerfile.voltha-onos . |
| 86 | |
Joey Armstrong | 7c3a1e0 | 2023-07-01 16:21:24 -0400 | [diff] [blame] | 87 | ## ----------------------------------------------------------------------- |
| 88 | ## ----------------------------------------------------------------------- |
Matteo Scandolo | c209e80 | 2021-06-07 16:59:30 +0200 | [diff] [blame] | 89 | test: ## verify that if the version is released we're not pointing to SNAPSHOT apps |
| 90 | bash tests/version-check.sh |
| 91 | |
| 92 | docker-push: ## push to docker registy: use DOCKER_REGISTRY, DOCKER_REPOSITORY and DOCKER_TAG to customize |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 93 | docker push ${ONOS_IMAGENAME} |
| 94 | |
Joey Armstrong | 99a72d0 | 2023-06-09 10:26:42 -0400 | [diff] [blame] | 95 | clean :: ## clean the build environment |
Joey Armstrong | 4048c1f | 2022-12-17 22:24:42 -0500 | [diff] [blame] | 96 | $(RM) -r local_imports |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 97 | |
| 98 | # end file |