You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Steinar Bang <sb...@dod.no> on 2021/03/07 09:23:49 UTC

Is it possible to run karaf applications on heroku?

Has anyone here run karaf on heroku?
Or rather: has anyone here run applications in karaf on heroku?

Seems like it should be possible from the Java on heroku documentation?
Seems like the jigzaw puzzle parts all are in place, or almost all are
in place...?
 https://devcenter.heroku.com/articles/java-support

If you can get a karaf pulled in by "mvn install" (which happens in my
karaf projects, to use in the integration test), fix the configuration
to add an extra feature, or two, to load, and provide heroku with the
proper start point to start karaf, then everything basically should
start and run:

Not sure how to provide the start point to start karaf?  With a
Procfile, maybe...? 
 https://devcenter.heroku.com/articles/procfile

One benefit, from my point of view, would be that heroku can run your
application built from the head of your branch, i.e. the newest
SNAPSHOT, without adding a snapshot repository.


Re: Is it possible to run karaf applications on heroku?

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Jean-Baptiste Onofre <jb...@nanthrax.net>:

> If Heroku is able to run Java, I don’t see why we won’t be able to run
> karaf. It’s basically, what pax exam is doing.

My thoughts, exactly! :-)

> It would be even simpler with Karaf5 as we have the Karaf main:

> KarafConfig config = KarafConfig.builder()
>                 .homeDirectory("karaf")
>                 .dataDirectory("karaf/data")
>                 .cacheDirectory("karaf/data/cache")
>                 .build();
>         karaf = Karaf.build(config);
>         karaf.init();
>         karaf.addExtension("mvn:org.apache.karaf.extensions/log/5.0.0-SNAPSHOT");
>         karaf.addModule("file:my-app.jar");

Neat API!

> So, we can do that in "code" and let heroku build it and run it.

Is it doable in karaf 4.x?
Or would one be better off waiting for karaf 5?

> We already have a full story with Kubenetes (I blogged about that, and
> I’m preparing a blog about Karaf5).

Thanks! I will read them.

> I think we can prepare a heroku use case if it’s useful.

I have currently been playing around with making my weekly allowance
app[1] run on docker.

The docker image runs fine in a local docker instance running on my
amd64 desktop machine.

But I wanted to see if the image would also run in a docker host in the
cloud.

And in that context I was looking for a free docker hosting, that didn't
require a credit card, and I ran into a way of running a docker image on
heroku[2][3].

Now, I was never able to make that work (the image loads, and I think
starts, but nothing responds on port 80).

I made one change to make the docker image respond on port 80: I made it
possible to set the port used by pax web, by setting the PORT
environment variable variable[4] (this is how heroku communicates the
port the application should run on [5]).

So my next thought was to see if heroku had karaf as an app type?

However, karaf didn't appear on on the list of languages and frameworks supported
by heroku[6].

So I dug deeper into the Java language support and thought "Hm... that
looked promising"... and that's how this thread started...:-)

References:
[1] <https://twitter.com/steinarba/status/1337139795320053766?s=20>
[2] <https://medium.com/@justkrup/deploy-a-docker-container-free-on-heroku-5c803d2fdeb1>
[3] <https://devcenter.heroku.com/articles/container-registry-and-runtime>
[4] <https://github.com/steinarb/ukelonn/blob/master/docker/ukelonn/docker/org.ops4j.pax.web.cfg#L2>
[5] <https://devcenter.heroku.com/articles/container-registry-and-runtime#dockerfile-commands-and-runtime>
[6] <https://devcenter.heroku.com/categories/language-support>


Re: Is it possible to run karaf applications on heroku?

Posted by Jean-Baptiste Onofre <jb...@nanthrax.net>.
Hi Steinar,

To be honest, I didn’t know Heroku. 

If Heroku is able to run Java, I don’t see why we won’t be able to run karaf. It’s basically, what pax exam is doing.
It would be even simpler with Karaf5 as we have the Karaf main:

KarafConfig config = KarafConfig.builder()
                .homeDirectory("karaf")
                .dataDirectory("karaf/data")
                .cacheDirectory("karaf/data/cache")
                .build();
        karaf = Karaf.build(config);
        karaf.init();
        karaf.addExtension("mvn:org.apache.karaf.extensions/log/5.0.0-SNAPSHOT");
        karaf.addModule("file:my-app.jar");

So, we can do that in "code" and let heroku build it and run it.

We already have a full story with Kubenetes (I blogged about that, and I’m preparing a blog about Karaf5).

I think we can prepare a heroku use case if it’s useful.

Regards
JB

> Le 7 mars 2021 à 10:23, Steinar Bang <sb...@dod.no> a écrit :
> 
> Has anyone here run karaf on heroku?
> Or rather: has anyone here run applications in karaf on heroku?
> 
> Seems like it should be possible from the Java on heroku documentation?
> Seems like the jigzaw puzzle parts all are in place, or almost all are
> in place...?
> https://devcenter.heroku.com/articles/java-support
> 
> If you can get a karaf pulled in by "mvn install" (which happens in my
> karaf projects, to use in the integration test), fix the configuration
> to add an extra feature, or two, to load, and provide heroku with the
> proper start point to start karaf, then everything basically should
> start and run:
> 
> Not sure how to provide the start point to start karaf?  With a
> Procfile, maybe...? 
> https://devcenter.heroku.com/articles/procfile
> 
> One benefit, from my point of view, would be that heroku can run your
> application built from the head of your branch, i.e. the newest
> SNAPSHOT, without adding a snapshot repository.
>