My Fellowship Journey: Bett Kipchumba

Hi there :wave:t5:

I’m Kipchumba C. Bett, but people call me “Bett” from Eldoret, Kenya. I work as a Software Engineer at AMPATH Kenya. I’d enjoy music, riding my bike, and reading.

On and off, I’ve been a member of this community for some time now. You may have seen my work because I’ve contributed to a number of projects. FHIR support for openmrs, service delivery queues backend, and cohorts are a few examples.

A number of personal circumstances have kept me from embarking on this adventure for some time now. Finally, I’m excited and eager to get started on the fellowship program and concentrate on honing my software engineering skills. In the coming months, I’ll learn more about the community’s ongoing projects and challenges/community priority issues and help come up with solutions. I will also provide mentorship and help review some PRs.

To begin, I’ll be focusing on;

  • Utilizing docker to build and develop openmrs modules.
  • Add support to build and develop using docker to the rest of openmrs modules(at least actively maintained ones).
  • Refactor openmrs-module-basicexample (example module provided by openmrs SDK) to include docker development support
  • Backport Rafal’s changes here to openmrs core maintained branches i.e. 2.5.x, 2.4.x, 2.3.x, …

I’m hoping that with @raff assistance and guidance, I’ll be able to complete the tasks listed above and more especially improve the developer experience.

Lastly, a big thank you to @jennifer for her help and guidance in getting me up and running. Thanks also to @jdick @grace @burke @ibacher @dkayiwa, as well as everyone else we’ve talked to along the way.

~ Bett

6 Likes

Welcome to the fellowship program Bett!! It’s going to be a pleasure to follow your journey in this thread. It’s so good that you’re helping to move OpenMRS containerization forward. Dockerization of OMRS is something I heard interest in from many org representatives across East Africa recently. CC/FYI @rubailly

1 Like

Welcome to the fellowship and good to see you @corneliouzbett

@corneliouzbett I wish you the best in your fellowship journey. Am grateful for having your back during my journey.

Hi @corneliouzbett! How are things going for you lately? How are you finding the work on these areas?

Hi @grace :wave:t5:
It is going on well though slowly. I’m waiting for a review from @raff for this PR, once it’s done, I will be able to apply the same to the rest of the modules.

1 Like

For the recent weeks, I’ve been looking into docker and containerization technology. As a concept it refers to the process of packaging up everything needed to run an application, including runtime dependencies, configuration files, and settings then running the application in a pre-prepared isolated environment.

Docker is a containerization technology that enables for the rapid and easy creation of containers. It runs on Windows, Linux, and MacOS. It is used in both development and production. The intention is harness this technology to better our backend development experience. For my case module development.

Docker support for OpenMRS module development

Note: This is still a work in progress. Feedback is highly appreciated

Pre-requisites

  • Docker - (No maven installation needed)

OpenMRS releases two variants of openmrs-core docker images: nightly and dev. I’m going to focus on the dev image, which is used for development. It contains dev dependencies such as maven and a configured OpenMRS SDK necessary for development purposes only.

Below is a docker-compose.yml template file;

version: "3.8"

services:
  db:
    image: mariadb:10.3
    command: "mysqld --character-set-server=utf8 --collation-server=utf8_general_ci"
    environment:
      MYSQL_DATABASE: ${OPENMRS_DB_NAME:-openmrs}
      MYSQL_USER: ${OPENMRS_DB_USER:-openmrs}
      MYSQL_PASSWORD: ${OPENMRS_DB_PASSWORD:-openmrs}
      MYSQL_ROOT_PASSWORD: ${OPENMRS_DB_ROOT_PASSWORD:-openmrs}
    deploy:
      replicas: '${OPENMRS_DB_REPLICAS:-1}'
      restart_policy:
        max_attempts: 3
    volumes:
      - db-data:/var/lib/mysql

  openmrs-core:
    image: openmrs-core:dev
    ports:
      - "8080:8080"
      - "8000:8000"
    restart: "no"
    environment:
      OMRS_CONFIG_MODULE_WEB_ADMIN: "true"
      OMRS_CONFIG_AUTO_UPDATE_DATABASE: "true"
      OMRS_CONFIG_CREATE_TABLES: "true"
      OMRS_CONFIG_CONNECTION_SERVER: ${OPENMRS_DB_SERVER:-db}
      OMRS_CONFIG_CONNECTION_DATABASE: ${OPENMRS_DB_NAME:-openmrs}
      OMRS_CONFIG_CONNECTION_USERNAME: ${OPENMRS_DB_USER:-openmrs}
      OMRS_CONFIG_CONNECTION_PASSWORD: ${OPENMRS_DB_PASSWORD:-openmrs}
      OMRS_REFRESH_MODULES: ${OMRS_REFRESH_MODULES:-false}
    healthcheck:
      test: [ "CMD", "curl", "-f", "http://localhost:8080/openmrs" ]
      timeout: 5s
    volumes:
      - ${PWD}:/openmrs/module/source
      # mount local m2 repository
      - ~/.m2:/root/.m2
volumes:
  db-data:

With changes from this PR(will be available in the next release of dev image), you only a compose file at the root of your module repository to start developing using docker. Moreover, extra configuration file is needed for a module that depend on other modules in order to run/start e.g queue module or emrapi module. That file would be module.properties(same as disto.properties used by SDK) - specifies the required modules to be download and looks like;

version=0.0.1-DEV
war.openmrs=2.6.0-SNAPSHOT
name=Queue module development
omod.webservices.rest=2.36.0

This leverages the OpenMRS-SDK to download modules specified in the properties. However, we need to modify OpenMRS-SDK to make name, version, war.openmrs optional or add a flag or something along those lines…

I would advise to mount local m2 repo for faster builds.

Any additional module to module.properties or force re-download modules needs a restart and first please set OMRS_REFRESH_MODULES to true

Build

Build module sources using the openmrs-dev docker image.

docker run --rm -w="/module" -v ~/.m2:/root/.m2 -v ${PWD}:/module openmrs/openmrs-core:dev mvn clean install -DskipTests

Module development

To start the OpenMRS development server, execute the command;

docker-compose up -d

Restart the container to deploy changes;

docker-compose restart

Under the hood docker-compose restart will build the current module, re-deploy and restart the OpenMRS development server

Access the container/server logs;

docker-compose logs -f --tail=1000

Connecting to an existing database

To use an existing database, first set the OPENMRS_DB_REPLICAS env variable to 0, then provide the following database connection properties in the .env file:

OPENMRS_DB_SERVER=host.docker.internal  // The database host
OPENMRS_DB_NAME=openmrs
OPENMRS_DB_USER=openmrs
OPENMRS_DB_PASSWORD=openmrs

Thoughts? Improvements?

@Platform_Team @dev5 @dev4 @dev3 @dev2 @dev1

Would you be interested to try out? Let me know :slightly_smiling_face:

8 Likes

thanks @corneliouzbett, we do use the docker tech already at UW,will look through your pr at the weekend to suggest any areas of improvement/thoughts

1 Like