Running Mule in Dokku and Heroku
September 27, 2015 by Gregory Lawson
In a previous blog, “Using Spring Boot with Mule”, I described and implemented embedding Mule into a Spring Boot application. This allows the running Mule from command line without having to install Mule server on the target system. Running Mule in this manner has multiple use cases. One of these use cases is running Mule in a PaaS. There are many PaaS providers so I will focus on two.
The first is Heroku. Heroku offers a simple deployment model for developers. There are many options for app developers. These options range from Ruby, Java, Node.js, Python, PHP, Clojure, Scala, Go as the programming languages for developing applications. Heroku allows the deployment of an application to its platform by Git. After creating a Heroku account and creating an application, a local Git repository can push to the remote for a deployment of the application.
The second is Dokku. Dokku is an open source Heroku implementation. You can install it for free with an Ubuntu Linux distribution. If offers the same capabilities as Heroku but is only scaled for one computer system.
Download the project. The complete source code and Github project can be found here.
On the command line from the project root execute the command:
mvn clean package && java -Dhttp.port=8080 -jar target/spring-boot-mule-pass-1.0-SNAPSHOT.jar
This will build, package, and run the Mule Embedded in Spring Boot locally.
Start another terminal or shell and issue the command:
curl http://localhost:8080/test
If you see “Welcome Paas Mule!”, you have just verified that the Embedded Mule can run locally.
Now, create an application in Heroku and follow the directions with “Deploy using Heroku Git”.
Install the Heroku Toolbelt
Download and install the Heroku Toolbelt or learn more about the Heroku Command Line Interface.
If you haven’t already, log in to your Heroku account and follow the prompts to create a new SSH public key.
$ heroku login
After logging in, you can add the local Git repo to Heroku’s remote repo:
heroku git:remote -a YOUR-APPLICATION-NAME
In my case I created an app called test-glawson6. My command becomes:
heroku git:remote -a test-glawson6
Deploy your application
Commit your code to the repository and deploy it to Heroku using Git.
$ git add . $ git commit -am "make it better" $ git push heroku master
Start another terminal or shell and issue the command:
curl https://YOUR-APPLICATION-NAME.herokuapp.com/test
You should see: Welcome Paas Mule!
Congratulations! You just deployed a Mule App to Heroku!
After installing Dokku, you can deploy an app by running in a terminal ‘git remote add dokku dokku@YOUR-DOMAIN-NAME:YOUR-APPLICATION-NAME
You can then run:
curl https://YOUR-APPLICATION-NAME.YOUR-DOMAIN-NAME/test
You should see: Welcome Paas Mule!
####Further reading