Andy Bavier | 614af14 | 2020-08-07 14:49:56 -0700 | [diff] [blame] | 1 | # Copyright 2020-present Open Networking Foundation |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
| 15 | # Secret iCal URL for ACE downtime calendar |
| 16 | SECRET_ICAL_URL ?= |
| 17 | |
| 18 | # Namespace to install secret in, for testing |
| 19 | NAMESPACE ?= edge-monitoring |
| 20 | |
| 21 | # set default shell |
| 22 | SHELL = bash -e -o pipefail |
| 23 | |
| 24 | # Variables |
| 25 | VERSION ?= $(shell cat ./VERSION) |
| 26 | VENVDIR := venv |
| 27 | |
| 28 | ## Docker related |
| 29 | DOCKER_REGISTRY ?= |
| 30 | DOCKER_REPOSITORY ?= |
| 31 | DOCKER_BUILD_ARGS ?= |
| 32 | DOCKER_TAG ?= ${VERSION} |
| 33 | ADAPTER_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}edge-monitoring-server:${DOCKER_TAG} |
| 34 | |
| 35 | |
| 36 | # This should to be the first and default target in this Makefile |
| 37 | help: |
| 38 | @echo "Usage: make [<target>]" |
| 39 | @echo "where available targets are:" |
| 40 | @echo |
| 41 | @echo "build : Build the edge-monitoring-server docker image" |
| 42 | @echo "help : Print this help" |
| 43 | @echo "docker-push : Push the docker image to an external repository" |
| 44 | @echo "venv : Build local Python virtualenv" |
| 45 | @echo "test : Run edge-monitoring-server unit tests" |
| 46 | @echo "clean : Remove files created by the build and tests" |
| 47 | @echo "distclean : Remove venv directory" |
| 48 | @echo |
| 49 | |
| 50 | build: docker-build |
| 51 | |
| 52 | docker-build: |
| 53 | docker build $(DOCKER_BUILD_ARGS) \ |
| 54 | -t ${ADAPTER_IMAGENAME} \ |
| 55 | -f ./Dockerfile.server . |
| 56 | |
| 57 | docker-push: |
| 58 | docker push ${ADAPTER_IMAGENAME} |
| 59 | |
| 60 | venv: ${VENVDIR} |
| 61 | virtualenv --python=python3.7 ${VENVDIR};\ |
| 62 | source ./${VENVDIR}/bin/activate ; set -u ;\ |
| 63 | pip install -r requirements.txt |
| 64 | |
| 65 | clean: |
| 66 | find . -name '*.pyc' | xargs rm -f |
| 67 | |
| 68 | distclean: clean |
| 69 | rm -rf ${VENVDIR} |
| 70 | |
| 71 | test: venv |
| 72 | source ./${VENVDIR}/bin/activate ; set -u ;\ |
| 73 | python3 test_edge_monitoring_server.py |