Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/daggerok/heroku-gradle-buildpack-example

Heroku gradle buildpack example.
https://github.com/daggerok/heroku-gradle-buildpack-example

buildpack gradle heroku heroku-buildpack herokuapp

Last synced: 7 days ago
JSON representation

Heroku gradle buildpack example.

Awesome Lists containing this project

README

        

= heroku-gradle-buildpack-example image:https://travis-ci.org/daggerok/heroku-gradle-buildpack-example.svg?branch=master["Build Status", link="https://travis-ci.org/daggerok/heroku-gradle-buildpack-example"] image:https://gitlab.com/daggerok/heroku-gradle-buildpack-example/badges/master/build.svg["Build Status", link="https://gitlab.com/daggerok/heroku-gradle-buildpack-example/-/jobs"]

//tag::content[]
== migrate from maven to gradle (heroku only)

.install heroku cli, register (if has no account) and login
[source,bash]
----
brew install heroku
heroku login
----

.clone my heroku maven (java buildpack) example project which has already ptrepared gradle stuff
[source,yml]
----
git clone https://github.com/daggerok/heroku-java-buildpack-example.git
rm -rf .git .mvn mvnw* pom.xml heroku.yml
----

.add requred heroku-gradle setup
[source,yml]
----
echo "task stage(dependsOn: 'build')" >> build.gradle
----

.create heroku app and deploy to it with development profile
[source,yml]
----
git init .
heroku create daggerok-gradle-buildpack

echo "web: SPRING_PROFILES_ACTIVE=dev ./build/libs/*.jar" > Procfile
git add .
git commit -am "First blood!"
git push heroku master

heroku logs -t
# find output: The following profiles are active: dev,spring-boot,data-jpa
----

key points here (if you just create app from scratch):

- you need prepare gradle `stage` task for build

echo "task stage(dependsOn: 'build')" >> build.gradle

- you need prepare Procfile with bash application startup command (in out case it's: `./build/libs/*.jar`)

echo "web: SPRING_PROFILES_ACTIVE=dev ./build/libs/*.jar" > Procfile

- you need install gradle wrapper in your project

gradle wrapper
git add -f gradle*
git commit -am "Add gradle wrapper"

== going production

.for production (heroku) version add postgres database
[source,bash]
----
heroku addons:create heroku-postgresql:hobby-dev
----

.now let's configure correct heroku URL and switch spring-boot app to production prpofile which is using postgres database:
[source,bash]
----
echo "web: SPRING_PROFILES_ACTIVE=prod APP_BASE_URL=https://daggerok-gradle-buildpack.herokuapp.com ./build/libs/*.jar" > Procfile
git add .
git commit -am "Setup right heroku application environment variables"
git push heroku master
----

.just FYI
[source,bash]
----
heroku git:remote -a daggerok-gradle-buildpack
git remote -v
# skip others...
heroku https://git.heroku.com/daggerok-gradle-buildpack.git (fetch)
heroku https://git.heroku.com/daggerok-gradle-buildpack.git (push)
----

link:

- link:https://devcenter.heroku.com/articles/getting-started-with-gradle-on-heroku#deploy-the-app[Getting Started with Gradle on Heroku]
- link:https://devcenter.heroku.com/articles/deploying-gradle-apps-on-heroku[Heroku Gradle documentation]
- link:https://github.com/heroku/heroku-buildpack-gradle[heroku buildpack gradle]
- link:https://github.com/heroku/gradle-getting-started[Gradle heroku buildpack example project]

generated by link:https://github.com/daggerok/generator-jvm/[generator-jvm] yeoman generator (java-spring-boot)
//end::content[]