-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
78 lines (65 loc) · 2.8 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
.ONESHELL:
PY_ENV=.venv
PY_BIN=$(shell python -c "print('$(PY_ENV)/bin') if __import__('pathlib').Path('$(PY_ENV)/bin/pip').exists() else print('')")
.DEFAULT_GOAL := help
DOCKER_COMPOSE := docker compose -f docker-compose.yml -f docker-compose.$(TARGET).yml
.PHONY: help
help: ## This help screen
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
.PHONY: check-venv
check-venv: ## Check if the virtualenv exists.
@if [ "$(PY_BIN)" = "" ]; then echo "No virtualenv detected, create one using 'make virtualenv'"; exit 1; fi
.PHONY: install
install: check-venv ## Install the project in dev mode.
@$(PY_BIN)/pip install -e .[dev,docs,test]
.PHONY: fmt
fmt: check-venv ## Format code using black & isort.
$(PY_BIN)/isort -v --src src/ --virtual-env $(PY_ENV)
$(PY_BIN)/black src/
.PHONY: lint
lint: check-venv ## Run ruff, black, mypy (optional).
@$(PY_BIN)/ruff check src/
@$(PY_BIN)/black --check src/
@if [ -x "$(PY_BIN)/mypy" ]; then $(PY_BIN)/mypy src/; else echo "mypy not installed, skipping"; fi
.PHONY: clean
clean: ## Clean unused files (VENV=true to also remove the virtualenv).
@find ./ -name '*.pyc' -exec rm -f {} \;
@find ./ -name '__pycache__' -exec rm -rf {} \;
@find ./ -name 'Thumbs.db' -exec rm -f {} \;
@find ./ -name '*~' -exec rm -f {} \;
@rm -rf .cache
@rm -rf .pytest_cache
@rm -rf .mypy_cache
@rm -rf .ruff_cache
@rm -rf build
@rm -rf dist
@rm -rf *.egg-info
@rm -rf htmlcov
@rm -rf .tox/
@rm -rf docs/_build
@if [ "$(VENV)" != "" ]; then echo "Removing virtualenv..."; rm -rf $(PY_ENV); fi
.PHONY: check-target
check-target: ## Check if TARGET variable is set.
@if [ -z "$(TARGET)" ]; then echo "TARGET is not set, launch the command setting TARGET=dev|prod"; exit 1; fi
@if [ "$(TARGET)" != "dev" ] && [ "$(TARGET)" != "prod" ]; then echo "TARGET must be either dev or prod"; exit 1; fi
@echo "Symlinking .env file to $${TARGET}.env"
@ln -sf ./envs/$${TARGET}.env .env
.PHONY: config
config: check-target ## Build the compose project.
@echo "Configuring compose with target: $${TARGET}"
@$(DOCKER_COMPOSE) config $${ARGS}
.PHONY: build
build: check-target ## Build the compose project.
@echo "Building images with target: $${TARGET}"
@$(DOCKER_COMPOSE) -p gaia-im-$${TARGET} build $${ARGS}
.PHONY: up
up: check-target ## Start the project containers.
@echo "Starting containers with target: $${TARGET}"
@$(DOCKER_COMPOSE) -p gaia-im-$${TARGET} up $${ARGS}
stop: check-target ## Stop the project containers.
@echo "Stopping containers with target: $${TARGET}"
@$(DOCKER_COMPOSE) -p gaia-im-$${TARGET} stop $${ARGS}
.PHONY: down
down: check-target ## Stop the project eliminating containers, use ARGS="-v" to remove volumes.
@echo "Stopping containers with target: $${TARGET}"
@$(DOCKER_COMPOSE) -p gaia-im-$${TARGET} down $${ARGS}