Template for deployment
With this template, you are ste to deploy your application to Heroku. I´m using a Spring backend, React JS Frontend with MongoDB database.
Try it out
- Standard react starting-page: https://kevinowens.herokuapp.com/
- Simple DB- request to save new Document and show all Documents: https://kevinowens.herokuapp.com/api (if you count the items, you know how many people visited the site :D)
- What you need:
- What to do:
-
Clone this Repo and connect it with a new Repo of yours(you can delete the .git Folder and make a new git init).
-
Install or sign up to Heroku and MongoDB using the Links above.
-
MongoDB Atlas:
- create a Cluster for your App (check the pricing, there is a free tier)
- After you created it, use the connect button => connect your application => java/current version => copy the connection string
-
Let´s head to Heroku:
- Create an App for your application
- Head to settings and reveal Config Vars
- Add the Key
URI
and as Value paste in your connetion string (replace user and password with your values) - Since we are already on Heroku, we need some kind of authentication for GitHub, in this case an API-Key. We can generate our API-Key in Heroku by clicking the User-icon (top-right) => Account settings => scroll down untill you see API-Key
- Either generate or copy your API-Key.
-
Github:
- We have save this API-Key in our Repo, to Login to Heroku.
- Go to your Repo => Settings => Secrets => New Repository Secret
- Save your API-Key as
HEROKU_API_KEY
, save, and now GitHub and Heroku can communicate.
- What to change:
-
pom.xml:
- change the finalName to your Appname.
- You can change the groupId if you like.
-
Github Action:
- All points of change are marked inside th action.
-
Dockerfile:
- Please change the Maintainer :D
- The .jar name should be changed to the same name, as in the pom.xml under 'finalName' (at three places, you´ll manage to do it!)
-
You can remove all Packages in the backend, they are just an example for the DB connection.
- Problems
- If you encounter any problems using this template, please let me know by stating an issue on GitHub.