Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

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

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

heroku herokuapp java maven mvn mvnw

Last synced: 3 days ago
JSON representation

Heroku java buildpack example.

Awesome Lists containing this project

README

        

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

//tag::content[]
== development

.run locally
[source,bash]
----
./gradlew
java -jar build/libs/*.jar --spring.profiles.active=dev
SPRING_PROFILES_ACTIVE=dev bash build/libs/*.jar

./mvnw
java -Dspring.profiles.active=dev -jar target/*.jar
bash target/*.jar

./mvnw; ./mvnw com.dkanejs.maven.plugins:docker-compose-maven-plugin:1.0.1:up
./mvnw com.dkanejs.maven.plugins:docker-compose-maven-plugin:1.0.1:down
----

== production
.prepare heroku.yml
[source,yml]
----
# default java build pack will use maven wrapper command: `./mvnw clean innstall`
build:
languages:
- java
run:
web: java -Dspring.profiles.active=dev -jar target/*.jar
----

.install heroku cli
[source,bash]
----
brew install heroku
----

.register in heroku.com and login
[source,bash]
----
heroku login
----

.create heroku app (in my case it's `daggerok-java-buildpack`)
[source,bash]
----
heroku create daggerok-java-buildpack
----

.customize java/maven versions: create file `system.properties` with content:
[source,bash]
----
java.runtime.version=1.8
maven.version=3.5.3
----

.configure application:
[source,bash]
----
heroku config:set APP_BASE_URL=https://daggerok-java-buildpack.herokuapp.com
heroku config:set SPRING_PROFILES_ACTIVE=dev

# output:
# Setting APP_BASE_URL and restarting ⬢ daggerok-java-buildpack... done, v5
# APP_BASE_URL: https://daggerok-java-buildpack.herokuapp.com
----

.deploy dev version first (using H2 inmemory database)
[source,bash]
----
git remote -v | grep heroku
git add .
git commit -am "First blood: prepare heroku development deployment."
git push heroku master
open https://daggerok-java-buildpack.herokuapp.com
heroku logs -t
----

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

.now let's switch out spring-boot app to production prpofile which is using postgres database:
[source,bash]
----
heroku config:set SPRING_PROFILES_ACTIVE=prod
heroku logs -t
# verifu log contains: The following profiles are active: prod,app,spring-boot,data-jpa
----

link:

- link:https://github.com/heroku/heroku-buildpack-java[heroku java buildpack]

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