This is a quick guide on how to easily create a DHIS2 instance on your local machine and setup the DHIS2 CLI.
Some of the benefits of using local instances are: (1) we can run multiple different DHIS2 versions at the same time and (2) testing is easier as the DHIS2 server runs locally and is not dependent on a network connection.
These steps will help you quickly spin up a server and get you started with DHIS2 application development!
First, make sure to install the following 👇
d2 command-line tool with
d2 --help for more information on available commands.
The d2 cluster command will allow you to launch a new cluster and create a DHIS2 instance using Docker containers. From your terminal, run the following:
The command above uses the
d2 cluster tool with the
up command, the
--db-version flag and the
--seed flag to spin up a new DHIS2 2.35.0 instance seeded with data from the Sierra Leone demo database.
Note: Once the
up command completes, the server might take up to a couple of minutes to start. You can then run
d2 cluster logs 2.35.0 and wait until you see the line
Server startup in xxx ms.
If you want to test against different DHIS2 and database versions or build your own custom DHIS2 Docker image, please refer to the d2 cluster docs.
After the above command has completed you can check your newly created cluster that's running locally at http://localhost:8080/. If DHIS2 is running, you should see the following page:
Login to your instance:
down command followed by the name of the cluster shuts down all Docker processes connected to that cluster.