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 | 5aa7346 | 2021-10-04 21:43:07 -0700 | [diff] [blame] | 42 | all: test |
Shad Ansari | b5808d7 | 2021-10-04 12:43:27 -0700 | [diff] [blame] | 43 | |
Shad Ansari | 47432b6 | 2021-09-27 22:46:25 +0000 | [diff] [blame] | 44 | help: |
| 45 | echo "$$PROJECT_HELP_MSG" | less |
| 46 | |
Shad Ansari | 47432b6 | 2021-09-27 22:46:25 +0000 | [diff] [blame] | 47 | $(VENV): $(VENV)/touchfile |
| 48 | |
| 49 | $(VENV)/touchfile: requirements.txt |
| 50 | test -d $(VENV) || python3 -m venv $(VENV) |
| 51 | . $(VENV)/bin/activate; pip install -Ur requirements.txt |
| 52 | touch $(VENV)/touchfile |
| 53 | |
| 54 | $(VENV)/bin/activate: requirements.txt |
| 55 | python3 -m venv $(VENV) |
| 56 | $(PIP) install -r requirements.txt |
| 57 | |
Shad Ansari | 5aa7346 | 2021-10-04 21:43:07 -0700 | [diff] [blame] | 58 | docker-build: $(VENV) |
| 59 | docker build $(DOCKER_BUILD_ARGS) \ |
| 60 | -t $(DOCKER_IMAGENAME) \ |
| 61 | --build-arg org_label_schema_version="${VERSION}" \ |
| 62 | --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \ |
| 63 | --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \ |
| 64 | --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \ |
| 65 | --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \ |
| 66 | -f docker/Dockerfile . |
Shad Ansari | 47432b6 | 2021-09-27 22:46:25 +0000 | [diff] [blame] | 67 | |
Shad Ansari | 5aa7346 | 2021-10-04 21:43:07 -0700 | [diff] [blame] | 68 | docker-push: |
| 69 | docker push $(DOCKER_IMAGENAME) |
| 70 | |
| 71 | docker-run: |
| 72 | docker run \ |
| 73 | -itu root:root \ |
| 74 | --privileged \ |
| 75 | --network host \ |
| 76 | --name $(CONTAINER_NAME) \ |
| 77 | --rm \ |
| 78 | $(DOCKER_IMAGENAME) |
Shad Ansari | 47432b6 | 2021-09-27 22:46:25 +0000 | [diff] [blame] | 79 | |
Shad Ansari | 341ca3a | 2021-09-30 12:10:00 -0700 | [diff] [blame] | 80 | run-native-file: $(VENV) |
Shad Ansari | d80531f | 2021-09-27 23:15:03 +0000 | [diff] [blame] | 81 | . ./bin/person_detection.sh -i ./resources/run.mp4 |
Shad Ansari | 47432b6 | 2021-09-27 22:46:25 +0000 | [diff] [blame] | 82 | |
Shad Ansari | 341ca3a | 2021-09-30 12:10:00 -0700 | [diff] [blame] | 83 | run-native-gstream: $(VENV) |
Shad Ansari | d80531f | 2021-09-27 23:15:03 +0000 | [diff] [blame] | 84 | . ./bin/person_detection.sh -i gstreamer |
Shad Ansari | 47432b6 | 2021-09-27 22:46:25 +0000 | [diff] [blame] | 85 | |
Shad Ansari | d365451 | 2021-09-29 10:31:53 -0700 | [diff] [blame] | 86 | run-native-cam: $(VENV) |
Shad Ansari | 0119b42 | 2021-09-27 23:51:49 +0000 | [diff] [blame] | 87 | . ./bin/person_detection.sh -i cam |
| 88 | |
Shad Ansari | b5808d7 | 2021-10-04 12:43:27 -0700 | [diff] [blame] | 89 | lint: |
| 90 | flake8 --exclude=.tox person_detection |
| 91 | |
Shad Ansari | 5aa7346 | 2021-10-04 21:43:07 -0700 | [diff] [blame] | 92 | test: docker-build |
Shad Ansari | 47432b6 | 2021-09-27 22:46:25 +0000 | [diff] [blame] | 93 | |
| 94 | |
| 95 | CLEANUP = *.pyc $(VENV) |
| 96 | clean: |
| 97 | rm -rf ${CLEANUP} |
| 98 | |
| 99 | .PHONY: run clean |
| 100 | |