.PHONY: build-binary
	build-docker
	push-docker
	update-docker
	makemigrations
	install
	run
	test
	deploy-to-testing
	deploy-to-production


build-binary:
	ya make -o build
	cp build/intranet/hrdb_ext/src/wsgi/hrdb_ext.wsgi hrdb_ext-main
	rm -rf build

build-docker:
	ya package docker-package.json --docker --docker-repository=hrdb-backend --custom-version=$(tag)

push-docker:
	docker push registry.yandex.net/hrdb-backend/hrdb_ext:$(tag)

update-docker: build-docker push-docker

makemigrations:
	make build-binary
	DJANGO_SETTINGS_MODULE="intranet.hrdb_ext.src.makemigrations_settings" IS_ARCADIA=1 Y_PYTHON_ENTRY_POINT="intranet.hrdb_ext.src.manage:django_main" ./hrdb_ext-main makemigrations

install:
	ya package docker-package.json --docker --docker-repository=hrdb-backend  --custom-version=local
	docker-compose build web
	docker-compose up web

run:
	docker-compose up web

test:
	SECRET_KEY=123 ya make -AP tests

deploy-to-testing:
	ya tool releaser stand -s hrdb_ext_testing

deploy-to-production:
	ya tool releaser stand -s hrdb_ext_production
