-
-
Notifications
You must be signed in to change notification settings - Fork 138
/
Makefile
98 lines (76 loc) · 1.94 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!make
DOCKER=docker
DOCKER_COMPOSE=docker-compose
.DEFAULT_GOAL:=help
-include .env .env.local .env.*.local
VCS_REF=$(shell git rev-parse --short HEAD)
BUILD_DATE=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
VERSION:=$(shell cat VERSION)
BACKEND ?= postgres
ifndef IMAGE_NAME
$(error IMAGE_NAME is not set)
endif
.PHONY: version
all: help
## lint - Lint Dockerfile.
lint:
docker run --rm -i hadolint/hadolint < Dockerfile
## test.unit - Run unit tests.
test.unit:
IMAGE_NAME=${IMAGE_NAME} \
VCS_REF=${VCS_REF} \
VERSION=${VERSION} \
$(DOCKER_COMPOSE) \
-f tests/docker-compose.test.${BACKEND}.yml \
up \
--build \
--renew-anon-volumes \
--no-color \
--exit-code-from tester
## build - Build docker image.
build:
$(DOCKER) build \
--build-arg VCS_REF=$(VCS_REF) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
--build-arg VERSION=$(VERSION) \
-t $(IMAGE_NAME) \
-t $(IMAGE_NAME):$(VERSION) \
-t $(IMAGE_NAME):$(VCS_REF) \
-t $(IMAGE_NAME):latest .
## push - Push docker image to repository.
push:
$(DOCKER) push $(IMAGE_NAME)
## pull - Pull docker images.
pull:
$(DOCKER_COMPOSE) -f docker-compose.yml pull
## up - Create and start up docker containers.
up:
$(DOCKER_COMPOSE) -f docker-compose.yml up
## down - Stop and remove docker containers.
down:
$(DOCKER_COMPOSE) -f docker-compose.yml down
## clean - Clean up docker containers.
clean:
$(DOCKER_COMPOSE) -f docker-compose.yml rm
## version - Show version.
version:
@$(DOCKER_COMPOSE) version
@echo "alerta version $(VERSION)"
## shell - Container shell prompt.
shell:
$(DOCKER_COMPOSE) -f docker-compose.test.yml run --rm sut bash
## env - Print environment variables.
env:
env | sort
## help - Show this help.
help: Makefile
@echo ''
@echo 'Usage:'
@echo ' make [TARGET]'
@echo ''
@echo 'Targets:'
@sed -n 's/^##//p' $<
@echo ''
@echo 'Add project-specific env variables to .env file:'
@echo 'PROJECT=$(PROJECT)'
.PHONY: help lint test build sdist wheel clean all