-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
115 lines (87 loc) · 2.52 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/usr/bin/make
NAME = "events"
ENV_FILE ?= .env
DOCKER_COMPOSE=docker-compose --env-file=${ENV_FILE}
.DEFAULT_GOAL := dev
# avoid target corresponding to file names, to depends on them
.PHONY: *
#------#
# Info #
#------#
info:
@echo "${NAME} version: ${VERSION}"
hello:
@echo "🥫 Welcome to the Events API dev environment setup!"
@echo "🥫 Thanks for contributing to Events API!"
@echo ""
goodbye:
@echo "🥫 Cleaning up dev environment (remove containers, remove local folder binds, prune Docker system) …"
#-------#
# Local #
#-------#
dev: hello up
@echo "🥫 You should be able to access your local install of Events API at http://localhost:8000"
@echo "🥫 You should be able to access Events API metrics at http://localhost:8000/metrics"
#----------------#
# Docker Compose #
#----------------#
up:
@echo "🥫 Building and starting containers …"
${DOCKER_COMPOSE} up -d --build 2>&1
down:
@echo "🥫 Bringing down containers …"
${DOCKER_COMPOSE} down
hdown:
@echo "🥫 Bringing down containers and associated volumes …"
${DOCKER_COMPOSE} down -v
restart:
@echo "🥫 Restarting containers …"
${DOCKER_COMPOSE} restart
status:
@echo "🥫 Getting container status …"
${DOCKER_COMPOSE} ps
livecheck:
@echo "🥫 Running livecheck …"
docker/docker-livecheck.sh
log:
@echo "🥫 Reading logs (docker-compose) …"
${DOCKER_COMPOSE} logs -f
#------------#
# Quality #
#------------#
flake8:
${DOCKER_COMPOSE} run --rm --no-deps api flake8
black-check:
${DOCKER_COMPOSE} run --rm --no-deps api black --check .
black:
${DOCKER_COMPOSE} run --rm --no-deps api black .
mypy:
${DOCKER_COMPOSE} run --rm --no-deps api mypy .
isort-check:
${DOCKER_COMPOSE} run --rm --no-deps api isort --check .
isort:
${DOCKER_COMPOSE} run --rm --no-deps api isort .
checks: flake8 black-check mypy isort-check
lint: isort black
integration:
make dev
newman run tests/integration/openfoodfacts-events.postman_collection.json -e tests/integration/off-local.postman_environment.json --delay-request 5000
make hdown
unit:
ADMIN_USERNAME=test ADMIN_PASSWORD=test poetry run pytest -vv tests/unit
#------------#
# Production #
#------------#
create_external_volumes:
@echo "🥫 Creating external volumes (production only) …"
docker volume create events-data
#---------#
# Cleanup #
#---------#
prune:
@echo "🥫 Pruning unused Docker artifacts (save space) …"
docker system prune -af
prune_cache:
@echo "🥫 Pruning Docker builder cache …"
docker builder prune -f
clean: goodbye hdown prune prune_cache