~arx10/furemcape unlisted

ref: 124b913abcba550ca78f4c5943a9f7d933b18ddb furemcape/Makefile -rw-r--r-- 4.9 KiB
124b913aJustin Ludwig Add 5 more actions to opensshd parser: 11 months ago
                                                                                
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
SHELL := /bin/sh
.DEFAULT_GOAL := help
.SUFFIXES:

FUREMCAPE_BIN ?= /usr/local/bin
FUREMCAPE_SRC ?= /usr/local/src/furemcape
FUREMCAPE_VENV ?= /usr/local/virtualenvs/furemcape

# help: @ Lists available make tasks
help:
	@egrep -oh '[0-9a-zA-Z_\.\-]+:.*?@ .*' $(MAKEFILE_LIST) | \
	awk 'BEGIN {FS = ":.*?@ "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | sort

# init: @ Creates local files/dirs not checked into version control
init: init.administrator init.analyzer init.docs init.e2e init.feeder init.hitdb init.issuedb \
      init.reporter init.responder init.shared init.transformer
	touch .env

# run: @ Runs full system with docker
run: init
	docker-compose up -d

# dist: @ Builds full release
dist: init
	docker-compose build

# install: @ Installs system as root after postgres and python have been installed
# install.batch: @ Same as install, but skips all prompts
install.batch upgrade.batch: BATCH=--batch
install install.batch: install.database install.code install.services

# upgrade: @ Upgrades existing services as root
# upgrade.batch: @ Same as upgrade, but skips all prompts
upgrade upgrade.batch: SERVICES=upgrade
upgrade upgrade.batch: install.code install.services

# install.database: @ Runs database creation scripts as root
install.database:
	$(FUREMCAPE_SRC)/installer/bin/create-databases.sh $(BATCH)

# install.code: @ Bootstraps code components as root
install.code:
	$(FUREMCAPE_SRC)/installer/bin/bootstrap-code.sh $(BATCH)

# install.services: @ Installs services as root (after bootstrap)
install.services:
	$(FUREMCAPE_VENV)/bin/python3 $(FUREMCAPE_SRC)/administrator/bin/install.py \
	--services=$(SERVICES) $(BATCH)

# clean: @ Cleans entire project, deleting all furemcape docker images/volumes
clean: clean.artifacts clean.docker

# clean.artifacts: @ Deletes all python build artifacts
clean.artifacts: fix.permissions
	for x in .coverage htmlcov __pycache__ .pytest-cache; do \
		find -name "$$x" -exec rm -r {} +; done

# clean.docker: @ Deletes all furemcape docker images/volumes
clean.docker:
	@(read -p "DELETING ALL EXISTING FUREMCAPE DATA! Enter to continue, ^C to cancel..." doit)
	docker-compose rm -fv
	docker-compose -f docker-compose-dev.yml rm -fv
	docker image ls |  awk '/furemcape/{print $$3}' | xargs docker image rm -f
	docker volume ls | awk '/furemcape/{print $$2}' | xargs docker volume rm

# clean.rebuild: @ Cleans and rebuilds full dev environment
clean.rebuild: clean rebuild

# rebuild: @ Rebuilds full dev environment
rebuild: rebuild.shared rebuild.hitdb rebuild.issuedb rebuild.transformer rebuild.feeder \
         rebuild.analyzer rebuild.reporter rebuild.responder rebuild.administrator \
		 rebuild.docs rebuild.e2e rebuild.dev

# clean.dev: @ Cleans docker dev environment, deleting docker images/volumes
clean.dev: init
	docker-compose -f docker-compose-dev.yml stop dev hitdb_dev issuedb_dev
	docker-compose -f docker-compose-dev.yml rm -v dev hitdb_dev issuedb_dev
	docker image rm -f furemcape_dev hitdb_dev issuedb_dev
	docker volume rm -f furemcape_hitdb_dev
	docker volume rm -f furemcape_issuedb_dev

# clean.rebuild.dev: @ Cleans and rebuilds docker dev environment
clean.rebuild.dev: clean.dev rebuild.dev

# rebuild.dev: @ Rebuilds docker dev environment
rebuild.dev: fix.permissions init
	docker-compose -f docker-compose-dev.yml stop dev
	docker-compose -f docker-compose-dev.yml build dev
	docker-compose -f docker-compose-dev.yml run dev \
		pw_migrate migrate --directory hitdb/migrations \
		--database postgresext://hitdb:hitdb@hitdb_dev:5432/hitdb
	docker-compose -f docker-compose-dev.yml run dev \
		pw_migrate migrate --directory issuedb/migrations \
		--database postgresext://issuedb:issuedb@issuedb_dev:5432/issuedb

# migrate.dev: @ Migrates DBs in docker dev environment
migrate.dev: fix.permissions init
	docker-compose -f docker-compose-dev.yml run dev \
		pw_migrate migrate --directory hitdb/migrations \
		--database postgresext://hitdb:hitdb@hitdb_dev:5432/hitdb
	docker-compose -f docker-compose-dev.yml run dev \
		pw_migrate migrate --directory issuedb/migrations \
		--database postgresext://issuedb:issuedb@issuedb_dev:5432/issuedb

# check: @ Runs all tests and linters
check: lint test

# lint: @ Runs linting
lint: lint.shared lint.hitdb lint.issuedb lint.transformer lint.feeder \
	  lint.analyzer lint.reporter lint.responder lint.administrator lint.e2e

# test: @ Runs all tests
test: test.unit test.e2e test.installer

# test.unit: @ Runs all unit tests
test.unit: test.shared test.hitdb test.issuedb test.transformer test.feeder \
           test.analyzer test.reporter test.responder test.administrator

# dev: @ Opens python repl in dev environment
dev: init
	docker-compose -f docker-compose-dev.yml run dev

# shell: @ Opens /bin/sh shell in dev environment
shell: CMD ?= /bin/sh
shell: init
	docker-compose -f docker-compose-dev.yml run dev $(CMD)

# fix.permissions: @ Fixes root ownership on local dev files
fix.permissions:
	sudo chown -R $(USER) .

include */*.mk