-
-
Notifications
You must be signed in to change notification settings - Fork 442
Enable Deployment to Heroku #206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
hi brad, thank you for your effort! is this everything that is necessary to run steve on heroku? what about managed database instance or logging? |
|
expanding on your commit, i think i have an idea how to improve the solution by using the way spring boot handles setting ports: port can be set to a number or to a system env, which is looked up if it starts with a dollar sign. we can apply the same approach when reading all properties. this is a little more flexible than hardcoding heroku-specific java logic. |
|
👋 @goekay ! Thanks for being open to my PR / feature request. I greatly appreciate it! 🎉 For simplicity and to continue to support SteVe's use by other people sakes' via SteVe's instructions my initial commit / PR was deliberately simple and focused only on the port and host name as that's fundamental. I'm totally happy to widen the scope of this PR if you would prefer that approach. I wanted to err on the side of simplicity since this was my first PR to this project. Let me explain further in my responses to your questions:
No. Heroku's Java support comes in two flavors: WAR files on Tomcat and Plain Java. Plain Java is a very open / flexible option as it's possible to deploy apps with Embedded Tomcat / Jetty as well as plain JAR files. Complicating things further Heroku supports 2 ways to deploy Java applications: Via Git and Executable JAR files (see links below for more details). Ideally, I'd prefer to be able to compile and deploy SteVe to Heroku via a Maven command using the Executable JAR method or via a simple WAR file. Currently I'm customizing SteVe properties along with the server and port fixes in Java Support Deploying Spring Boot Applications To Heroku Deploying With Git Deploying Executable JAR Files
Heroku only supports Postgres, Redis, and Kafka directly themselves. They do have 3rd party support of MySQL via ClearDB and JawsDB. Due to SteVe's need to support Transactions only JawsDB allows this (which is what I'm using). Ideally SteVe would support a variety of databases, starting with Postgres due to it being open source and supported by Heroku, and it looks like it could quite easily via it's existing use of Hibernate ORM. This isn't an immediate blocker, but it's very much desired. https://devcenter.heroku.com/categories/data-management
Heroku's logging is a bit of a black box (to say the least IMHO). While it in theory supports external log aggregators (see link below), my basic goal is to get it to support https://devcenter.heroku.com/articles/logging
I like this much better than my original solution as it' much lower level on the stack and avoids the platform specific spaghetti code. The only question I have about it is how to also null out the server host name in this scenario? Heroku needs to be able to set the port number AND have Jetty not bind to a particular host name. Unfortunately, Heroku only signifies this via setting the port number via environment variable and not also via host name. Thoughts? Again, thank you for considering this PR and adding support for Heroku based deployments of SteVe! |
|
I totally agree with you on this. Besides, at this point in time it's much easier / less work to make SteVe work with Heroku as is rather than to refactor everything to produce a WAR file. 👍
No worries. Lack of Postgres is not a blocker for me at this point due to Heroku's integration with JawsDB. JOOQ has support for Posgres already so perhaps at a later date the SteVe's Maven
Yep, also very much agreed. Please DO NOT merge my commit 690fa03 for this very reason. 😄
This admittedly is a weird situation as Heroku doesn't provide any documentation on this (at least that I could find anyway). From my trial and error experiments the only way I could get SteVe to run on Heroku was with both the port being set via Heroku's environment variable AND the serverHost being set to With this all in mind, here's what I propose:
What do you think? As for my personal use case, just having the external setting of Jetty's port and serverName is the priority. Having the Heroku Maven command is a "nice to have" and can built at a later date if desired. Thanks again for your time and willingness to look into supporting deployment to Heroku. I really appreciate it! 👍 |
|
external setting of the port is already enabled with my latest commit. can you please test |
|
@goekay I was able to test out the
Let's go with your solution of: Thanks again for your help and willingness to collaborate! I really appreciate it. 👍 |
|
that's great. i believe that even |
|
Excellent! How should we go about finishing this PR? Do you want to finish your implementation and merge? |
|
i am not sure that any additional changes for steve are necessary. in order to build and run steve on heroku, a better solution might be the heroku cli, which eliminates the necessity to modify edit: since i consider my only commit to provide the necesary changes for heroku and it is already in master branch, i think this problem is solved and propose to close this PR. no? |
|
Sounds good to me. This PR should serve as a good document for others looking to run SteVe on Heroku. I'll close it out now and if others feel the need to expand upon it then they can. Thanks again for everything! |
In order for SteVe to be deployed on Heroku (and likely other cloud hosting providers) the internal Jetty server needs to be able to be dynamically configured externally. Specifically, it needs to be able to have its
portandserverHostconfigured at launch time.This change is Heroku specific in that it checks for the
PORTenvironment variable and if found sets Jetty to use that value and sets theserverHostto null so that SteVe can bind to it's hosting environment. If this environment variable is not found, SteVe runs as originally designed using thehttp.portandserver.hostfrommain.properties. For more details please see:https://devcenter.heroku.com/articles/setting-the-http-port-for-java-applications
Relatedly, another way around this issue would be for SteVe to be refactored to support being run as an external .war file using Jetty Runner or Heroku Webapp Runner.
Thanks for considering this change!
/cc @goekay