APP_NAME := oos-service
VERSION  := $(shell git describe --tags --always --dirty 2>/dev/null || echo "0.1.0")

.PHONY: all build run run-dev run-uat run-prod test clean fmt vet

all: clean build

build:
	go build -ldflags "-X bitbucket.org/imediabrands/oos-service/healthchecks.version=$(VERSION)" -o bin/$(APP_NAME) .

run: run-dev

run-dev: build
	cp environments/dev/config.json config.json
	./bin/$(APP_NAME)

run-uat: build
	cp environments/uat/config.json config.json
	./bin/$(APP_NAME)

run-prod: build
	cp environments/prod/config.json config.json
	./bin/$(APP_NAME)

test:
	go clean --testcache
	go test ./...

fmt:
	go fmt ./...

vet:
	go vet ./...

clean:
	rm -rf bin/
