Hosting > 3.x > Production Hosting - Docker
Hosting the CHT on self run infrastructure
Most production CHT instances are deployed on AWS EC2. Leveraging Elastic Compute Cloud (EC2) and Elastic Block Store (EBS), CHT instances can easily be scaled up with larger EC2 instances and have easy increased disk space, backup and restores with EBS.
This guide will walk you through the process of creating an EC2 instance, mounting an EBS volume and provisioning Docker containers.
Create EC2 (use security best practices)
Review the CHT hardware requirements and start with an appropriately sized instance. After creating the instance and downloading the .pem
file, change permissions to 0600
for it:
sudo chmod 0600 ~/Downloads/name_of_file.pem
Create an Elastic IP (EIP) and associate the EIP to your EC2 instance.
You should now be able to SSH into the EC2 instance using the EIP and the .pem
file.
Goal
: SSH into instance
Create or Restore EBS Volume
sudo mkfs -t ext4 <location>
in step 4/srv
Goal
: Mount EBS volume to /srv
Provision Docker server
Follow README & Run scripts in cht-infrastructure repository.
Goal
: CHT Application bootstraps and comes online
DNS configuration
A
record to EIP given to Docker server in the prior step.Review SSL certificates
/srv/settings/medic-core/nginx/private/
default.key
and the certificate file is default.crt
Configure CHT Sync See the CHT Sync configuration.
Setup postgres to work with CHT Sync
Debugging CHT Sync/postgres
Restarting processes
/boot/svc-<start/stop/restart> <service-name/medic-api/medic-sentinel/medic-core couchdb/medic-core nginx>
Investigating logs inside Medic OS
docker exec -it medic-os /bin/bash
less /srv/storage/medic-core/couchdb/logs/startup.log
less /srv/storage/medic-api/logs/medic-api.log
less /srv/storage/medic-sentinel/logs/medic-sentinel.log
Investigating docker stderr/stdout logs
sudo docker logs medic-os
sudo docker logs haproxy
Upgrading the container
Backup all data (EBS)
Log into container and stop all services
To prepare for the upgrade, delete all other files in /srv
EXCEPT for /srv/storage/medic-core/
The medic-core
directory is where the CHT stores user data. Of key importance is ./couchdb/local.in
and ./medic-core/couchdb/local.d/
where custom CouchDB configuration is stored.
Change the image tag to the final Medic OS image release version (cht-3.9.0-rc.2
) in the docker compose file:
services:
medic-os:
image: medicmobile/medic-os:cht-3.9.0-rc.2
Launch new containers with appropriate COUCHDB_ADMIN_PASSWORD
& HA_PASSWORD
environment variables
Upgrading the webapp
RDS help
Configure backups
Restoring from backup
supvisorctl
/boot/supervisor-inspect
Monitor disk usage so alerts are sent before all disk spaces is used up. If free disk space falls below 40%, increase the disk space as follows:
sudo supervisorctl stop medic
sudo supervisorctl start medic
Hosting the CHT on self run infrastructure
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.