Skip to content

Commit

Permalink
Improved DX (makefile and docker-compose). (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
zerai authored Jan 14, 2024
1 parent 0736622 commit a2db4fa
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 0 deletions.
133 changes: 133 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
#
# This file contains the custom commands and/or aliases.
#
# To use it, run make <command>.
# To see the command list run make help

#

# Mute all `make` specific output. Comment this out to get some debug information.
.SILENT:

# make commands be run with `bash` instead of the default `sh`
SHELL='/bin/bash'

# .DEFAULT: If command does not exist in this makefile
# default: If no command was specified:
.DEFAULT default:
if [ "$@" != "" ]; then echo "Command '$@' not found."; fi;
$(MAKE) help # goes to the main Makefile
if [ "$@" != "" ]; then exit 2; fi;

help:
@echo
@echo "Available custom commands:"
@grep '^[^#[:space:]].*:' Makefile | grep -v '^help' | grep -v '^default' | grep -v '^\.' | grep -v '=' | grep -v '^_' | sed 's/://' | xargs -n 1 echo ' -'

########################################################################################################################

# stable available openemr release: v7_0_2|v7_0_1_1|v7_0_1|v7_0_0_2|v5_0_2|v5_0_2_1|v5_0_2_2|v5_0_2_3
# develop available openemr branch: master

ifndef OE_RELEASE_ENV
OE_RELEASE_ENV=v7_0_1
OE_DEVELOPMENT_ENV=development-easy
OE_DOCKER_COMPOSE_FILE=./../openemr-instance/${OE_RELEASE_ENV}/docker/${OE_DEVELOPMENT_ENV}/docker-compose.yml -f docker-compose-module.yml
endif

ifndef MODULE_ENV
MODULE_ENV=medicalmundi/oe-module-npi-registry
endif

release-download:
echo
echo "Download Openemr:${OE_RELEASE_ENV}"
git clone https://github.com/openemr/openemr.git -b ${OE_RELEASE_ENV} ./../openemr-release/${OE_RELEASE_ENV}
echo
echo "Openemr:${OE_RELEASE_ENV} downloaded"

release-remove:
echo "Remove release folder for Openemr:${OE_RELEASE_ENV}"
rm -fR var/openemr-release/${OE_RELEASE_ENV}


instance-init:
echo "Init Openemr instance version: ${OE_RELEASE_ENV}"
rm -fR ./../openemr-instance/${OE_RELEASE_ENV}/
cp -fR ./../openemr-release/${OE_RELEASE_ENV}/ ./../openemr-instance/${OE_RELEASE_ENV}

instance-start:
echo "Start Openemr instance version: ${OE_RELEASE_ENV}"
docker-compose -f ${OE_DOCKER_COMPOSE_FILE} up -d
$(MAKE) instance-fix-permission
docker-compose -f ${OE_DOCKER_COMPOSE_FILE} exec -T openemr chown -R apache:apache /oe-module-npi-registry
$(MAKE) instance-status
$(MAKE) instance-log

instance-stop:
echo "Stop Openemr instance version: ${OE_RELEASE_ENV}"
docker-compose -f ${OE_DOCKER_COMPOSE_FILE} down

instance-status:
echo "Check Openemr instance status: ${OE_RELEASE_ENV}"
docker-compose -f ${OE_DOCKER_COMPOSE_FILE} ps

instance-log:
echo "Check Openemr instance status: ${OE_RELEASE_ENV}"
docker-compose -f ${OE_DOCKER_COMPOSE_FILE} logs -f openemr

instance-clean:
echo "Stop and Clean Openemr instance version: ${OE_RELEASE_ENV}"
$(MAKE) instance-stop
echo "Clean Openemr volumes for instance version: ${OE_RELEASE_ENV}"
docker-compose -f ${OE_DOCKER_COMPOSE_FILE} down -v

instance-fix-permission:
echo "Fix file & folder permission in Openemr instance version: ${OE_RELEASE_ENV}"
docker-compose -f ${OE_DOCKER_COMPOSE_FILE} exec -T openemr chown -R apache:apache /var/www/localhost/htdocs/openemr

instance-shell:
echo "Entering in Openemr instance version: ${OE_RELEASE_ENV}"
docker-compose -f ${OE_DOCKER_COMPOSE_FILE} exec openemr sh

config-oe-instance:
echo "Config Openemr instance version: ${OE_RELEASE_ENV}"
docker-compose -f ${OE_DOCKER_COMPOSE_FILE} exec -T openemr php -f /var/www/localhost/htdocs/openemr/contrib/util/installScripts/InstallerAuto.php rootpass=root server=mysql loginhost=%

tail-error:
docker-compose -f ${OE_DOCKER_COMPOSE_FILE} exec -T openemr tail -f /var/log/apache2/error.log

tail-access:
docker-compose -f ${OE_DOCKER_COMPOSE_FILE} exec -T openemr tail -f /var/log/apache2/access.log

module-install:
echo "Install ${MODULE_ENV} in openemr:${OE_RELEASE_ENV}"
docker-compose -f ${OE_DOCKER_COMPOSE_FILE} exec openemr composer config repositories.medicalmundi/oe-module-todo-list vcs https://github.com/MedicalMundi/oe-module-todo-list.git --working-dir /var/www/localhost/htdocs/openemr
docker-compose -f ${OE_DOCKER_COMPOSE_FILE} exec openemr composer require ${MODULE_ENV} --prefer-source --working-dir /var/www/localhost/htdocs/openemr
$(MAKE) instance-fix-permission
echo "Module ${MODULE_ENV} installed in Openemr:${OE_RELEASE_ENV}"

module-dev-install:
echo "Install ${MODULE_ENV} in openemr:${OE_RELEASE_ENV}"
docker-compose -f ${OE_DOCKER_COMPOSE_FILE} exec openemr composer config repositories.medicalmundi/oe-module-todo-list vcs https://github.com/MedicalMundi/oe-module-todo-list.git --working-dir /var/www/localhost/htdocs/openemr
docker-compose -f ${OE_DOCKER_COMPOSE_FILE} exec openemr composer require ${MODULE_ENV}:dev-main --prefer-source --working-dir /var/www/localhost/htdocs/openemr
$(MAKE) instance-fix-permission
echo "Module ${MODULE_ENV} installed in Openemr:${OE_RELEASE_ENV}"

module-remove:
echo "Remove ${MODULE_ENV} in openemr:${OE_RELEASE_ENV}"
docker-compose -f ${OE_DOCKER_COMPOSE_FILE} exec openemr composer remove ${MODULE_ENV} --working-dir /var/www/localhost/htdocs/openemr
echo "Module ${MODULE_ENV} removed in Openemr:${OE_RELEASE_ENV}"

module-update:
echo "Update ${MODULE_ENV} in openemr:${OE_RELEASE_ENV}"
docker-compose -f ${OE_DOCKER_COMPOSE_FILE} exec openemr composer update ${MODULE_ENV} --working-dir /var/www/localhost/htdocs/openemr
$(MAKE) instance-fix-permission
echo "Module ${MODULE_ENV} updated in Openemr:${OE_RELEASE_ENV}"

module-as-local:
echo "Install ${MODULE_ENV} as local module (from directory) in openemr:${OE_RELEASE_ENV}"
docker-compose -f ${OE_DOCKER_COMPOSE_FILE} exec openemr composer config repositories.${MODULE_ENV} '{"type": "path", "url": "/oe-module-npi-registry/"}' --working-dir /var/www/localhost/htdocs/openemr
docker-compose -f ${OE_DOCKER_COMPOSE_FILE} exec openemr composer require ${MODULE_ENV}:dev-main --working-dir /var/www/localhost/htdocs/openemr
$(MAKE) instance-fix-permission
echo "Module ${MODULE_ENV} installed in Openemr:${OE_RELEASE_ENV}"
6 changes: 6 additions & 0 deletions docker-compose-module.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: '3.1'
services:
openemr:
volumes:
- ../..:/openemr:rw
- ./../../../../oe-module-npi-registry/:/oe-module-npi-registry:rw

0 comments on commit a2db4fa

Please sign in to comment.