Compare commits

...

2 commits

Author SHA1 Message Date
pedro bab540187c docker: refactor init env vars 2024-09-24 09:52:18 -03:00
pedro b024dd1a11 docker: add optional DEMO env var
that includes the default snapshot import
2024-09-24 09:50:57 -03:00
3 changed files with 13 additions and 4 deletions

View file

@ -1 +1,2 @@
DOMAIN=localhost DOMAIN=localhost
DEMO=false

View file

@ -6,6 +6,7 @@ services:
environment: environment:
- DEBUG=true - DEBUG=true
- DOMAIN=${DOMAIN:-localhost} - DOMAIN=${DOMAIN:-localhost}
- DEMO=${DEMO:-n}
volumes: volumes:
- .:/opt/devicehub-django - .:/opt/devicehub-django
ports: ports:

View file

@ -21,21 +21,28 @@ deploy() {
# inspired by https://medium.com/analytics-vidhya/django-with-docker-and-docker-compose-python-part-2-8415976470cc # inspired by https://medium.com/analytics-vidhya/django-with-docker-and-docker-compose-python-part-2-8415976470cc
echo "INFO detected NEW deployment" echo "INFO detected NEW deployment"
./manage.py migrate ./manage.py migrate
./manage.py add_institution example-org INIT_ORG="${INIT_ORG:-example-org}"
INIT_USER="${INIT_USER:-user@example.org}"
INIT_PASSWD="${INIT_PASSWD:-1234}"
./manage.py add_institution "${INIT_ORG}"
# TODO: one error on add_user, and you don't add user anymore # TODO: one error on add_user, and you don't add user anymore
./manage.py add_user example-org user@example.org 1234 ./manage.py add_user "${INIT_ORG}" "${INIT_USER}" "${INIT_PASSWD}"
if [ "${DEMO:-}" ]; then
./manage.py up_snapshots example/snapshots/ "${INIT_USER}"
fi
fi fi
} }
runserver() { runserver() {
PORT="${PORT:-8000}" PORT="${PORT:-8000}"
if [ "${DEBUG:-}" = "true" ]; then if [ "${DEBUG:-}" ]; then
./manage.py runserver 0.0.0.0:${PORT} ./manage.py runserver 0.0.0.0:${PORT}
else else
# TODO # TODO
#./manage.py collectstatic #./manage.py collectstatic
true true
if [ "${EXPERIMENTAL:-}" = "true" ]; then if [ "${EXPERIMENTAL:-}" ]; then
# TODO # TODO
# reloading on source code changing is a debugging future, maybe better then use debug # reloading on source code changing is a debugging future, maybe better then use debug
# src https://stackoverflow.com/questions/12773763/gunicorn-autoreload-on-source-change/24893069#24893069 # src https://stackoverflow.com/questions/12773763/gunicorn-autoreload-on-source-change/24893069#24893069