GOSRCS := $(shell find .  -name "*.go")
IMAGE_NAME := sport_rec_demo
all: sport_rec_demo

clean:
	@rm -f sport_rec_demo
	@rm -f $(IMAGE_NAME).img.gz

run: sport_rec_demo
	@echo "Starting ..."
	@./sport_rec_demo serve -L :8080

docker: $(GOSRCS)
	@echo "Building docker image ..."
	@docker build . -t $(IMAGE_NAME):latest

docker-run:
	@echo "Starting docker container ..."
	-@docker stop sport_rec_demo && docker rm -f sport_rec_demo
	@docker run --name sport_rec_demo -d -p 8080:3000 sport_rec_demo:latest

dump-image: docker
	@echo "Dumping docker image ..."
	@docker save $(IMAGE_NAME):latest | gzip > $(IMAGE_NAME).img.gz

sport_rec_demo: $(GOSRCS) Makefile
	@echo "Building $@ ..."
	@go build $@
