DOKKU – Deploy a runnable JAR in Dokku

abril 4, 2017

Dokku is like Heroku running on your own servers. This is pretty cool.

Normally, you should push your changes to the dokku repository and watch your code compile and run smoothly. But sometimes, the process of gathering dependencies and compiling your code takes to much time and processor, that sometimes gets rejected or it simply won’t compile on dokku server.
Probably, you already have a valid, tested, runnning jar in your development machine that you want to run on dokku, so how could you push this jar to the dokku server? well, let’s see…

In heroku, you have, among other options, the command

heroku deploy:jar

I don’t know of such a command for dokku[1]. but nevertheless you can deploy any jar(Many Java and JVM applications are packaged into a self-contained executable JAR file that includes application code, configuration and dependencies. These artifacts are often called “uberjars” or “fat jars”) with the following trick.

This article explains how to get a metabase runnable jar onto dokku. I’ve tried and it almost worked, the only really difference is that you have to create a java application skeleton with a maven archetype, and put your jar into version control.

so, first let’s create the skeleton for our java app deployment

mvn archetype:generate -DgroupId=com.sample -DartifactId=sample-jar-deploy -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

then run the following commands to configure and deploy to dokku

cd sample-jar-deploy
cp ~/Apps/sample-app/target/sample-app.jar .
echo "web: java -jar sample-app.jar" > Procfile
git init
git add .
git commit -m 'sample-app.jar version 0.1'
ssh dokku@where.your.dokku.is.com apps:create sample-app
git remote add dokku dokku@where.your.dokku.is.com:sample-app
git push dokku master

to upgrade your app

cp ~/Apps/sample-app/target/sample-app.jar .
git commit -am 'sample-app.jar version 0.2'
git push dokku master

Beware that this is definitively going to increase the size of the repository. This is only a temporary repository to have the jar deployed, your source and main repository should be in ~/Apps/sample-app/

to clean up and start over

cd sample-jar-deploy
rm -rf .git/
cp ~/Apps/sample-app/target/sample-app.jar .
git init
git add .
git commit -m 'sample-app.jar version 0.3'
ssh dokku@where.your.dokku.is.com apps:destroy sample-app
ssh dokku@where.your.dokku.is.com apps:create sample-app
git remote add dokku dokku@where.your.dokku.is.com:sample-app
git push dokku master

Of course you can deploy using buildpacker, dockerfile, docker image, and tarball based deploys which are documented.

Fuentes:
View story at Medium.com
http://dokku.viewdocs.io/dokku/
https://devcenter.heroku.com/articles/deploying-executable-jar-files
http://www.mkyong.com/maven/how-to-create-a-java-project-with-maven/

[1]:

 Hi, do anyone know if there's command like 'heroku deploy:jar' available for dokku
[16:09]  https://devcenter.heroku.com/articles/deploying-executable-jar-files#using-the-heroku-deploy-cli-plugin
[16:13]   no
[16:13]   we support buildpacker, dockerfile, docker image, and tarball based deploys
[16:14]   http://dokku.viewdocs.io/dokku/getting-started/installation/
[16:14]   sidebar on that page shows our deployment methods
Anuncios

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s

A %d blogueros les gusta esto: