.PHONY = build, test, test-api, test-ui, test-style, demo, stop

# Build the API image
build:
	docker build \
		--pull \
		--cache-from=dorianpula/rookeries:latest \
		--tag dorianpula/rookeries:latest .

# Runs all the tests
test: build test-style test-api test-ui

# Run code linter tests
test-style: stop build
	docker-compose run --no-deps rookeries \
		inv test.style

# Runs API tests
test-api: stop build
	docker-compose up -d db rookeries
	docker-compose exec rookeries \
		inv db.wait db.init-couchdb db.add-db
	docker-compose exec rookeries \
		inv server.wait --timeout 100
	docker-compose exec rookeries \
		inv test.server --verbosity=1

# Runs UI tests
test-ui: stop build
	docker-compose run --no-deps rookeries \
		inv test.js

# Demos Rookeries in a browser
demo: build
	docker-compose up -d --remove-orphans
	python -m webbrowser -n http://localhost:5000/

# Shuts down Rookeries
stop:
	docker-compose down --remove-orphans --volumes
