Fork me on GitHub
#funcool
<
2016-04-14
>
kenny06:04:00

Is it possible to create a war file with catacumba?

niwinz06:04:29

it uses netty and uses its own http stack

kenny06:04:39

@niwinz: Is there something similar to a war file that you can create in order to nicely bundle up your application? It would be nice to able to serve static files from inside a jar instead of requiring it be on the system path

niwinz06:04:57

serving the static from the jar is completly independent from the ability to create war

niwinz06:04:17

I deploy my apps using uberjar

niwinz06:04:30

give me 5 min for remember that I'm doing

niwinz06:04:02

java -jar target/uxbox-backend-0.1.0-SNAPSHOT-standalone.jar -m uxbox.main

niwinz06:04:06

this how I run the app

niwinz06:04:23

this is the repo and its config

niwinz06:04:49

I'm just don't want AOT, because of this the -m uxbox.main

niwinz06:04:06

the uxbox does not serves static files

niwinz06:04:43

but as far as I know it is easy setup puting the .catacumba file inside resources and configure properly the routing for serve static files from there

kenny06:04:39

Right but the problem is that :base-dir requires a system path, not relative path inside a jar

niwinz06:04:35

if you not specify it and put .catacumba file inside resources it does not works?

niwinz06:04:56

I didn't test that in real environments but if you give me some time I can do it

kenny06:04:03

What is the .catacumba file?

niwinz06:04:09

a marker file

niwinz06:04:18

touch resources/.catacumba

kenny06:04:24

What does this do?

kenny06:04:37

What can you put in .catacumba?

niwinz06:04:41

indicates to catacumba that if no base dir is specified, find one that contains that file

kenny06:04:26

How does it find one?

niwinz06:04:24

I don't know the impl, the fact is, if you don't provide the base-dir parameter on server startup, it will find .catacumba file in the class path and the directory where that file exists put as the base dir

kenny06:04:04

Interesting. I did not know about this. Is this part of ratpack?

niwinz06:04:14

yes and not

niwinz06:04:21

in ratpack is not automatic

niwinz06:04:27

but in catacumba yes it is

kenny06:04:10

What do you mean not automatic?

niwinz06:04:32

in ratpack you should explicitly set always the base-dir, and you can use some helper for do that catacumba does

niwinz06:04:46

catacumba automatically does that if base dir is not specified

niwinz06:04:40

but I think that I'm wrong in one thin

niwinz06:04:50

this does not allows in any case serve files

niwinz06:04:54

from classpath

niwinz07:04:07

seems like this is not solved at this moment

kenny07:04:36

Have you tested it?

niwinz07:04:23

Yes but always out of uberjar

niwinz07:04:42

I think this will not work in the bundled executable jar

kenny07:04:40

Hmm. Seems like it should. I'll see if the .catacumba file solves my problem

niwinz07:04:14

In any case I recommend serve static files just using nginx or similar

kenny07:04:08

Yes in prod. This is actually for a small dev tool so it would be nice to just distribute it as a standalone jar that can run in the background.

niwinz07:04:57

ok, let me know of any result 😉

niwinz07:04:56

[3/5.2][email protected]:~/uxbox/uxbox-backend> java -jar target/uxbox-backend-0.1.0-SNAPSHOT-standalone.jar -m uxbox.main Exception in thread "main" java.lang.IllegalStateException: Could not find marker file '.catacumba' via context class loader

niwinz07:04:05

I think it will not work

niwinz07:04:51

The most closes solution to that you want is just create the uberjar and latter package it for use static files from main filesystem (no classpath), you don't need nginx but at this moment you can't serve files from classpath

niwinz07:04:08

I think that is very useful so I priorize that task in my backlog 😉

niwinz07:04:40

java -Dcatacumba.basedir=`pwd`/resources -jar target/uxbox-backend-0.1.0-SNAPSHOT-standalone.jar -m uxbox.main

niwinz07:04:36

This works as expected

niwinz07:04:44

I will try to implement the ability to serve static files from classpath, because for small applications this is the most obvious way to deploy them 😄

niwinz08:04:41

I will chat with ratpack developers if they know any way to do it

niwinz10:04:37

@kenny: I think that I found a solution, at this moment I don't have much time for it, but this afternoon I'll try to make it done

niwinz16:04:44

@kenny: fixed in 0.13.0-SNAPSHOT

niwinz16:04:09

the final part of that doc section explains a little bit the problem and how to solve

kenny20:04:50

@niwinz: Sweet, that works. Thanks

kenny22:04:37

@niwinz: Actually I am having a problem with it.. It doesn't seem to find my js file that is in the same directory as .catacumba.basedir. It will serve my index.html though. The main.js file will get a 404.

kenny22:04:06

It will serve index.html, logback.xml, and I can even download .catacumba.basedir, however, main.js will always be a 404.