Clojurians
#hoplon
<
2016-05-15
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

leontalbot00:05:01

What is your server?

leontalbot00:05:37

@Ispector ^^^

leontalbot00:05:20

The hoplon-castra template is a good start and with it you can deploy to heroku easily or any where that accepts a war file You create template like so: lein new hoplon-castra my-project-name and when you cd in your project you do boot make-war which should output a war file located in target dir.

leontalbot00:05:18

For client only, i guess you could compile to javascript and use it on any server.

leontalbot00:05:24

I guess you do boot prod

leontalbot00:05:37

Then look for js files in target...

leontalbot00:05:01

Not sure i have never done client only builds

leontalbot00:05:37

Can't test right now to tell you where exactly are the output files in target but maybe somebody else could answer...

lspector00:05:30

This is for client only apps. I don't see anything about "prod" in boot help... but boot prod does indeed seem to do something in the address-book project from Getting Started... but whatever it does doesn't seem to leave anything new in the project directory.

lspector00:05:50

PS I don't know anything about heroku or war files. I have a directory on a machine where I can put html files... and occasionally I've put slightly more complicated things there, but not much and not within the last several generations of web programming technology. That's where I want to put a hoplon project. If I can put the Getting Started address-book project there then I'm confident I can build it out to do what I want... but I don't see how to take that Getting Started project the final step to the web.

lspector00:05:30

I see that boot prod ended with Skipping prerender: phantomjs not found on path.

leontalbot01:05:48

prod is not a default boot task rather a "local" task set in your `build.boot file

lspector01:05:29

Ah see that now. Thanks. Still fails though.

leontalbot01:05:01

yes, I'm testing right now

leontalbot01:05:18

we need to hack around the prod task

lspector01:05:47

Great -- thanks. BTW why isn't this what everybody wants to do? What do people do instead?

leontalbot01:05:34

I go with heroku because I can control server side (like routes, etc.) too

leontalbot01:05:06

The following prod task (creates target dir and) outputs html files to /target

leontalbot01:05:13

(deftask prod
  "Build address-book for production deployment."
  []
  (comp
    (hoplon)
    (cljs :optimizations :advanced)
    (target :dir #{"target"})))

leontalbot01:05:28

hope that works for you

leontalbot01:05:39

@alandipert: I also got a Skipping prerender: phantomjs not found on path. message when running boot prod for address-book tutorial

leontalbot01:05:40

I suggest we add a section in the wiki covering deployment with static files

leontalbot01:05:04

And that we fix boot prod task (or have an additional task for this use case)

leontalbot01:05:29

in the hoplon template

leontalbot01:05:17

Would you have a better approach then

(comp
    (hoplon)
    (cljs :optimizations :advanced)
    (target :dir #{"target"}))
?

leontalbot01:05:24

Thanks. Going to sleep

leontalbot01:05:32

@Ispector ^^^

lspector02:05:48

@leontalbot: Yes! That works beautifully for me. If I copy the resulting target directory to my server then I can indeed browse it there and the code runs. I should be in business. Thanks!

lspector02:05:40

Those suggestions re: documenting deployment and changing the template sound good to me (from my position of very limited knowledge).

lspector02:05:30

I'm still curious, though, what others do, such that this step wasn't the natural conclusion to the Getting Started address-book tutorial. Do people deploy in some completely different way?

thedavidmeister02:05:25

@lspector: this is my current heroku builder task

thedavidmeister02:05:28

(deftask build-heroku
  "Builds a standalone jar."
  []
  (comp (aot :namespace #{'app.main})
        (hoplon)
        (cljs :optimizations :advanced)
        (prerender)
        (uber)
        (jar :main 'app.main)
        (sift :include #{#"\.jar$"})
        (target :dir #{"target_prod"})))

thedavidmeister02:05:48

to deploy i just

thedavidmeister02:05:57

boot prod;
heroku deploy:jar --jar target_prod/project.jar --app my-app;

thedavidmeister02:05:45

but that’s actually more complicated than you might need it

thedavidmeister02:05:58

because i’m handling the web server in my app

thedavidmeister02:05:20

you can use heroku’s deploy:war too, and just

thedavidmeister02:05:32

(deftask build-heroku-war
  "Build a war for deployment"
  []
  (comp
    (hoplon)
    (cljs :optimizations :advanced)
    (prerender)
    (uber :as-jars true)
    (web :serve 'app.handler/app)
    (war)
    (target :dir #{"target_prod"})))

lspector03:05:02

@thedavidmeister: Thanks. So when most people use hoplon they do something like this maybe?

thedavidmeister03:05:33

dunno about “most people"

thedavidmeister03:05:38

but this works fine on heroku

thedavidmeister03:05:03

i didn’t need to use anything more than the second example until i wanted to do something custom with websockets and had to stop using jetty

thedavidmeister03:05:36

@lspector: please put any feedback you have about documentation up as/on issues for hoplon

thedavidmeister03:05:11

hoplon is very cool, but the learning curve could be mitigated a bit with good feedback on the docs 🙂

lspector03:05:13

Thanks. FWIW to me all of this deployment stuff, even the "simpler" versions, is non-obvious. I do think it'd be great to have some version of this stuff at the end of the Getting Started page and/or in templates.

thedavidmeister03:05:53

i started learning hoplon, java, clojure/script and heroku all at the same time, i feel your pain 😉

thedavidmeister03:05:42

@lspector: it will get easier if we make an effort to move the summaries of chat back into the wiki/readme/tutorials

leontalbot12:05:05

@thedavidmeister thanks for sharing your jar task. Would you mind sharing what is in your procfile? I will update hoplon-castra template readme accordingly. Thanks!

thedavidmeister12:05:22

@leontalbot: i don’t think i have a procfile, i think the heroku cli tool just does it for me

leontalbot12:05:06

ok, excellent!

thedavidmeister12:05:30

@leontalbot: just test it on a free dyno

leontalbot12:05:18

@alandipert: To deploy hoplon-template do I use my personal login pass?

alandipert12:05:06

@leontalbot: correct

leontalbot12:05:41

@thedavidmeister: testing...

alandipert12:05:48

i like the idea of concluding the tutorial with deployment instructions a lot

leontalbot12:05:40

@Ispector ^^^

leontalbot12:05:05

The only thing is I can't deploy to clojar right now, I have a passphrase issue

leontalbot12:05:29

feel free to do it this time (again)...

leontalbot12:05:52

I changed a bit the prod task

leontalbot12:05:00

(as mentioned above)

leontalbot12:05:05

@alandipert: ^^^

alandipert12:05:56

i can do the push for now

alandipert12:05:32

awesome, hoplon-template 3.2.2 is deployed. thanks!

leontalbot12:05:41

Excellent! Thanks!

leontalbot12:05:13

@lspector: thank you for your feed back

leontalbot12:05:40

the tutorial has now been updated

leontalbot12:05:13

@lspector How did you find hoplon?

leontalbot13:05:29

@thedavidmeister: weird, I'm at adding uberjar entries and it takes forever...

Skipping prerender: phantomjs not found on path.
Adding uberjar entries...

leontalbot13:05:28

I'll remove prerender and try again...

leontalbot13:05:52

@thedavidmeister: so there is no main fn by defaut in hoplon-castra template

leontalbot13:05:39

could we change (aot :namespace #{'app.main}) to make it work?

leontalbot13:05:47

if so, how? Thanks!

thedavidmeister13:05:14

you do need a main fn for it to work @leontalbot

thedavidmeister13:05:19

otherwise, use the war approach

thedavidmeister13:05:40

is there a need to use a jar? because the war worked fine for me and is easier to setup

leontalbot13:05:33

Actually it was more to add use cases to the doc. Why does one need a jar?

thedavidmeister13:05:50

i need one because i’m using sente instead of castra

thedavidmeister13:05:01

so, kind of irrelevant in a castra tutorial 😛

thedavidmeister13:05:09

basically, sente needs http-kit

thedavidmeister13:05:24

but the default is jetty

leontalbot13:05:41

Http-kit seems to have more and more traction

leontalbot13:05:44

Why do you need Sente over Castra?

thedavidmeister13:05:52

um, castra didn’t easily support my custom defrecords

thedavidmeister13:05:07

also, i’m sending dozens of small data points down the wire and it’s important the send order is preserved

thedavidmeister13:05:55

websockets makes sure the order of things being sent is preserved

thedavidmeister13:05:07

as soon as sente returns me info, i just stick it in a cell

lspector14:05:26

@leontalbot: the deployment instructions look great to me, assuming the new template works (I haven't tried it from scratch yet).

lspector14:05:47

@leontalbot: I found hoplon via the clojure google group, in William La Forge's reply to my query here: https://groups.google.com/forum/#!topic/clojure/xAnl5UR4V1E. The other replies looked promising but once I dug in it turned out I needed more of a general javascript/web programming tutorial than I have time for right now. Hoplon gets me much further with just my Clojure knowledge, and with the deployment instructions worked out may get me as far as I need to get for my current project, unless I end up needing something fancier than I anticipate.

leontalbot15:05:57

Great to hear!