Deploy

We are ready to deploy the server! First, we package our application as a JAR file. I like to do this from the terminal.

Open the terminal in IntelliJ and build an executable JAR file:

./gradlew build jar

Next, run the following command

./gradlew build deployHeroku

If all goes well, you will get a message that looks like this

BUILD SUCCESSFUL in 1s
2 actionable tasks: 1 executed, 1 up-to-date
➜  course-search-api git:(master) ✗ ./gradlew build deployHeroku

> Task :deployHeroku
-----> Packaging application...
       - including: build/tmp/jar/MANIFEST.MF
       - including: build/classes/java/main/ApiServer.class
       - including: build/classes/java/main/Course.class
       - including: build/classes/java/main/Main$1.class
       - including: build/classes/java/main/Main.class
       - including: build/libs/course-search-api-0.0.1.jar
       - including: build/tmp/compileJava/source-classes-mapping.txt
-----> Creating build...
       - file: /var/folders/kb/2p6m6w4s4dv008lktq9z459h0000gn/T/heroku-deploy3849104631357747029source-blob.tgz
       - size: 2MB
-----> Uploading build...
       - success
-----> Deploying...
remote: 
remote: -----> Building on the Heroku-20 stack
remote: -----> heroku-gradle app detected
remote: -----> Installing JDK 1.8... done
remote: -----> Discovering process types
remote:        Procfile declares types -> web
remote: 
remote: -----> Compressing...
remote:        Done: 54.6M
remote: -----> Launching...
remote:        Released v3
remote:        https://course-search-api-421.herokuapp.com/ deployed to Heroku
remote: 
-----> Done

BUILD SUCCESSFUL in 19s
3 actionable tasks: 1 executed, 2 up-to-date

The server is deployed on Heroku and it is available on the web 🎉

The URL for my Heroku app is https://course-search-api-421.herokuapp.com/. (Yours will be different.) My API endpoint must be available at https://course-search-api-421.herokuapp.com/api/courses. Check your endpoint by sending a Get request to it on Postman. You must get the list of sample courses.