From 92321dd740fdff76554304ebaad01abc55ad8ff7 Mon Sep 17 00:00:00 2001 From: "Kipchumba C. Bett" Date: Wed, 13 Jul 2022 11:04:00 +0300 Subject: [PATCH] some refactoring --- README.md | 49 +++++++++++++++++++++++++++++ docker-compose.yml | 4 +-- prepare.sh => prepare-docker-env.sh | 21 ++++++++----- 3 files changed, 64 insertions(+), 10 deletions(-) rename prepare.sh => prepare-docker-env.sh (83%) diff --git a/README.md b/README.md index 2bbf021..f90f65d 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,55 @@ Openmrs-module-queue - Java 8 or higher - Webservices rest module -(Always bundled with the platform) +## Docker development environment +To prepare environment for development of the module, execute the following command; + +```bash +sh prepare-docker-env.sh +``` +The above command will create a directory named `required_modules` in the current directory and install all required modules. +Also, it will create an environment file named `.env` in the current directory and populate it with the following variables: + +``` +# OpenMRS core platform version. +OPENMRS_CORE_VERSION=dev + +# To use an existing database, set the following variables. +OPENMRS_DB=localhost +OPENMRS_DB_NAME=openmrs +OPENMRS_DB_USER=openmrs +OPENMRS_DB_PASSWORD=openmrs + +# To use an existing database, set this variable to 0 +# To create a new database, set this variable to 1 +OPENMRS_DB_REPLICAS=1 + +# OMOD file name +OMOD_TARGET="queue-1.0.0-SNAPSHOT.omod" + +``` +Now, you can spin up an OpenMRS instance with the `required_modules` by executing the following command; + +```bash +docker-compose up -d +``` + +To deploy module changes, run the following command; + +```bash + docker run --rm -w="/module" -v ${PWD}:/module openmrs/openmrs-core:dev-m1 mvn clean install +``` +Or if you already have maven installed on your system, you can use the following command; + +```bash +mvn clean install +``` +Then, you can restart the container(OpenMRS instance) by executing the following command; + +```bash +docker-compose restart +``` + ## Configurations After installing the queue module, configure the following GPs according to your implementation needs. Note that this is a diff --git a/docker-compose.yml b/docker-compose.yml index 69b8894..87c9c52 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,8 +18,8 @@ services: MYSQL_PASSWORD: ${OPENMRS_DB_PASSWORD:-openmrs} MYSQL_ROOT_PASSWORD: ${OPENMRS_DB_ROOT_PASSWORD:-openmrs} deploy: - #replicas: ${OPENMRS_DB_REPLICAS} - replicas: 0 + replicas: '${OPENMRS_DB_REPLICAS}' + #replicas: 0 restart_policy: max_attempts: 3 volumes: diff --git a/prepare.sh b/prepare-docker-env.sh similarity index 83% rename from prepare.sh rename to prepare-docker-env.sh index c4aa242..a03e440 100644 --- a/prepare.sh +++ b/prepare-docker-env.sh @@ -23,21 +23,26 @@ echo "Current version: $OMOD_NAME-$OMOD_VERSION" installMaven() { # Linux/unix - # TODO: Find a better way to do this + # TODO: Find a better way to do this (No mvn install needed) sh install-maven.sh } createEnvironmentVariablesFile() { cat <.env +# OpenMRS core platform version. OPENMRS_CORE_VERSION=dev +# To use an existing database, set the following variables. OPENMRS_DB=localhost OPENMRS_DB_NAME=openmrs OPENMRS_DB_USER=openmrs OPENMRS_DB_PASSWORD=openmrs -OPENMRS_DB_REPLICAS=0 -#Omod file name +# To use an existing database, set this variable to 0 +# To create a new database, set this variable to 1 +OPENMRS_DB_REPLICAS=1 + +# OMOD file name OMOD_TARGET="$OMOD_NAME-$OMOD_VERSION.omod" EOF } @@ -49,10 +54,10 @@ setupOpenmrsSDK() { } downloadArtifacts() { - #prepare the dir + # Prepare the modules dir if [ -d "${MODULES_DIR}" ]; then echo "${MODULES_DIR} dir is already exists." - #Remove contents + # Remove contents rm -rf "${MODULES_DIR:?}/"* else echo "Creating ${MODULES_DIR} directory..." @@ -73,8 +78,8 @@ if [ -x "$(command -v docker)" ]; then echo "Installed ${installed_docker_version}" echo "configuring openmrs sdk..." - #docker run openmrs/openmrs-core:dev - #docker run openmrs/openmrs-core:dev mvn + # docker run openmrs/openmrs-core:dev + # docker run openmrs/openmrs-core:dev mvn if ! command -v mvn -v &>/dev/null; then echo "Installing maven..." @@ -85,5 +90,5 @@ if [ -x "$(command -v docker)" ]; then downloadArtifacts createEnvironmentVariablesFile else - printf "Please install Docker and re-run setup script.\n" + printf "Please install Docker and re-run prepare script.\n" fi