-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·112 lines (103 loc) · 2.35 KB
/
entrypoint.sh
File metadata and controls
executable file
·112 lines (103 loc) · 2.35 KB
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
#!/bin/bash
set -e
# This script is used as the entrypoint for docker when used for local dev
show_help() {
echo """
Commands
---------------------------------------------------------------
start : start django + uwsgi
start_dev : start django devserver
start_webpack : start webpack server (only in DEV mode)
manage : run django manage.py
eval : eval shell command
bash : run bash
"""
}
export PYTHONPATH="/opt/app:$PYTHONPATH"
if [ -e hat/local_settings.py ]
then
export DJANGO_SETTINGS_MODULE=hat.local_settings
else
export DJANGO_SETTINGS_MODULE=hat.settings
fi
case "$1" in
"start")
./scripts/wait_for_dbs.sh
./manage.py migrate --noinput
./manage.py runserver 0.0.0.0:8081
;;
"start_gunicorn")
./scripts/wait_for_dbs.sh
./manage.py migrate --noinput
gunicorn hat.wsgi --workers 2 --threads=4 --bind=0.0.0.0:8081
;;
"test" )
export TESTING=true
# Linting tasks first
ruff check ./hat
npm run lint
# Then tests
./scripts/wait_for_dbs.sh
# Run python tests and pass on any args to e.g. run individual tests
./manage.py test --exclude-tag selenium "${@:2}"
npm run test
;;
"test_lint" )
export TESTING=true
ruff check -v ./hat
npm run lint
;;
"test_js" )
npm run test
;;
"vitest" )
npm run test
;;
"vitest_watch" )
npm run test:watch
;;
"gen_docs" )
./scripts/gen_docs.sh
;;
"start_dev" )
export DEV_SERVER=true
./scripts/wait_for_dbs.sh
./manage.py migrate --noinput
./manage.py createcachetable
./manage.py compile_translations
./manage.py runserver 0.0.0.0:8081
;;
"start_celery_beat" )
celery -A hat beat -l info --scheduler "django_celery_beat.schedulers:DatabaseScheduler"
;;
"start_celery_worker" )
celery -A hat worker -l info --without-heartbeat
;;
"start_webpack" )
# if TEST_PROD, make a static js bundle otherwise launch js dev server
if [ -n "$TEST_PROD" ]; then
npm run webpack-prod
exit 0
fi
npm run webpack-server
;;
"manage" )
./manage.py "${@:2}"
;;
"eval" )
eval "${@:2}"
;;
"bash" )
bash
;;
"python" )
python "${@:2}"
;;
* )
if [[ $2 == /opt/.pycharm_helpers/* || $2 == /opt/project/manage.py ]]; then
"${@}"
else
show_help
fi
;;
esac