-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
46 lines (37 loc) · 1.54 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
VERSION := $(shell git describe --always --dirty --tags 2>/dev/null || echo "undefined")
IMG ?= quay.io/pusher/k8s-spot-price-monitor
RED := \033[31m
GREEN := \033[32m
NC := \033[0m
.PHONY: all
all: lint
.PHONY: lint
lint: venv pip-install
@ echo "$(GREEN)Linting code$(NC)"
@ if [ ! $$(which flake8) ]; then echo "$(RED)flake8 not found - please install 'python -m pip install flake8'$(NC)"; exit 1; fi
. venv/bin/activate; flake8 spot_price_monitor --max-line-length=120 --max-complexity=8
@ if [ ! $$(which pylint) ]; then echo "$(RED)pylint not found - please install 'python -m pip install pylint'$(NC)"; exit 1; fi
. venv/bin/activate ; pylint spot_price_monitor --max-line-length=120
@ echo
venv:
python3 -m venv venv
.PHONY: pip-install
pip-install: venv
. venv/bin/activate ; \
pip3 install -r requirements.txt
.PHONY: docker-build
docker-build:
docker build --build-arg VERSION=${VERSION} . -t ${IMG}:${VERSION}
@echo "$(GREEN)Built $(IMG):$(VERSION)$(NC)"
TAGS ?= latest
.PHONY: docker-tag
docker-tag: docker-build
@IFS=","; tags=${TAGS}; for tag in $${tags}; do docker tag ${IMG}:${VERSION} ${IMG}:$${tag}; echo "$(GREEN)Tagged $(IMG):$(VERSION) as $${tag}$(NC)"; done
PUSH_TAGS ?= ${VERSION}, latest
.PHONY: docker-push
docker-push: docker-build docker-tag
@IFS=","; tags=${PUSH_TAGS}; for tag in $${tags}; do docker push ${IMG}:$${tag}; echo "$(GREEN)Pushed $(IMG):$${tag}$(NC)"; done
TAGS ?= latest
.PHONY: docker-clean
docker-clean:
@IFS=","; tags=${TAGS}; for tag in $${tags}; do docker rmi -f ${IMG}:${VERSION} ${IMG}:$${tag}; done