gen:
	go get google.golang.org/protobuf/cmd/protoc-gen-go
	go get -u github.com/twitchtv/twirp/protoc-gen-twirp
	protoc --proto_path=. --twirp_out=. --go_out=. ./proto/centaur.proto

run:
	go run ./cmd/centaur

build: gomodgen gen
	export GO111MODULE=on
	env GOOS=linux go build -ldflags="-s -w" -o bin/centaur ./cmd/centaur

clean:
	rm -rf ./bin ./vendor Gopkg.lock

gomodgen:
	chmod u+x gomod.sh
	./gomod.sh

compose:
	docker-compose build
	docker-compose up

compose-deploy:
	rsync -e "ssh -F /dev/null" -avhd --delete --exclude ".git" --exclude "node_modules" ./ ubuntu@clipclop.mgst.xarth.tv:centaur/
	ssh -F /dev/null ubuntu@clipclop.mgst.xarth.tv "cd centaur && sudo make prod-script"

prod-script:
	docker-compose -f docker-compose.prod.yaml build
	docker-compose -f docker-compose.prod.yaml down --remove-orphans
	docker-compose -f docker-compose.prod.yaml up -d

logs:
	ssh -F /dev/null ubuntu@clipclop.mgst.xarth.tv "cd centaur && sudo docker-compose -f docker-compose.prod.yaml logs -f"
