From 9525cbcbe0ceef2585919dfeb7d4fde6dea06426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Thu, 23 Mar 2017 22:56:17 -0700 Subject: [PATCH] Cleanup Makefile Rename 'make build' to 'make docker-image' so it's more obvious what it's doing Initialize git submodules automatically when needed, so users don't need to do it manually --- .gitignore | 1 + Makefile | 15 ++++++++++----- README.md | 22 +++++++++++----------- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index bfa7937e7..53172e377 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ +.build unsee diff --git a/Makefile b/Makefile index e87d94a81..20c8bc58c 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,19 @@ VERSION := $(shell git describe --tags --always --dirty='-dev') -.PHONY: build -build: +.build/deps.ok: .gitmodules + git submodule update --init --recursive + mkdir -p .build + touch $@ + +.PHONY: docker-image +docker-image: docker build --build-arg VERSION=$(VERSION) -t unsee:$(VERSION) . ALERTMANAGER_URI := https://raw.githubusercontent.com/prymitive/alertmanager-demo-api/master PORT := 8080 .PHONY: demo -demo: build +demo: docker-image @docker rm -f unsee-dev || true docker run \ --name unsee-dev \ @@ -18,7 +23,7 @@ demo: build unsee:$(VERSION) .PHONY: dev -dev: +dev: .build/deps.ok go build -v -ldflags "-X main.version=${VERSION:-dev}" && \ DEBUG=true \ ALERTMANAGER_URI=$(ALERTMANAGER_URI) \ @@ -26,7 +31,7 @@ dev: ./unsee .PHONY: lint -lint: +lint: .build/deps.ok @golint ./... | (grep -v ^vendor/ || true) .PHONY: test diff --git a/README.md b/README.md index 911caec67..77ad8b3ef 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,19 @@ to alert data, therefore safe to be accessed by wider audience. ## Building and running +### Running in dev mode + +Requires Go. + + make dev + +Will compile unsee and run the binary (not using Docker), by default will use +same port and Alertmanager URI as demo mode. This is intended for local +development. + ### Build a Docker image - make build + make docker-image This will build a Docker image from sources. @@ -27,16 +37,6 @@ variables. Example: make PORT=5000 ALERTMANAGER_URI=https://alertmanager.unicorn.corp run -### Running in dev mode - -Requires Go. - - make dev - -Will compile unsee and run the binary (not using Docker), by default will use -same port and Alertmanager URI as demo mode. This is intended for testing -changes. - ### Environment variables #### ALERTMANAGER_URI