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 | ae90d25 | 2021-10-22 16:40:29 +0000 | [diff] [blame] | 58 | freeze: |
| 59 | pip3 freeze | grep -v "pkg-resources" > requirements.txt |
| 60 | |
Shad Ansari | 5aa7346 | 2021-10-04 21:43:07 -0700 | [diff] [blame] | 61 | docker-build: $(VENV) |
| 62 | docker build $(DOCKER_BUILD_ARGS) \ |
| 63 | -t $(DOCKER_IMAGENAME) \ |
| 64 | --build-arg org_label_schema_version="${VERSION}" \ |
| 65 | --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \ |
| 66 | --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \ |
| 67 | --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \ |
| 68 | --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \ |
| 69 | -f docker/Dockerfile . |
Shad Ansari | 47432b6 | 2021-09-27 22:46:25 +0000 | [diff] [blame] | 70 | |
Shad Ansari | 5aa7346 | 2021-10-04 21:43:07 -0700 | [diff] [blame] | 71 | docker-push: |
| 72 | docker push $(DOCKER_IMAGENAME) |
| 73 | |
| 74 | docker-run: |
| 75 | docker run \ |
| 76 | -itu root:root \ |
| 77 | --privileged \ |
| 78 | --network host \ |
| 79 | --name $(CONTAINER_NAME) \ |
| 80 | --rm \ |
| 81 | $(DOCKER_IMAGENAME) |
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-file: $(VENV) |
Shad Ansari | d80531f | 2021-09-27 23:15:03 +0000 | [diff] [blame] | 84 | . ./bin/person_detection.sh -i ./resources/run.mp4 |
Shad Ansari | 47432b6 | 2021-09-27 22:46:25 +0000 | [diff] [blame] | 85 | |
Shad Ansari | 341ca3a | 2021-09-30 12:10:00 -0700 | [diff] [blame] | 86 | run-native-gstream: $(VENV) |
Shad Ansari | d80531f | 2021-09-27 23:15:03 +0000 | [diff] [blame] | 87 | . ./bin/person_detection.sh -i gstreamer |
Shad Ansari | 47432b6 | 2021-09-27 22:46:25 +0000 | [diff] [blame] | 88 | |
Shad Ansari | d365451 | 2021-09-29 10:31:53 -0700 | [diff] [blame] | 89 | run-native-cam: $(VENV) |
Shad Ansari | 0119b42 | 2021-09-27 23:51:49 +0000 | [diff] [blame] | 90 | . ./bin/person_detection.sh -i cam |
| 91 | |
Shad Ansari | b5808d7 | 2021-10-04 12:43:27 -0700 | [diff] [blame] | 92 | lint: |
| 93 | flake8 --exclude=.tox person_detection |
| 94 | |
Shad Ansari | 5aa7346 | 2021-10-04 21:43:07 -0700 | [diff] [blame] | 95 | test: docker-build |
Shad Ansari | 47432b6 | 2021-09-27 22:46:25 +0000 | [diff] [blame] | 96 | |
| 97 | |
| 98 | CLEANUP = *.pyc $(VENV) |
| 99 | clean: |
| 100 | rm -rf ${CLEANUP} |
| 101 | |
| 102 | .PHONY: run clean |
| 103 | |