Shad Ansari | d365451 | 2021-09-29 10:31:53 -0700 | [diff] [blame] | 1 | # |
Shad Ansari | 47432b6 | 2021-09-27 22:46:25 +0000 | [diff] [blame] | 2 | # SPDX-FileCopyrightText: 2020-present Open Networking Foundation <info@opennetworking.org> |
| 3 | # SPDX-License-Identifier: LicenseRef-ONF-Member-1.01 |
| 4 | # |
| 5 | define PROJECT_HELP_MSG |
| 6 | Usage: |
| 7 | make help show this message |
| 8 | make clean remove intermediate files |
Shad Ansari | 55ff185 | 2021-09-27 20:05:54 +0000 | [diff] [blame] | 9 | |
Shad Ansari | 47432b6 | 2021-09-27 22:46:25 +0000 | [diff] [blame] | 10 | make ${VENV} make a virtualenv in the base directory |
| 11 | make python-reqs install python packages in requirements.pip |
| 12 | make git-config set local git configuration |
| 13 | make setup make python-reqs |
| 14 | |
| 15 | make run launch network-video-recorder |
| 16 | make run-native run native application (no docker) |
| 17 | make run-native-no-show run native applicaiton (no docker) w/o video output |
| 18 | endef |
| 19 | export PROJECT_HELP_MSG |
| 20 | |
Shad Ansari | 5aa7346 | 2021-10-04 21:43:07 -0700 | [diff] [blame] | 21 | SHELL = bash -eu -o pipefail |
| 22 | |
| 23 | VERSION ?= $(shell cat ./VERSION) |
| 24 | #CONTAINER_NAME ?= person-detection-app |
| 25 | CONTAINER_NAME ?= $(notdir $(abspath .)) |
| 26 | |
| 27 | DOCKER_REGISTRY ?= |
| 28 | DOCKER_REPOSITORY ?= |
| 29 | DOCKER_BUILD_ARGS ?= --rm --force-rm |
| 30 | DOCKER_TAG ?= ${VERSION} |
| 31 | DOCKER_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}${CONTAINER_NAME}:${DOCKER_TAG} |
| 32 | |
| 33 | DOCKER_LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote)) |
| 34 | DOCKER_LABEL_VCS_REF ?= $(shell git diff-index --quiet HEAD -- && git rev-parse HEAD || echo "unknown") |
| 35 | DOCKER_LABEL_COMMIT_DATE ?= $(shell git diff-index --quiet HEAD -- && git show -s --format=%cd --date=iso-strict HEAD || echo "unknown" ) |
| 36 | DOCKER_LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ") |
| 37 | |
Shad Ansari | 47432b6 | 2021-09-27 22:46:25 +0000 | [diff] [blame] | 38 | VENV = .venv |
| 39 | PYTHON = $(VENV)/bin/python3 |
| 40 | PIP = $(VENV)/bin/pip |
Shad Ansari | 47432b6 | 2021-09-27 22:46:25 +0000 | [diff] [blame] | 41 | |
Shad Ansari | 2948cc0 | 2022-04-14 21:33:37 +0000 | [diff] [blame^] | 42 | ROC_USER ?= |
| 43 | ROC_PASSWD ?= |
| 44 | ROC_URL ?= |
| 45 | KEYCLOAK ?= |
| 46 | ENTERPRISE ?= |
| 47 | SITE ?= |
| 48 | DEVICEGROUP ?= |
| 49 | |
Shad Ansari | 5aa7346 | 2021-10-04 21:43:07 -0700 | [diff] [blame] | 50 | all: test |
Shad Ansari | b5808d7 | 2021-10-04 12:43:27 -0700 | [diff] [blame] | 51 | |
Shad Ansari | 47432b6 | 2021-09-27 22:46:25 +0000 | [diff] [blame] | 52 | help: |
| 53 | echo "$$PROJECT_HELP_MSG" | less |
| 54 | |
Shad Ansari | 47432b6 | 2021-09-27 22:46:25 +0000 | [diff] [blame] | 55 | $(VENV): $(VENV)/touchfile |
| 56 | |
| 57 | $(VENV)/touchfile: requirements.txt |
| 58 | test -d $(VENV) || python3 -m venv $(VENV) |
| 59 | . $(VENV)/bin/activate; pip install -Ur requirements.txt |
| 60 | touch $(VENV)/touchfile |
| 61 | |
| 62 | $(VENV)/bin/activate: requirements.txt |
| 63 | python3 -m venv $(VENV) |
| 64 | $(PIP) install -r requirements.txt |
| 65 | |
Shad Ansari | ae90d25 | 2021-10-22 16:40:29 +0000 | [diff] [blame] | 66 | freeze: |
| 67 | pip3 freeze | grep -v "pkg-resources" > requirements.txt |
| 68 | |
Shad Ansari | 5aa7346 | 2021-10-04 21:43:07 -0700 | [diff] [blame] | 69 | docker-build: $(VENV) |
| 70 | docker build $(DOCKER_BUILD_ARGS) \ |
| 71 | -t $(DOCKER_IMAGENAME) \ |
| 72 | --build-arg org_label_schema_version="${VERSION}" \ |
| 73 | --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \ |
| 74 | --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \ |
| 75 | --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \ |
| 76 | --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \ |
| 77 | -f docker/Dockerfile . |
Shad Ansari | 47432b6 | 2021-09-27 22:46:25 +0000 | [diff] [blame] | 78 | |
Shad Ansari | 5aa7346 | 2021-10-04 21:43:07 -0700 | [diff] [blame] | 79 | docker-push: |
| 80 | docker push $(DOCKER_IMAGENAME) |
| 81 | |
Shad Ansari | 2948cc0 | 2022-04-14 21:33:37 +0000 | [diff] [blame^] | 82 | docker-run : |
Shad Ansari | 5aa7346 | 2021-10-04 21:43:07 -0700 | [diff] [blame] | 83 | docker run \ |
| 84 | -itu root:root \ |
| 85 | --privileged \ |
| 86 | --network host \ |
| 87 | --name $(CONTAINER_NAME) \ |
| 88 | --rm \ |
Shad Ansari | 2948cc0 | 2022-04-14 21:33:37 +0000 | [diff] [blame^] | 89 | $(DOCKER_IMAGENAME) \ |
| 90 | --url $(ROC_URL) \ |
| 91 | --keycloak $(KEYCLOAK) \ |
| 92 | --enterprise $(ENTERPRISE) \ |
| 93 | --site $(SITE) \ |
| 94 | --devicegroup $(DEVICEGROUP) \ |
| 95 | --user $(ROC_USER) --password $(ROC_PASSWD) |
Shad Ansari | 47432b6 | 2021-09-27 22:46:25 +0000 | [diff] [blame] | 96 | |
Shad Ansari | 341ca3a | 2021-09-30 12:10:00 -0700 | [diff] [blame] | 97 | run-native-file: $(VENV) |
Shad Ansari | d80531f | 2021-09-27 23:15:03 +0000 | [diff] [blame] | 98 | . ./bin/person_detection.sh -i ./resources/run.mp4 |
Shad Ansari | 47432b6 | 2021-09-27 22:46:25 +0000 | [diff] [blame] | 99 | |
Shad Ansari | 341ca3a | 2021-09-30 12:10:00 -0700 | [diff] [blame] | 100 | run-native-gstream: $(VENV) |
Shad Ansari | d80531f | 2021-09-27 23:15:03 +0000 | [diff] [blame] | 101 | . ./bin/person_detection.sh -i gstreamer |
Shad Ansari | 47432b6 | 2021-09-27 22:46:25 +0000 | [diff] [blame] | 102 | |
Shad Ansari | d365451 | 2021-09-29 10:31:53 -0700 | [diff] [blame] | 103 | run-native-cam: $(VENV) |
Shad Ansari | 0119b42 | 2021-09-27 23:51:49 +0000 | [diff] [blame] | 104 | . ./bin/person_detection.sh -i cam |
| 105 | |
Shad Ansari | b5808d7 | 2021-10-04 12:43:27 -0700 | [diff] [blame] | 106 | lint: |
| 107 | flake8 --exclude=.tox person_detection |
| 108 | |
Shad Ansari | 5aa7346 | 2021-10-04 21:43:07 -0700 | [diff] [blame] | 109 | test: docker-build |
Shad Ansari | 47432b6 | 2021-09-27 22:46:25 +0000 | [diff] [blame] | 110 | |
| 111 | |
| 112 | CLEANUP = *.pyc $(VENV) |
| 113 | clean: |
| 114 | rm -rf ${CLEANUP} |
| 115 | |
| 116 | .PHONY: run clean |
| 117 | |