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