-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
64 lines (47 loc) · 1.97 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
# 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/
ifndef API_NAME
-include .env
endif
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) .;
build.migrations:
cd $(cwd); docker build -f Dockerfile-migrations -t tapis/$(api)-migrations .
build.test:
cd $(cwd); docker build -t tapis/$(api)-tests -f Dockerfile-tests .;
build: build.api build.migrations build.test
# ----- run tests
test: build.test
cd $(cwd); touch service.log; chmod a+w service.log; docker-compose run $(api)-tests;
# ----- shutdown the currently running services
down:
docker-compose down
# ----- wipe the local environment by removing all data and containers
clean: down
- docker volume rm $(api)_pgdata
# ----- start databases
run_dbs: build.api down
cd $(cwd); docker-compose up -d postgres; docker-compose up -d authenticator-ldap
# ----- 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 8
docker cp new_db.sql $(api)_postgres_1:/db.sql
docker-compose exec -T postgres psql -Upostgres -f /db.sql
# ----- wipe database and associated data
#wipe: clean
# rm -rf migrations
# ----- run migrations
migrate.upgrade: build.migrations
docker-compose run --rm migrations upgrade