Skip to content

Commit

Permalink
some refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
corneliouzbett committed Jul 13, 2022
1 parent 9c2e3cf commit 92321dd
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 10 deletions.
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
21 changes: 13 additions & 8 deletions prepare.sh → prepare-docker-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF >.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
}
Expand All @@ -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..."
Expand All @@ -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..."
Expand All @@ -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

0 comments on commit 92321dd

Please sign in to comment.