
include .env

.PHONY: venv
venv:
	python3 -m venv venv
	./venv/bin/pip install -r requirements.txt
	./venv/bin/pip install -r requirements-test.txt

docker-start:
	docker-compose up --build -d function

docker-test:
	docker-compose up --build -d lint-and-test

docker-stop:
	docker-compose down

trigger:
	curl -i --request POST \
	  --data-binary '@tests/sample_event.json' \
	  http://localhost:9000/2015-03-31/functions/function/invocations

test:
	./venv/bin/python -m pytest --ignore=tests/integration/ tests/

lint:
	./venv/bin/flake8 src/ tests/ config.py
	./venv/bin/yamllint -s docker-compose.yaml

build:
	docker build --tag ${AWS_ACCOUNT}.dkr.ecr.us-east-1.amazonaws.com/lambda-essentia-audio-features .

ecr-login:
	aws ecr get-login-password --region us-east-1 | \
        docker login --username AWS --password-stdin "${AWS_ACCOUNT}.dkr.ecr.us-east-1.amazonaws.com"

deploy-dev: build ecr-login
	docker push ${AWS_ACCOUNT}.dkr.ecr.us-east-1.amazonaws.com/lambda-essentia-audio-features