blob: 08e84a379679c545de5b9762b52efbf01ead3c32 [file] [log] [blame]
#
# SPDX-FileCopyrightText: 2020-present Open Networking Foundation <info@opennetworking.org>
# SPDX-License-Identifier: LicenseRef-ONF-Member-1.01
#
define PROJECT_HELP_MSG
Usage:
make help show this message
make clean remove intermediate files
make ${VENV} make a virtualenv in the base directory
make python-reqs install python packages in requirements.pip
make git-config set local git configuration
make setup make python-reqs
make run launch network-video-recorder
make run-native run native application (no docker)
make run-native-no-show run native applicaiton (no docker) w/o video output
endef
export PROJECT_HELP_MSG
SHELL = bash -eu -o pipefail
VERSION ?= $(shell cat ./VERSION)
#CONTAINER_NAME ?= person-detection-app
CONTAINER_NAME ?= $(notdir $(abspath .))
DOCKER_REGISTRY ?=
DOCKER_REPOSITORY ?=
DOCKER_BUILD_ARGS ?= --rm --force-rm
DOCKER_TAG ?= ${VERSION}
DOCKER_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}${CONTAINER_NAME}:${DOCKER_TAG}
DOCKER_LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote))
DOCKER_LABEL_VCS_REF ?= $(shell git diff-index --quiet HEAD -- && git rev-parse HEAD || echo "unknown")
DOCKER_LABEL_COMMIT_DATE ?= $(shell git diff-index --quiet HEAD -- && git show -s --format=%cd --date=iso-strict HEAD || echo "unknown" )
DOCKER_LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ")
VENV = .venv
PYTHON = $(VENV)/bin/python3
PIP = $(VENV)/bin/pip
all: test
help:
echo "$$PROJECT_HELP_MSG" | less
$(VENV): $(VENV)/touchfile
$(VENV)/touchfile: requirements.txt
test -d $(VENV) || python3 -m venv $(VENV)
. $(VENV)/bin/activate; pip install -Ur requirements.txt
touch $(VENV)/touchfile
$(VENV)/bin/activate: requirements.txt
python3 -m venv $(VENV)
$(PIP) install -r requirements.txt
freeze:
pip3 freeze | grep -v "pkg-resources" > requirements.txt
docker-build: $(VENV)
docker build $(DOCKER_BUILD_ARGS) \
-t $(DOCKER_IMAGENAME) \
--build-arg org_label_schema_version="${VERSION}" \
--build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \
--build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \
--build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \
--build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \
-f docker/Dockerfile .
docker-push:
docker push $(DOCKER_IMAGENAME)
docker-run:
docker run \
-itu root:root \
--privileged \
--network host \
--name $(CONTAINER_NAME) \
--rm \
$(DOCKER_IMAGENAME) --key "eyJhbGciOiJSUzI1NiIsImtpZCI6IjUwNDJmNjcxYTQ1YWMxNGM1MzA0ZTA3MWY3MWM2N2FkNGE4N2RhZDYifQ.eyJpc3MiOiJodHRwczovL2RleC5hZXRoZXJwcm9qZWN0Lm9yZy9kZXgiLCJzdWIiOiJDaXN4TmpNNE5ERTZPRGMxWlRNeU5qY3RZakkwT1MwME9XTXdMV0V5TW1ZdE1qUmlaalUyWXprNVpEazFFZ1ZqY205M1pBIiwiYXVkIjoiYWV0aGVyLXJvYy1ndWkiLCJleHAiOjE2Mzg5OTU0MTAsImlhdCI6MTYzODkwOTAxMCwibm9uY2UiOiJNSGRTV25CWFpGRkxRVmxNWlROWk9IbzViWE55ZDJOV2VFWnlTV2RuUlRSUE4xaDNTMnBSTVV4NGRUSmoiLCJhdF9oYXNoIjoiWGtGNW5WM3UwcUZxYml3RC03c2NNdyIsImNfaGFzaCI6ImUzdXdRVkZpOW5ieGJlbHNmNW9MS0EiLCJlbWFpbCI6InNoYWRAb3Blbm5ldHdvcmtpbmcub3JnIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImdyb3VwcyI6WyJBZXRoZXJST0NBZG1pbiIsIk9ORlN0YWZmIl0sIm5hbWUiOiJzaGFkIiwicHJlZmVycmVkX3VzZXJuYW1lIjoic2hhZCJ9.uIaSeuJGviVSiQeOT8EBPBoLBDy5G8lSwXz48XoAyNIyj3jontKNKfOf8pnQR7Cvrutqk56WOS78V8HPQgr01uTezaSHMZzPNnHtsyyCreMChAwKV-ZKS40b0q56yNihScHHVB0wlSO6Yr9K45M2tX1AActL10Ky3td9myvObPXEPgYsiG-KTWQVNAC_dnrmArKuUiqVlWAJhJckdRBOGHVhceenaDCrMPB8u-Z3_-S89gq4mper1fXNFmDCxXbRceJJPfWeWJNhJEQ0y1LC1c8JLxKFpynjfetXCA9qAaPJ0vzn-NYQnVpTqiDm7BsW4Ry1-62Nlgm3km2wT-Le_A"
run-native-file: $(VENV)
. ./bin/person_detection.sh -i ./resources/run.mp4
run-native-gstream: $(VENV)
. ./bin/person_detection.sh -i gstreamer
run-native-cam: $(VENV)
. ./bin/person_detection.sh -i cam
lint:
flake8 --exclude=.tox person_detection
test: docker-build
CLEANUP = *.pyc $(VENV)
clean:
rm -rf ${CLEANUP}
.PHONY: run clean