OK , I figured this all out after 1 week of research.
So the first step is getting the server setup, for most Spring boot apps, this means installing Java on the server and some type of Database, I choose PostgreSQL.
- Install Java
- Install PostgreSQL (or your database choice)
Make sure to create the user and database that you will use for your connection string in your application.properties (or where ever your connection info is) or you won’t be able to connect to your Database and your app won’t run
Then you can build up your Spring boot application locally and package it into a FAT(executable) .jar file. Make sure you have the spring-boot-maven-plugin for that
- Then you can run in the terminal
./mvnw clean package -Dmaven.test.skip=true
Make sure your database credentials are inside your application.properties file or whatever file they need to be in before you package your code into a jar
- SCP your jar file to your Digital ocean. A director like /var/myapp works good.
You should have the Apache Web Server already installed and setup for a non-root user. Digital ocean has alot of good guides to set that up.
You can run your jar by typing:
java -jar yourjarfilename.jar
It should spin up and start successfully.
If you’re using a Spring Boot app that uses the embedded Tomcat server like me, since the Apache Web Server listens for HTTP on port 80, and the Tomcat default port is 8080, no traffic will be sent to your Tomcat server.
Thus , you will need to setup a reverse proxy so your Apache web server re-routes HTTP traffic to your embedded Tomcat listening on port 8080.
Because I still wanted to use my frontend static website located at alpizano.me, that means I had to make the ProxyPass redirect at the which a
/api route, or else it rerouted all my traffic and I was never able to access the root of my website at alpizano.me This could be want you want though, if you plan to have your main Spring boot/Tomcat server as your main application
You can then setup your Spring boot app as a Systemd service so that its managed by Systemd and runs even when you close out the SSH connection and logs to
journalctl Read about that here