This repository is used internally by some KoboToolbox developers and shared here in the hope that it may be helpful to others. There is ABSOLUTELY NO SUPPORT offered for this code: not in the issue tracker, not in the discussion forum, not via email, not anywhere! You have been warned. If you are seeking to run your own instance of KoboToolbox, you should look at https://github.com/kobotoolbox/kobo-install/, or, for large installs, consider Kubernetes: https://github.com/kobotoolbox/kobo-helm-chart
Clone kpi repo in this directory
- Build
docker compose build --pull
- Start postgres
docker compose up postgres
this ensures it has time to initialize - Run Django database migrations
docker compose run --rm kpi scripts/migrate.sh
- Make user
docker compose run --rm kpi ./manage.py createsuperuser
- Edit
/etc/hosts
and add127.0.0.1 kf.kobo.local ee.kobo.local
- Run
npm i
in the kpi directory.
docker compose up
- Run frontend (in own tab)
cd kpi
andnpm run watch
- KPI http://kf.kobo.local
- EE http://ee.kobo.local:8005 (or localhost:8005)
Mailhog will capture all emails sent, regardless of to address.
- Start mailhog
docker compose -f docker-compose.mailhog.yml up
- Edit
docker-compose.yml
(or copy todocker-compose.override.yml
to preserve original file) and uncommentEMAIL_BACKEND: 'django.core.mail.backends.smtp.EmailBackend'
Go to http://localhost:8025
- Run from inside a container
docker compose exec -it kpi bash
(Assumes application is already running) - Install dev dependencies if not already done
pip install -r dependencies/pip/dev_requirements.txt
- Run Pytest
pytest
or to run on a specific directory and reuse the DB (as a speedup)pytest --reuse-db kobo/apps/foo
.
If python packages in kpi change, you can build like this
docker compose build --pull
Run migrate commands when new migrations are added
Useful to remake databases.
docker compose down
Run first run steps again
Many editors and cli tools can do type checking and type inference. However, it requires setting up a virtual environment.
- Install Python 3 dependencies. For Ubuntu this is
apt install python3-dev python3-venv
- Create Python virtual environment
python3 -m venv env
- Activate environment
source env/bin/activate
- Install packages
pip install -r dependencies/pip/dev_requirements.txt
These are not required but can improve the experience of editing code. Most text editors cannot read these dependencies from the docker container itself.