-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
124 lines (101 loc) · 2.88 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
116
117
118
119
120
121
122
123
124
.DEFAULT_GOAL := help
export COMPOSE_DOCKER_CLI_BUILD=1
export DOCKER_BUILDKIT=1
export BUILDKIT_PROGRESS=plain
A3M_PIPELINE_DATA ?= $(CURDIR)/hack/compose-volume
CURRENT_UID := $(shell id -u)
CURRENT_GID := $(shell id -g)
PYTHON_VERSION = $(shell cat .python-version | awk -F '.' '{print $$1 "." $$2}')
define compose
docker compose -f compose.yml $(1)
endef
define compose_run
$(call compose, \
run \
--rm \
--user=$(CURRENT_UID):$(CURRENT_GID) \
--workdir /a3m \
--no-deps \
$(1))
endef
.PHONY: shell
shell: ## Open a shell in a new container.
$(call compose_run, \
--entrypoint bash \
a3m)
.PHONY: build
build: ## Build containers.
$(call compose, \
build \
--build-arg USER_ID=$(CURRENT_UID) \
--build-arg GROUP_ID=$(CURRENT_GID))
.PHONY: create-volume
create-volume: ## Create external data volume.
mkdir -p ${A3M_PIPELINE_DATA}
docker volume create \
--opt type=none \
--opt o=bind \
--opt device=$(A3M_PIPELINE_DATA) \
a3m-pipeline-data
.PHONY: manage
manage: ## Run Django /manage.py on a3m, suppling <command> [options] as value to ARG, e.g., `make manage ARG=shell`
$(call compose_run, \
--entrypoint /a3m/manage.py \
a3m \
$(ARG))
.PHONY: bootstrap
bootstrap: ## Bootstrap a3m (new database).
$(MAKE) manage ARG="migrate --noinput"
.PHONY: makemigrations
makemigrations: ## Make Django migrations.
$(MAKE) manage ARG="makemigrations main fpr"
.PHONY: stop
stop: ## Stop services
docker-compose stop a3m
.PHONY: restart
restart: ## Restart services
docker-compose restart a3m
.PHONY: db
db:
$(call compose_run, \
--entrypoint=sqlite3 \
a3m \
./hack/compose-volume/db.sqlite)
.PHONY: flush
flush: stop flush-db flush-shared-dir bootstrap restart ## Delete ALL user data.
.PHONY: flush-db
flush-db: ## Flush SQLite database.
$(call compose_run, \
--entrypoint sh \
a3m \
-c "rm -rf /home/a3m/.local/share/a3m/db.sqlite")
.PHONY: flush-shared-dir
flush-shared-dir: ## Flush shared directory including the database.
$(call compose_run, \
--entrypoint sh \
a3m \
-c "rm -rf /home/a3m/.local/share/a3m/share/")
.PHONY: buf
buf:
docker run \
--volume "$(CURDIR)/proto:/workspace" \
--workdir /workspace \
bufbuild/buf:1.42.0 \
$(ARG)
.PHONY: help
help: ## Print this help message.
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
RED := \033[0;31m
GREEN := \033[0;32m
YELLOW := \033[0;33m
RESET := \033[0m
define print_color
@echo "$(1)$(2)$(RESET)"
endef
.PHONY: workflow
workflow: ## Open amflow application web server.
$(call print_color,$(YELLOW),Access the amflow server at http://127.0.0.1:2323 once it's fully started.)
@docker run --rm --publish=2323:2323 --pull=always \
--volume=$(CURDIR)/a3m/assets/workflow.json:/tmp/workflow.json \
artefactual/amflow:latest \
edit --file=/tmp/workflow.json --verbosity=warn