5

I need to deploy my application in an embedded solution (running on a raspberry pi zero). As such, I only really can deploy things on localhost. I am not too familiar with virtual hosts, so I may be wrong on this.

My problem is that I want tomcat to auto-deploy the war file that is contained within the git repository I cloned onto the raspberry pi. This is so that updates can be made over the git respository easily instead of having to deal with the manager. That being said, I also like to keep the manager and other admin tools active and working which are contained within the default webapps directory. Copying these into the git repository is not something i want to do as they will be misplaced and kept in the repository which is not necessary. Furthermore, I want tomcat to "explode" or extract the WAR files in the original webapps directory, as to not add these files to the git repository.

Basically I want to be able to auto-deploy all war files in a certain directory without that directory being actually being written to and while also auto-deploying the war files in the "standard" webapps directory.

Is this possible?

Im using tomcat9

Spyros K
  • 2,480
  • 1
  • 20
  • 37
MoustacheSpy
  • 743
  • 1
  • 6
  • 27

2 Answers2

1

How about using "inotify" to watch over the war directory in the cloned repository and if it changes copying the war into the "webapps" of the tomcat which will autodeploy the changed application. You can install inotify-tools for this. Check here for more on this.

Shailendra
  • 8,874
  • 2
  • 28
  • 37
1

Solution A:

Tomcat 9 has only one appBase attribute, which by default is the webapps. In order to change that you need to configure 2 Common attributes :

1.appBase: Set this parameter to the folder where the war that needs to be deployed is located. 2.autoDeploy: Make sure this is set to true.

It is not possible to have 2 appbase directories. So the original webapps will not work for autodeployment.

Solution B:

Use a script to pull the WAR from the GIT repository, that will also copy or move the file to the standard webapps folder of Tomcat9. e.g.

git pull rm path/to/tomcat/webapps/warname.war  
mv warname.war
path/to/tomcat/webapps

Solution C:

Configure your GIT repository or another GIT repository to just include webapps folder with the desired war. If you use this folder only to pull the war from your GIT repository you do not need to commit the default Tomcat apps. See the following steps. Starting from a vanilla Tomcat 9 installation

  1. Rename webapps to webappsOriginal

  2. Clone the webapps repository so that another webapps folder is now created, containing only the war.

  3. Move all contents of webappsOriginal to webapps.

  4. Delete webappsOriginal

Now if you pull from the repository the updated war will be fetched and autodeployed. There is no reason to add, commit or push the prexisting files in your GIT.

Spyros K
  • 2,480
  • 1
  • 20
  • 37