this is not an official kobotoolbox repository, okay?
fighting complexity with simplicity by making humans do more work
As a developer, I would like to run things I don't change inside Docker (PostgreSQL, Redis, MongoDB, and—for now—Enketo Express). I would like full, manual control over running code that I do change (kpi Python and kpi JS). I would like simplicity in configuration with sensible defaults and a minimum of mandatory customization.
currently empty?!? 😮
- clone https://github.com/kobotoolbox/kpi if you haven't already
docker-compose up, which should yield:- nginx listening at 10.6.6.1 on port 9000
- this will reverse-proxy to kpi because the application does not run properly without nginx
- enketo running on 10.6.6.1:9001
- postgres, on 10.6.6.1:60666
- redis, on 10.6.6.1:60667
- mongo, on 10.6.6.1:60668
- nginx listening at 10.6.6.1 on port 9000
- install os-level dependencies (sorry):
sudo apt install python3.12-venv gcc python3-dev gdal-bin libpq-dev- more about GDAL here (it's required during migrations. and it's only required then?)
- you'll also need docker and the compose plugin; tested with docker 27.2.1 and compose 2.29.2
python3 -m venv kpienv- tested with Python 3.12.3 on Ubuntu 24.04
- set up a python development environment for kpi!
. kpienv/bin/activate. envfilepip install pip-toolscdinto your kpi source directorypip-sync dependencies/pip/dev_requirements.txtscripts/migrate.sh./manage.py runserver 10.6.6.1:9010⚠️ not just any ol'runserver, okay?
- set up a javascript development environment for kpi!
- open a new terminal
cdinto your kpi source directorynvm use 20.17.0, or whatever you cool kids likenpm installnpm run watch- are you lucky today? i am!
webpack 5.92.1 compiled successfully in 16285 ms
- are you lucky today? i am!
🥧 "don't forget to manage your pie"
- django is set to use the console email backend, so you can do things like
create user accounts and read the activation email details right from the
output of
./manage.py runserver 10.6.6.1:9010 - it might also be helpful to have a superuser account:
- go to the terminal where kpi
./manage.py runserver 10.6.6.1:9010is running - press ctrl+z to suspend
runserver ./manage.py createsuperuser- once you're done, type
fgand press enter to bringrunserverback to the foreground
- go to the terminal where kpi
- help! i want to switch branches!
- you're generally responsible for knowing how to use
./manage.py migrateand its wrapperscripts/migrate.shto apply database migrations (or revert them, by migrating backwards)- fyi, when going backwards, django lingo for the migration before
0001iszero
- fyi, when going backwards, django lingo for the migration before
- let's say you'd like to back up your databases and start
from scratch to avoid migration hassles:
- stop
⚠️ the database servers withdocker-compose stop - rename the
storagedirectory to something else - restart the database servers with
docker-compose up - check out the new branch you'd like to use
- re-run
scripts/migrate.sh - you'll also have to recreate user accounts
- stop
- you're generally responsible for knowing how to use
- periodic tasks (
celery beat) are completely ignored for the sake of simplicity apt install gdal-binon the host unavoidable?- "
pyuwsgiis the exact same code asuwsgibut" actually has binary wheels?- it'd sure be nice not to compile uwsgi from source
- then we could remove
gccandpython3-devrequirements
- then we could remove
- unbit/uwsgi#1218 (comment)
- it'd sure be nice not to compile uwsgi from source
psycopg2-binary"is a practical choice for development and testing but in production it is advised to use the package built from sources."- the "why" is described here
- for now, this means
libpq-devmust be installed to avoid messing with Python requirements