forked from tapis-project/tokens-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
58 lines (40 loc) · 1.71 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
# Recipes for building images, and applying data migrations and running services locallu.
# NOTE - tab characters are required within recipes; Do NOT edit this file in an editor that supplies spaces; for example,
# lots of Python IDEs like PyCharm won't work because they are (rightly) configured to insert spaces, even if you
# type a TAB character. If you see an error like " *** missing separator. Stop." you're missing some tabs!
#
# CONSIDER USING VIM (sigh!) WHICH ACTUALLY HAS GOOD MAKEFILE EDITING SUPPORT.
# it is required that the operator export API_NAME=<name_of_the_api> before using this makefile/
api=${API_NAME}
cwd=$(shell pwd)
# ----- build images
build.api:
cd $(cwd); touch service.log; chmod a+w service.log; docker build -t tapis/$(api)-api .;
build.test:
cd $(cwd); docker build -t tapis/$(api)-api-tests -f Dockerfile-tests .;
build: build.api build.test
# ----- wipe the local environment by removing all containers
clean:
docker-compose down
# ----- start databases
run_dbs: build.api clean
cd $(cwd); docker-compose up -d postgres
# ----- run tests
test: build.test
cd $(cwd); touch service.log; docker-compose run $(api)-tests;
# ----- connect to db as root
connect_db:
docker-compose exec postgres psql -Upostgres
# ----- initialize databases; run this target once per database installation
init_dbs: run_dbs
echo "wait for db to start up..."
sleep 4
docker cp new_db.sql ${api}-api_postgres_1:/db.sql
docker-compose exec postgres psql -Upostgres -f /db.sql
# ----- wipe database and associated data
wipe: clean
docker volume rm $(api)-api_pgdata
rm -rf migrations
# ----- run migrations
migrate.upgrade: build.migrations
docker-compose run --rm migrations upgrade