Skip to content

Commit

Permalink
Zero installation/configuration but docker
Browse files Browse the repository at this point in the history
  • Loading branch information
corneliouzbett committed Jul 13, 2022
1 parent 92321dd commit f6f42b2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 77 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Openmrs-module-queue
- Webservices rest module -(Always bundled with the platform)

## Docker development environment
To prepare environment for development of the module, execute the following command;
Prepare the docker development environment by executing the following command;

```bash
sh prepare-docker-env.sh
Expand All @@ -40,7 +40,7 @@ OPENMRS_DB_REPLICAS=1
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;
Now, spin up an OpenMRS instance with`required_modules` by executing the following command;

```bash
docker-compose up -d
Expand All @@ -51,12 +51,12 @@ 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;
Or if you already have maven installed on your system, use the following command;

```bash
mvn clean install
```
Then, you can restart the container(OpenMRS instance) by executing the following command;
Then, restart the container(OpenMRS instance) by executing the following command;

```bash
docker-compose restart
Expand Down
32 changes: 0 additions & 32 deletions install-maven.sh

This file was deleted.

63 changes: 22 additions & 41 deletions prepare-docker-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,19 @@ set -e
# Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
# graphic logo is a trademark of OpenMRS Inc.

# This script is used to setup the development environment for the module.
# It is run once when the project is first clone/created.
# This script is used to setup the development environment for this module.
# It should be run once when the project is first clone/created.
# Downloads the required openmrs modules and installs them.

OPENMRS_SDK_PLUGIN="org.openmrs.maven.plugins:openmrs-sdk-maven-plugin"
MODULES_DIR="required_modules"

#Extract project artifactId & version
# Extract project artifactId & version
OMOD_NAME=$(mvn help:evaluate -Dexpression=project.artifactId | grep -e '^[^\[]')
OMOD_VERSION=$(mvn help:evaluate -Dexpression=project.version | grep -e '^[^\[]')
echo "Current version: $OMOD_NAME-$OMOD_VERSION"

installMaven() {
# Linux/unix
# TODO: Find a better way to do this (No mvn install needed)
sh install-maven.sh
}

createEnvironmentVariablesFile() {
create_environment_variables_file() {
cat <<EOF >.env
# OpenMRS core platform version.
OPENMRS_CORE_VERSION=dev
Expand All @@ -47,48 +41,35 @@ OMOD_TARGET="$OMOD_NAME-$OMOD_VERSION.omod"
EOF
}

setupOpenmrsSDK() {
# Setup SDK
mvn ${OPENMRS_SDK_PLUGIN}:setup-sdk -DbatchAnswers=n -B
#docker run -it -v maven-repo:/root/.m2 maven mvn ${OPENMRS_SDK_PLUGIN}:setup-sdk -DbatchAnswers=n -B
prepare_modules_directory() {
# prepare modules directory
if [ -d "${MODULES_DIR}" ]; then
echo "${MODULES_DIR} dir is already exists."
# remove contents
rm -rf "${MODULES_DIR:?}/"*
else
echo "Creating ${MODULES_DIR} directory..."
mkdir -p "${MODULES_DIR}"
fi
}

downloadArtifacts() {
# Prepare the modules dir
if [ -d "${MODULES_DIR}" ]; then
echo "${MODULES_DIR} dir is already exists."
# Remove contents
rm -rf "${MODULES_DIR:?}/"*
else
echo "Creating ${MODULES_DIR} directory..."
mkdir -p "${MODULES_DIR}"
fi

download_artifacts() {
mkdir -p artifacts
# Download modules
#docker run -it openmrs/openmrs-core:dev-m1 mvn "$OPENMRS_SDK_PLUGIN":build-distro -Ddistro=module.properties -Ddir=artifacts -B
mvn ${OPENMRS_SDK_PLUGIN}:build-distro -Ddistro=module.properties -Ddir=artifacts -B
# download modules
docker run --rm -w="/module" -v ${PWD}:/module openmrs/openmrs-core:dev mvn ${OPENMRS_SDK_PLUGIN}:build-distro -Ddistro=module.properties -Ddir=artifacts -B
# copy downloaded modules to ${MODULES_DIR} directory
cp -r artifacts/web/modules/* "${MODULES_DIR}"
# Clean up artifacts
# clean up artifacts
rm -rf artifacts
}

if [ -x "$(command -v docker)" ]; then
installed_docker_version=$(docker --version)
echo "Installed ${installed_docker_version}"
echo "configuring openmrs sdk..."

# docker run openmrs/openmrs-core:dev
# docker run openmrs/openmrs-core:dev mvn

if ! command -v mvn -v &>/dev/null; then
echo "Installing maven..."
installMaven
fi

setupOpenmrsSDK
downloadArtifacts
createEnvironmentVariablesFile
prepare_modules_directory
download_artifacts
create_environment_variables_file
else
printf "Please install Docker and re-run prepare script.\n"
fi

0 comments on commit f6f42b2

Please sign in to comment.