-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
108 lines (82 loc) · 2.25 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
DOCKER_DIRS := keycloak_bend oauth2-authenticator keycloak_tapir_bridge legacy_auth_provider test-site
ALL_DIRS := $(DOCKER_DIRS) tools tests
include .env
export $(shell sed 's/=.*//' .env)
ARXIV_BASE_DIR ?= $(HOME)/arxiv/arxiv-base
.PHONY: HELLO all bootstrap docker-image arxiv-db nginx test up down
all: HELLO
define run_in_docker_dirs
@for dir in $(DOCKER_DIRS); do \
echo "Running $(1) in $$dir"; \
$(MAKE) -C $$dir $(1) || exit 1; \
done
endef
define run_in_all_subdirs
@for dir in $(ALL_DIRS); do \
echo "Running $(1) in $$dir"; \
$(MAKE) -C $$dir $(1) || exit 1; \
done
endef
HELLO:
@echo To see the README of this Makefile, type "make help"
@echo First, run "bash config.sh"
@echo Then, "make bootstrap" to set up the environment.
#-#
#-# help:
#-# print help messsages
help:
@awk '/^#-#/ { print substr($$0, 5)}' Makefile
.env: .env.localdb
.env.localdb:
bash config.sh > /dev/null
#-#
#-# bootstrap:
#-# bootstraps the environment
bootstrap: .bootstrap
.bootstrap:
./tools/install_py311.sh
$(call run_in_all_subdirs,bootstrap)
touch .bootstrap
#-#
#-# docker-image:
#-# builds docker images
docker-image:
$(call run_in_docker_dirs,docker-image)
#-#
#-# up:
#-# runs docker compose up with .env.
up: .env
docker compose --env-file=.env up -d
#-#
#-# down:
#-# runs docker compose down
down:
docker compose --env-file=.env down
#-#
#-# test:
#-# runs test in all of subdirectories
test:
$(call run_in_all_subdirs,test)
#-#
#-# nginx:
#-# runs nginx docker container and get into shell.
#-# NOTE: you need to run docker compose ("make up") so that the network exists.
nginx:
docker run -it --rm \
--network arxiv-keycloak_arxiv-network \
-v ./tests/config/nginx-docker.conf:/etc/nginx/nginx.conf \
-p ${NGINX_PORT}:${NGINX_PORT} \
nginx:latest /bin/bash
sh-nginx:
docker exec -it nginx-proxy /bin/bash
#-#
#-# arxiv-db:
#-# loads the arxiv-db aka mysql database.
#-# NOTE: you need to run docker compose ("make up") so that the network exists.
arxiv-db:
docker run --rm --name arxiv-db-setup \
--network arxiv-keycloak_arxiv-network \
-e CLASSIC_DB_URI="mysql://root:root_password@arxiv-test-db:${ARXIV_DB_PORT}/arXiv" \
-v $(PWD):/arxiv-keycloak \
python:3.11 bash /arxiv-keycloak/tools/load_test_data.sh
#-#