image = miti.sh
docker-run = docker run --rm -w /opt/app -v $(PWD):/opt/app $(image)

serve:
	docker run --rm -it --init -v $(PWD):/opt/app -p 8080:80 $(image) \
		sh -c "openresty -p /opt/app -g 'daemon off;' -c conf/dev.nginx.conf"

shell:
	docker run --rm -it --init -v $(PWD):/opt/app -p 8080:80 $(image) bash

build:
	$(if $(file), $(docker-run) sitegen build $(file), $(docker-run) sitegen)

build-pygments:
	$(docker-run) moonc pygments.moon

image-rm:
	docker image rm $(image)

image-build:
	docker build -t $(image) .

lint:
	$(docker-run) moonc -l .

test:	build-pygments
	./test.sh

host = 'gundi@miti.sh'
path = 'www/sites/miti.sh/html/'

deploy: confirm_deploy
	rsync -rvuzL html/ $(host):$(path)

confirm_deploy:
	@echo -n "Deploy previously generated site over ssh using rsync\n\n\
	Server hostname $(host)?\n\
	Path on server to deploy to $(path)?\n\n\
	Are you sure? [y/N] " && read ans && [ $${ans:-N} = y ]

.PHONY: confirm_deploy
