This guide is based on How to automate new modules’ registration within folio/testing-backend Vagrant box. It provides shell scripts for re-registering/redeploying modules in folio/testing Vagrant box.
The goal is to set up a script that will be run after module is built. The script will copy all necessary files, build docker image, register and deploy it inside of Vagrant box.
This guide assumes that Okapi already has a version of the same module registered and deployed. The script will only replace old module with new one, it won't register module from scratch.
Additionally version of new module has to be greater or equal to the version of already deployed module
- Copy deployment_scripts folder from following archive into vagrant root folder (directory with Vagrantfile)
- Edit file copy_jar_and_deploy.sh:
set variable VAGRANT_PATH to vagrant root folder
set VAGRANT_VM_NAME to the name or id of vagrant VM (you can get it by running "vagrant global-status", normally it will be "testing" or "testing-backend")
- Edit file make_docker_directory.sh to set variable VAGRANT_PATH to the same value as in copy_jar_and_deploy.sh
This step needs to be done only once for each module.
To build docker image we need to create a separate directory with Dockerfile for each module. This directory has to be placed in vagrant root folder, so that it is accessible from inside vagrant vm.
To create docker directory:
- run "make_docker_directory.sh",
- Specify name of directory (e.g. mod-notes)
- Specify debug port that will be exposed by deployed module
- Check that directory is created in vagrant root folder
- If necessary, modify docker-DeploymentDescriptor.json
Go to the directory with module:
Build module with maven:
- Make sure that version of built module is greater or equal to version of already deployed module, script uses "/_/proxy/tenants/diku/upgrade" endpoint for redeployment, so redeployment will only work if new version is greater than old version. (You can temporarily set the version to be greater by modifying pom.xml and rebuilding module)
run copy_jar_and_deploy.sh, pass name of jar file, name of docker directory and path to module:
Alternatively, if you don't pass module folder path then it will default to current folder:
- Go to Run - Edit Configuration
- Add Shell Script configuration with path to copy_jar_and_deploy.sh, specify jar filename and docker directory as parameters:
If you are using older Intellij Idea then use BashSupport plugin https://plugins.jetbrains.com/plugin/4230-bashsupport to create similar Run configuration
Each redeployed module exposes debug port that is specified in docker_dir/DEBUG_PORT.txt. To access debug port you need to forward it in Vagrantfile by adding following string:
You can forward a range of ports by using a for loop: