blob: 9beff28ffaf2063366fe2b232c3c0efe60110362 [file] [log] [blame]
Shad Ansarid3654512021-09-29 10:31:53 -07001#
Shad Ansarif53bc4f2022-06-07 14:31:11 -07002# SPDX-FileCopyrightText: 2022-present Intel Corporation
Shad Ansari47432b62021-09-27 22:46:25 +00003# SPDX-FileCopyrightText: 2020-present Open Networking Foundation <info@opennetworking.org>
Shad Ansariea2e1dd2022-06-09 12:37:37 -07004# SPDX-License-Identifier: Apache-2.0
Shad Ansari47432b62021-09-27 22:46:25 +00005#
6define PROJECT_HELP_MSG
7Usage:
8 make help show this message
9 make clean remove intermediate files
Shad Ansari55ff1852021-09-27 20:05:54 +000010
Shad Ansari47432b62021-09-27 22:46:25 +000011 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
19endef
20export PROJECT_HELP_MSG
21
Shad Ansari5aa73462021-10-04 21:43:07 -070022SHELL = bash -eu -o pipefail
23
24VERSION ?= $(shell cat ./VERSION)
25#CONTAINER_NAME ?= person-detection-app
26CONTAINER_NAME ?= $(notdir $(abspath .))
27
28DOCKER_REGISTRY ?=
29DOCKER_REPOSITORY ?=
30DOCKER_BUILD_ARGS ?= --rm --force-rm
31DOCKER_TAG ?= ${VERSION}
32DOCKER_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}${CONTAINER_NAME}:${DOCKER_TAG}
33
34DOCKER_LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote))
35DOCKER_LABEL_VCS_REF ?= $(shell git diff-index --quiet HEAD -- && git rev-parse HEAD || echo "unknown")
36DOCKER_LABEL_COMMIT_DATE ?= $(shell git diff-index --quiet HEAD -- && git show -s --format=%cd --date=iso-strict HEAD || echo "unknown" )
37DOCKER_LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ")
38
Shad Ansari47432b62021-09-27 22:46:25 +000039VENV = .venv
40PYTHON = $(VENV)/bin/python3
41PIP = $(VENV)/bin/pip
Shad Ansari47432b62021-09-27 22:46:25 +000042
Shad Ansari2948cc02022-04-14 21:33:37 +000043ROC_USER ?=
44ROC_PASSWD ?=
45ROC_URL ?=
46KEYCLOAK ?=
47ENTERPRISE ?=
48SITE ?=
49DEVICEGROUP ?=
50
Shad Ansari5aa73462021-10-04 21:43:07 -070051all: test
Shad Ansarib5808d72021-10-04 12:43:27 -070052
Shad Ansari47432b62021-09-27 22:46:25 +000053help:
54 echo "$$PROJECT_HELP_MSG" | less
55
Shad Ansari47432b62021-09-27 22:46:25 +000056$(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 Ansariae90d252021-10-22 16:40:29 +000067freeze:
68 pip3 freeze | grep -v "pkg-resources" > requirements.txt
69
Shad Ansari5aa73462021-10-04 21:43:07 -070070docker-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 Ansari47432b62021-09-27 22:46:25 +000079
Shad Ansari5aa73462021-10-04 21:43:07 -070080docker-push:
81 docker push $(DOCKER_IMAGENAME)
82
Shad Ansari2948cc02022-04-14 21:33:37 +000083docker-run :
Shad Ansari5aa73462021-10-04 21:43:07 -070084 docker run \
85 -itu root:root \
86 --privileged \
87 --network host \
88 --name $(CONTAINER_NAME) \
89 --rm \
Shad Ansari2948cc02022-04-14 21:33:37 +000090 $(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 Ansari47432b62021-09-27 22:46:25 +000097
Shad Ansari341ca3a2021-09-30 12:10:00 -070098run-native-file: $(VENV)
Shad Ansarid80531f2021-09-27 23:15:03 +000099 . ./bin/person_detection.sh -i ./resources/run.mp4
Shad Ansari47432b62021-09-27 22:46:25 +0000100
Shad Ansari341ca3a2021-09-30 12:10:00 -0700101run-native-gstream: $(VENV)
Shad Ansarid80531f2021-09-27 23:15:03 +0000102 . ./bin/person_detection.sh -i gstreamer
Shad Ansari47432b62021-09-27 22:46:25 +0000103
Shad Ansarid3654512021-09-29 10:31:53 -0700104run-native-cam: $(VENV)
Shad Ansari0119b422021-09-27 23:51:49 +0000105 . ./bin/person_detection.sh -i cam
106
Shad Ansarib5808d72021-10-04 12:43:27 -0700107lint:
108 flake8 --exclude=.tox person_detection
109
Shad Ansari5aa73462021-10-04 21:43:07 -0700110test: docker-build
Shad Ansari47432b62021-09-27 22:46:25 +0000111
112
113CLEANUP = *.pyc $(VENV)
114clean:
115 rm -rf ${CLEANUP}
116
117.PHONY: run clean
118