-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·115 lines (103 loc) · 2.28 KB
/
entrypoint.sh
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
#!/bin/bash
#load environment variables from .env file
[ -f .env ] || export $(grep -v '^#' .env | xargs)
set -e
set -o nounset
export PATH=${PATH}:/src
export PYTHONPATH=/app/src
postgres_ready() {
python << END
import sys
from psycopg2 import connect
from psycopg2.errors import OperationalError
try:
connect(
dbname="${DB_NAME}",
user="${DB_USER}",
password="${DB_PASSWORD}",
)
except OperationalError:
sys.exit(-1)
END
}
wait_other_containers() {
until postgres_ready; do
>&2 echo "Waiting for PostgreSQL to become available..."
sleep 5
done
>&2 echo "PostgreSQL is available"
}
cd /app
case $1 in
"bash")
bash;;
"server")
wait_other_containers ;\
if [ "$FASTAPI_DEBUG" = "true" ]; then
uvicorn \
src.chatcleaner.adapters.entrypoints.api.app:app \
--reload \
--host 0.0.0.0 \
--proxy-headers \
--port 8088
else
uvicorn \
src.chatcleaner.adapters.entrypoints.api.app:app \
--workers 2 \
--host 0.0.0.0 \
--proxy-headers \
--port 8088
fi
;;
"test")
wait_other_containers ;\
pytest -svvv -m "not slow and not integration" tests
;;
"test-last-failed")
wait_other_containers ;\
TEST_RUN="TRUE" pytest -svvv --lf tests
;;
"test-current")
wait_other_containers ;\
pytest -m current --no-header
;;
"test-current-v")
wait_other_containers ;\
pytest -vv -m current --log-cli-level=DEBUG
;;
"test-domain")
wait_other_containers ;\
pytest tests/domain --log-cli-level=DEBUG
;;
"test-int")
wait_other_containers ;\
TEST_RUN="true" pytest tests/integrations --log-cli-level=DEBUG
;;
"test-repos")
wait_other_containers ;\
pytest tests/repositories --log-cli-level=DEBUG
;;
"test-services")
wait_other_containers ;\
pytest tests/services --log-cli-level=DEBUG
;;
"test-uows")
wait_other_containers ;\
pytest tests/unit_of_works --log-cli-level=DEBUG
;;
"test-cov")
wait_other_containers ;\
TEST_RUN="TRUE" pytest -svvv --cov-report html --cov=src tests
;;
"migrations")
wait_other_containers ;\
alembic -c src/chatcleaner/adapters/db/alembic.ini revision --autogenerate
;;
"migrate")
wait_other_containers ;\
alembic -c src/chatcleaner/adapters/db/alembic.ini upgrade head
;;
"*")
exec "$@"
;;
esac