-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile-docker.defs
133 lines (101 loc) · 3.65 KB
/
makefile-docker.defs
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
125
126
127
128
129
130
131
132
133
# definitions for docker-based development
# ----------------------------------
# starting, stopping, migrating DB
# ----------------------------------
create_mock_vespa_certs:
mkdir -p secrets
[ -f secrets/cert.pem ] || touch secrets/cert.pem
[ -f secrets/key.pem ] || touch secrets/key.pem
start: build_from_cached create_mock_vespa_certs
# Build & run containers and setup vespa
docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d --remove-orphans
$(MAKE) vespa_setup
start_without_vespa_setup:
# Build & run containers and setup vespa
docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d --remove-orphans
start_backend:
# Build and run containers
docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d backend backend_db
show_logs:
docker compose logs -f
stop:
docker compose down --remove-orphans
rm:
docker compose rm
remove_volumes:
docker compose down -v
up:
# docker-compose up, without -d
docker compose -f docker-compose.yml -f docker-compose.dev.yml up
restart:
docker compose build
make start
make show_logs
# ----------------------------------
# database maintenance
# ----------------------------------
%:
@:
new_migration_backend:
docker compose -f docker-compose.yml -f docker-compose.dev.yml run --rm backend alembic revision --autogenerate -m "$(filter-out $@,$(MAKECMDGOALS))"
refresh_all_dbs:
docker compose down -v
make start
# ----------------------------------
# building images
# ----------------------------------
build_bats:
docker build bats -t bats-with-helpers:latest
build:
docker compose build --no-cache backend
build_from_cached:
docker compose build backend
# ----------------------------------
# testing
# ----------------------------------
vespa_confirm_cli_installed:
@if [ ! $$(which vespa) ]; then \
echo 'ERROR: The vespa cli is not installed, please install and try again:' ; \
echo 'https://docs.vespa.ai/en/vespa-cli.html'; \
exit 1; \
fi
vespa_healthy:
@if [ ! $$(curl -f -s 'http://localhost:19071/status.html') ]; then \
echo 'ERROR: Bad response from local vespa cluster, is it running?'; \
exit 1; \
fi
.ONESHELL:
vespa_deploy_schema:
vespa config set target local
@vespa deploy tests/search/vespa/fixtures/vespa_test_schema --wait 300
.ONESHELL:
vespa_load_data:
vespa config set target local
vespa feed --progress=3 tests/search/vespa/fixtures/vespa_search_weights.json
vespa feed --progress=3 tests/search/vespa/fixtures/vespa_family_document.json
vespa feed --progress=3 tests/search/vespa/fixtures/vespa_document_passage.json
vespa_setup: vespa_confirm_cli_installed vespa_healthy vespa_deploy_schema vespa_load_data
# Deploys a vespa application to a local vespa container and loads search fixtures
.ONESHELL:
test_search:
docker compose \
-f docker-compose.yml \
-f docker-compose.dev.yml \
run --rm --name search_test \
-v "${PWD}/data:/data" \
backend pytest \
-vvv tests/search \
-m 'search' ${ARGS}
test_cors:
docker compose -f docker-compose.yml -f docker-compose.dev.yml run --rm backend pytest -vvv -m 'cors' ${ARGS}
test_unit:
docker compose -f docker-compose.yml -f docker-compose.dev.yml run --rm backend pytest -vvv tests/unit ${ARGS}
test_non_search:
docker compose -f docker-compose.yml -f docker-compose.dev.yml run --rm backend pytest -vvv -m 'not search' ${ARGS}
test:
docker compose -f docker-compose.yml -f docker-compose.dev.yml run --rm backend pytest -vvv tests ${ARGS}
# ----------------------------------
# tasks
# ----------------------------------
postgres_dump:
docker compose run -v ${PWD}/backend:/app/data --rm backend_db pg_dump -d ${DATABASE_URL} --data-only -F c --file /app/data/backend_db_dump.dump