blob: 1a2408028989404f714a1a04fde8f6f64c373df9 [file] [log] [blame]
Shad Ansarid3654512021-09-29 10:31:53 -07001#
Shad Ansari47432b62021-09-27 22:46:25 +00002# SPDX-FileCopyrightText: 2020-present Open Networking Foundation <info@opennetworking.org>
3# SPDX-License-Identifier: LicenseRef-ONF-Member-1.01
4#
5define PROJECT_HELP_MSG
6Usage:
7 make help show this message
8 make clean remove intermediate files
Shad Ansari55ff1852021-09-27 20:05:54 +00009
Shad Ansari47432b62021-09-27 22:46:25 +000010 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
18endef
19export PROJECT_HELP_MSG
20
Shad Ansari5aa73462021-10-04 21:43:07 -070021SHELL = bash -eu -o pipefail
22
23VERSION ?= $(shell cat ./VERSION)
24#CONTAINER_NAME ?= person-detection-app
25CONTAINER_NAME ?= $(notdir $(abspath .))
26
27DOCKER_REGISTRY ?=
28DOCKER_REPOSITORY ?=
29DOCKER_BUILD_ARGS ?= --rm --force-rm
30DOCKER_TAG ?= ${VERSION}
31DOCKER_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}${CONTAINER_NAME}:${DOCKER_TAG}
32
33DOCKER_LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote))
34DOCKER_LABEL_VCS_REF ?= $(shell git diff-index --quiet HEAD -- && git rev-parse HEAD || echo "unknown")
35DOCKER_LABEL_COMMIT_DATE ?= $(shell git diff-index --quiet HEAD -- && git show -s --format=%cd --date=iso-strict HEAD || echo "unknown" )
36DOCKER_LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ")
37
Shad Ansari47432b62021-09-27 22:46:25 +000038VENV = .venv
39PYTHON = $(VENV)/bin/python3
40PIP = $(VENV)/bin/pip
Shad Ansari47432b62021-09-27 22:46:25 +000041
Shad Ansari2948cc02022-04-14 21:33:37 +000042ROC_USER ?=
43ROC_PASSWD ?=
44ROC_URL ?=
45KEYCLOAK ?=
46ENTERPRISE ?=
47SITE ?=
48DEVICEGROUP ?=
49
Shad Ansari5aa73462021-10-04 21:43:07 -070050all: test
Shad Ansarib5808d72021-10-04 12:43:27 -070051
Shad Ansari47432b62021-09-27 22:46:25 +000052help:
53 echo "$$PROJECT_HELP_MSG" | less
54
Shad Ansari47432b62021-09-27 22:46:25 +000055$(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 Ansariae90d252021-10-22 16:40:29 +000066freeze:
67 pip3 freeze | grep -v "pkg-resources" > requirements.txt
68
Shad Ansari5aa73462021-10-04 21:43:07 -070069docker-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 Ansari47432b62021-09-27 22:46:25 +000078
Shad Ansari5aa73462021-10-04 21:43:07 -070079docker-push:
80 docker push $(DOCKER_IMAGENAME)
81
Shad Ansari2948cc02022-04-14 21:33:37 +000082docker-run :
Shad Ansari5aa73462021-10-04 21:43:07 -070083 docker run \
84 -itu root:root \
85 --privileged \
86 --network host \
87 --name $(CONTAINER_NAME) \
88 --rm \
Shad Ansari2948cc02022-04-14 21:33:37 +000089 $(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 Ansari47432b62021-09-27 22:46:25 +000096
Shad Ansari341ca3a2021-09-30 12:10:00 -070097run-native-file: $(VENV)
Shad Ansarid80531f2021-09-27 23:15:03 +000098 . ./bin/person_detection.sh -i ./resources/run.mp4
Shad Ansari47432b62021-09-27 22:46:25 +000099
Shad Ansari341ca3a2021-09-30 12:10:00 -0700100run-native-gstream: $(VENV)
Shad Ansarid80531f2021-09-27 23:15:03 +0000101 . ./bin/person_detection.sh -i gstreamer
Shad Ansari47432b62021-09-27 22:46:25 +0000102
Shad Ansarid3654512021-09-29 10:31:53 -0700103run-native-cam: $(VENV)
Shad Ansari0119b422021-09-27 23:51:49 +0000104 . ./bin/person_detection.sh -i cam
105
Shad Ansarib5808d72021-10-04 12:43:27 -0700106lint:
107 flake8 --exclude=.tox person_detection
108
Shad Ansari5aa73462021-10-04 21:43:07 -0700109test: docker-build
Shad Ansari47432b62021-09-27 22:46:25 +0000110
111
112CLEANUP = *.pyc $(VENV)
113clean:
114 rm -rf ${CLEANUP}
115
116.PHONY: run clean
117