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 3f385d1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 72 deletions.
32 changes: 0 additions & 32 deletions install-maven.sh

This file was deleted.

61 changes: 21 additions & 40 deletions prepare-docker-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ 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"
Expand All @@ -21,13 +21,7 @@ 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 -it openmrs/openmrs-core:dev mvn openmrs-sdk:build-distro -Ddistro=module.properties -Ddir=artifacts -B
#mvn ${OPENMRS_SDK_PLUGIN}:build-distro -Ddistro=module.properties -Ddir=artifacts -B
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 3f385d1

Please sign in to comment.