Difference between revisions of "Kobo Docker Setup"
m |
(Tag: visualeditor-switched) |
||
Line 1: | Line 1: | ||
− | + | === Decide upon the location === | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | $ cd /home/ate | |
− | + | $ git clone https://github.com/kobotoolbox/kobo-docker.git | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | git clone https://github.com/kobotoolbox/kobo-docker.git | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | The working tree repository will be created in the directory kobo.docker, i.e. /home/ate/kobo-docker. If required, the folder can be renamed: | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | docker | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | docker | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | $ mv kobo-docker new-name | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | ...but we will leave it at /home/ate/kobo-docker/. Systemwide variable: | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | docker | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | docker- | + | $ sudo nano /etc/profile.d/kobo-docker.sh |
− | docker-compose | + | <blockquote><pre>export KOBO_DOCKER="/home/ate/kobo-docker"</pre></blockquote> |
− | docker-compose | + | |
− | docker- | + | This will define the system-wide (environment) variable, available to all users. |
− | + | ||
− | docker-compose | + | $ cd $KOBO_DOCKER && pwd |
− | docker-compose | + | <blockquote><pre>/home/ate/kobo-docker</pre></blockquote> |
− | docker-compose up | + | |
− | docker-compose stop | + | {{KOBO_DOCKER}} |
− | + | ||
− | + | === Configure KoBo Docker === | |
− | + | $ ln -s docker-compose.server.yml docker-compose.yml | |
− | + | $ sudo docker-compose pull | |
− | + | $ docker-compose build | |
− | + | $ nano envfile.server.txt | |
− | + | <blockquote><pre># The publicly-accessible domain where your KoBo Toolbox instance will be reached. | |
− | + | PUBLIC_DOMAIN_NAME=msf.org | |
− | + | # The publicly-accessible subdomain for the KoBoForm form building and management interface. | |
+ | KOBOFORM_PUBLIC_SUBDOMAIN=kobo | ||
+ | # The publicly-accessible subdomain for the KoBoCAT data collection and project management interface. | ||
+ | KOBOCAT_PUBLIC_SUBDOMAIN=kc | ||
+ | # The publicly-accessible subdomain for the Enketo Express web forms. | ||
+ | ENKETO_EXPRESS_PUBLIC_SUBDOMAIN=ee | ||
+ | # See "api key" here: https://github.com/kobotoolbox/enketo-express/tree/master/config#linked-form-and-data-server. | ||
+ | ENKETO_API_TOKEN=fAvPevhvWb1w79XQxSabMKN9mW | ||
+ | # Canonically a 50-character random string. See https://docs.djangoproject.com/en/1.8/ref/settings/#secret-key and https://docs.djangoproject.com/en/1.8/ref/settings/#secret-key. | ||
+ | DJANGO_SECRET_KEY=QE7Vwf7uqYJ8LgLaEZLC9f3AebTCX8DPukue46tYAU7ZyVTbXX | ||
+ | # The initial superuser's username. | ||
+ | KOBO_SUPERUSER_USERNAME=msfuser | ||
+ | # The initial superuser's password. | ||
+ | KOBO_SUPERUSER_PASSWORD=msfOCB1971 | ||
+ | |||
+ | ###################### | ||
+ | # Optional variables # | ||
+ | ###################### | ||
+ | |||
+ | # For help customizing backup schedules, use a `cron` schedule generator (e.g. | ||
+ | # crontab.guru). To enable a backup, uncomment the relevant schedule. | ||
+ | # Default KoBoCAT media backup schedule is weekly at 12:00 AM UTC on Sunday. | ||
+ | KOBOCAT_MEDIA_BACKUP_SCHEDULE=59 2 * * * | ||
+ | # Default MongoDB backup schedule is weekly at 01:00 AM UTC on Sunday. | ||
+ | MONGO_BACKUP_SCHEDULE=57 2 * * * | ||
+ | # Default Postgres backup schedule is weekly at 02:00 AM UTC on Sunday. | ||
+ | POSTGRES_BACKUP_SCHEDULE=52 2 * * *</pre></blockquote> | ||
+ | |||
+ | $ sudo nano envfiles/smtp.txt | ||
+ | |||
+ | <blockquote><pre>EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend | ||
+ | EMAIL_HOST=192.168.60.4 | ||
+ | EMAIL_PORT=25 | ||
+ | #EMAIL_HOST_USER= | ||
+ | #EMAIL_HOST_PASSWORD= | ||
+ | #EMAIL_USE_TLS= | ||
+ | #DEFAULT_FROM_EMAIL=</pre></blockquote> | ||
+ | |||
+ | === Configure SSL Certificates === | ||
+ | |||
+ | $ mkdir secrets && cd secrets/ | ||
+ | $ nano ssl.crt | ||
+ | $ nano ssl.key | ||
+ | |||
+ | Please refer to the article [[SSL Setup]] for more information. | ||
+ | |||
+ | === Start the system! === | ||
+ | |||
+ | $ sudo docker-compose up -d | ||
+ | $ sudo docker ps | ||
+ | |||
+ | <blockquote><pre> Name Command State Ports< | ||
+ | ------------------------------------------------------------------------------------------------------------ | ||
+ | kobodocker_nginx_1 /sbin/my_init Up 0.0.0.0:443->443/tcp, 0.0.0.0:80->80/tcp | ||
+ | kobodocker_enketo_express_1 /sbin/my_init Up 8005/tcp | ||
+ | kobodocker_kobocat_1 /sbin/my_init Up 8000/tcp | ||
+ | kobodocker_kpi_1 /sbin/my_init Up 8000/tcp | ||
+ | kobodocker_mongo_1 /sbin/my_init Up 27017/tcp | ||
+ | kobodocker_postgres_1 /sbin/my_init Up 5432/tcp | ||
+ | kobodocker_rabbit_1 /sbin/my_init Up 5672/tcp | ||
+ | kobodocker_redis_cache_1 /entrypoint.sh redis-server Up 6379/tcp | ||
+ | kobodocker_redis_main_1 /entrypoint.sh redis-server Up 6379/tcp</pre></blockquote> | ||
+ | |||
+ | [[File:KoBo-Toolbox-Diagram.png|thumb|150x150px|left]] Are the names on the list familiar? They should be - it is our (living and breathing) instance of the system laid out in the article [[KoBo Toolbox Architecture]]. | ||
+ | |||
+ | '''Well done!''' | ||
+ | |||
+ | Your KoBo Toolbox has now been set up, and you should be able to log into the system with the initial username and password, as provided in <code>envfile.server.txt</code>. | ||
+ | |||
+ | Should you require to stop KoBo Toolbox, issue the following command: | ||
+ | $ sudo docker-compose down | ||
+ | ==== Make Kobo start with the OS ==== | ||
+ | To make the system start with OS, i.e. restart on every reboot, the following steps are necessary | ||
+ | $ sudo nano /etc/systemd/system/kobo-toolbox.service | ||
+ | |||
+ | <blockquote><pre>[Unit] | ||
+ | Description=Kobo Toolbox containers | ||
+ | Requires=docker.service | ||
+ | After=docker.service | ||
+ | |||
+ | [Service] | ||
+ | Restart=always | ||
+ | ExecStart=/usr/local/bin/docker-compose -f /home/ate/kobo-docker/docker-compose.server.yml up | ||
+ | ExecStop=/usr/local/bin/docker-compose -f /home/ate/kobo-docker/docker-compose.server.yml stop | ||
+ | |||
+ | [Install] | ||
+ | WantedBy=default.target</pre></blockquote> | ||
+ | |||
+ | $ sudo ln -s /etc/systemd/system/kobo-toolbox.service /etc/systemd/system/default.target.wants/kobo-toolbox.service | ||
+ | $ sudo systemctl enable kobo-toolbox.service | ||
+ | |||
+ | ...and we are ready for system reboot. | ||
+ | |||
+ | For additional information, please familiarise yourself woth [https://github.com/kobotoolbox/kobo-docker|Kobo Docker setup at Github] | ||
+ | |||
+ | Raw bash history can be found [[Kobo Docker Setup Raw BASH history|here]]. |
Revision as of 09:19, 21 December 2016
Contents
Decide upon the location
$ cd /home/ate $ git clone https://github.com/kobotoolbox/kobo-docker.git
The working tree repository will be created in the directory kobo.docker, i.e. /home/ate/kobo-docker. If required, the folder can be renamed:
$ mv kobo-docker new-name
...but we will leave it at /home/ate/kobo-docker/. Systemwide variable:
$ sudo nano /etc/profile.d/kobo-docker.sh
export KOBO_DOCKER="/home/ate/kobo-docker"
This will define the system-wide (environment) variable, available to all users.
$ cd $KOBO_DOCKER && pwd
/home/ate/kobo-docker
KOBO_DOCKER=/home/ate/kobo-docker/
Configure KoBo Docker
$ ln -s docker-compose.server.yml docker-compose.yml $ sudo docker-compose pull $ docker-compose build $ nano envfile.server.txt
# The publicly-accessible domain where your KoBo Toolbox instance will be reached. PUBLIC_DOMAIN_NAME=msf.org # The publicly-accessible subdomain for the KoBoForm form building and management interface. KOBOFORM_PUBLIC_SUBDOMAIN=kobo # The publicly-accessible subdomain for the KoBoCAT data collection and project management interface. KOBOCAT_PUBLIC_SUBDOMAIN=kc # The publicly-accessible subdomain for the Enketo Express web forms. ENKETO_EXPRESS_PUBLIC_SUBDOMAIN=ee # See "api key" here: https://github.com/kobotoolbox/enketo-express/tree/master/config#linked-form-and-data-server. ENKETO_API_TOKEN=fAvPevhvWb1w79XQxSabMKN9mW # Canonically a 50-character random string. See https://docs.djangoproject.com/en/1.8/ref/settings/#secret-key and https://docs.djangoproject.com/en/1.8/ref/settings/#secret-key. DJANGO_SECRET_KEY=QE7Vwf7uqYJ8LgLaEZLC9f3AebTCX8DPukue46tYAU7ZyVTbXX # The initial superuser's username. KOBO_SUPERUSER_USERNAME=msfuser # The initial superuser's password. KOBO_SUPERUSER_PASSWORD=msfOCB1971 ###################### # Optional variables # ###################### # For help customizing backup schedules, use a `cron` schedule generator (e.g. # crontab.guru). To enable a backup, uncomment the relevant schedule. # Default KoBoCAT media backup schedule is weekly at 12:00 AM UTC on Sunday. KOBOCAT_MEDIA_BACKUP_SCHEDULE=59 2 * * * # Default MongoDB backup schedule is weekly at 01:00 AM UTC on Sunday. MONGO_BACKUP_SCHEDULE=57 2 * * * # Default Postgres backup schedule is weekly at 02:00 AM UTC on Sunday. POSTGRES_BACKUP_SCHEDULE=52 2 * * *
$ sudo nano envfiles/smtp.txt
EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend EMAIL_HOST=192.168.60.4 EMAIL_PORT=25 #EMAIL_HOST_USER= #EMAIL_HOST_PASSWORD= #EMAIL_USE_TLS= #DEFAULT_FROM_EMAIL=
Configure SSL Certificates
$ mkdir secrets && cd secrets/ $ nano ssl.crt $ nano ssl.key
Please refer to the article SSL Setup for more information.
Start the system!
$ sudo docker-compose up -d $ sudo docker ps
Are the names on the list familiar? They should be - it is our (living and breathing) instance of the system laid out in the article KoBo Toolbox Architecture.Name Command State Ports< ------------------------------------------------------------------------------------------------------------ kobodocker_nginx_1 /sbin/my_init Up 0.0.0.0:443->443/tcp, 0.0.0.0:80->80/tcp kobodocker_enketo_express_1 /sbin/my_init Up 8005/tcp kobodocker_kobocat_1 /sbin/my_init Up 8000/tcp kobodocker_kpi_1 /sbin/my_init Up 8000/tcp kobodocker_mongo_1 /sbin/my_init Up 27017/tcp kobodocker_postgres_1 /sbin/my_init Up 5432/tcp kobodocker_rabbit_1 /sbin/my_init Up 5672/tcp kobodocker_redis_cache_1 /entrypoint.sh redis-server Up 6379/tcp kobodocker_redis_main_1 /entrypoint.sh redis-server Up 6379/tcp
Well done!
Your KoBo Toolbox has now been set up, and you should be able to log into the system with the initial username and password, as provided in envfile.server.txt
.
Should you require to stop KoBo Toolbox, issue the following command:
$ sudo docker-compose down
Make Kobo start with the OS
To make the system start with OS, i.e. restart on every reboot, the following steps are necessary
$ sudo nano /etc/systemd/system/kobo-toolbox.service
[Unit] Description=Kobo Toolbox containers Requires=docker.service After=docker.service [Service] Restart=always ExecStart=/usr/local/bin/docker-compose -f /home/ate/kobo-docker/docker-compose.server.yml up ExecStop=/usr/local/bin/docker-compose -f /home/ate/kobo-docker/docker-compose.server.yml stop [Install] WantedBy=default.target
$ sudo ln -s /etc/systemd/system/kobo-toolbox.service /etc/systemd/system/default.target.wants/kobo-toolbox.service $ sudo systemctl enable kobo-toolbox.service
...and we are ready for system reboot.
For additional information, please familiarise yourself woth Docker setup at Github
Raw bash history can be found here.