Issue
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
Solution
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
Rename
webapps
towebappsOriginal
Clone the
webapps
repository so that anotherwebapps
folder is now created, containing only the war.Move all contents of
webappsOriginal
towebapps
.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.
Answered By - Spyros K