PHONY: all

run_with_docker:
	docker-compose -f compose/karmen/docker-compose.yml down
	docker-compose -f compose/karmen/docker-compose.yml up --build -d
	echo "Uploading files to the cloud..."
	sleep 15

	curl -u admin:password http://localhost:8080/remote.php/webdav/Documents/List -X MKCOL
	curl -u admin:password http://localhost:8080/remote.php/webdav/Documents/List/list.tpl.md -X PUT --data-binary @"./generator/generators/list/example_1/resources/list.tpl.md"
	curl -u admin:password http://localhost:8080/remote.php/webdav/Documents/List/reference.odt -X PUT --data-binary @"./generator/generators/list/example_1/resources/reference.odt"

	curl -u admin:password http://localhost:8080/remote.php/webdav/Documents/Department -X MKCOL
	curl -u admin:password http://localhost:8080/remote.php/webdav/Documents/Department/template.md -X PUT --data-binary @"./generator/generators/department/example_1/resources/template.md"
	curl -u admin:password http://localhost:8080/remote.php/webdav/Documents/Department/reference.odt -X PUT --data-binary @"./generator/generators/department/example_1/resources/reference.odt"

run_outside_docker:
	killall main || echo "Process was not running."
	docker-compose -f compose/karmen/docker-compose_outside_docker.yml down
	docker-compose -f compose/karmen/docker-compose_outside_docker.yml up -d db
	go run main.go --config=config/config_outside_docker.yaml &

all: run_with_docker
