Fork me on GitHub
#hoplon
<
2016-09-10
>
dvingo16:09:43

does anyone have a gist or know of any docs for building a hoplon app for production? maybe @thedavidmeister

dvingo16:09:05

i've tried digging thru the examples, but they are all broken, https://github.com/hoplon/demos/tree/master/deploy-uberwar

micha16:09:31

for production i always deploy the frontend to s3/cdn

micha16:09:48

and communicate to the backend via CORS

micha16:09:08

so the hoplon part is compiled and uploaded to s3 and that's it for production

dvingo16:09:18

that would work, i'm stuck at the first step though - I can't get static files to build

dvingo16:09:37

or maybe i'm confused as to what prerender does

dvingo16:09:44

because i get index.html.js

dvingo16:09:53

and then index.html has a script tag that pulls it in

dvingo16:09:59

which is still client side rendering

micha16:09:42

prerendering is for search engine crawlers and for things like splash screens while the js is loading

micha16:09:08

if you use prerendering you should see your application content in the body

dvingo16:09:08

i thought it would execute the js to generate html

micha16:09:15

yes it should do that

micha16:09:21

do you have phantomjs installed?

dvingo16:09:36

looks like it

micha16:09:40

it will print a notice that it's skipping the prerendering step if you don't

dvingo16:09:40

$ phantomjs phantomjs>

dvingo16:09:55

yea - didn't get any messages, the task just finishes

micha16:09:32

and you have the prerender task after the cljs task?

micha16:09:44

like (boot (hoplon) (cljs) (prerender))

dvingo16:09:56

(deftask prod [] (comp (sass) (hoplon) (cljs :optimizations :advanced) (prerender)))

micha16:09:05

yeah that should work

dvingo16:09:15

will that write to disk or do i need the target task?

micha16:09:17

you need the target task too

micha16:09:30

at the very end of the pipeline of course

dvingo16:09:34

ah ok, that's missing in some examples so i was confused

micha16:09:51

you don't ned it if you're using a local server for instance

micha16:09:16

it can slow things down so it's not added by default

dvingo16:09:40

are the files written to a temp dir without the target task?

dvingo16:09:48

or just in memory?

micha16:09:58

they're all real files, in temp dirs

micha16:09:17

boot has efficient filesystem patching/diffing stuff in it

micha16:09:32

because the files in the fileset are immutable

micha16:09:37

and content-addressed

micha16:09:58

the files you interact with are actually just hardlinks to the content-addressed, immutable blob storage

dvingo16:09:37

interesting

dvingo16:09:01

well , thanks for the help i'll keep digging. i'll throw together a wiki page when i figure out the full deploy - i'll need the server side running as well

dvingo17:09:25

i'm really just looking for a gist of some shell commands to run, figured this would be a common thing that someone has gone thru before

flyboarder17:09:08

@danvingo: what kinda of shell commands are you looking to run?

dvingo17:09:25

i just mean a walkthru of how to build for a prod and run

dvingo17:09:40

on a normal unix-like environment

dvingo17:09:52

there just aren't any examples to reference that have all the steps

dvingo17:09:22

I just think it's odd for all the effort and documentation that exists for hoplon that there isn't any mention of how to deploy for production

flyboarder17:09:58

@danvingo: i think it's kinda hard to have exact examples since you can do pretty much whatever you want with boot as a build tool, we use it for regular OS related tasks too

flyboarder17:09:41

Also hoplon builds regular web files, you can serve them however you want, if you do prerendering then you just have static things

dvingo17:09:57

for hoplon specifically - it's a web application framework so some common examples would be good

flyboarder17:09:27

Agreed but I think that is more "target platform" dependent

dvingo17:09:07

i'm just saying from an ecosystem point of view my experience trying to get a simple app deployed has been terrible

dvingo17:09:26

and i would not choose to use this again just because of that

flyboarder17:09:07

Really? That's interesting iv found hoplon to be the easiest to build with from my experience thanks to boot

dvingo17:09:24

even just a page saying, hoplon uses boot, you can do a lot with boot so you should first make sure that you are comfortable with boot before continuing

micha17:09:58

i heard that github has fixed the gh-pages situation

micha17:09:18

so you can now make a folder that github pages will serve, you don't need to make the gh-pages branch anymore

micha17:09:25

so maybe that could be the example we show

micha17:09:50

compile hoplon to static files that go in the docs dir, push to github, and you've deployed to produciton

flyboarder17:09:51

@danvingo: where are you trying to run your app? Documentation is a thing that's been expanding the last year we could have a wiki page with how to build for different env

dvingo17:09:55

i'm making some progress from this template

dvingo17:09:10

got the war deployed with: heroku deploy:war target/project.war --app floating-island-79453

flyboarder17:09:45

@danvingo: heroku supports docker images, there are docker images for boot out in the wild too

micha17:09:09

perhaps add a section to the getting started wiki page? https://github.com/hoplon/hoplon/wiki/Get-Started

dvingo17:09:13

@flyboarder i don't have a preference, just want to : 1. build static assets 2. start clojure server

flyboarder17:09:57

Your app relies on castra yea? So you need a backend server also?

dvingo17:09:02

@micha - yea, i don't mind updating with the heroku steps when i get it workikng

dvingo17:09:09

yep - using castra

flyboarder17:09:56

@micha I think the challenge is how do I host my app, this is something I also had to wrap my head around since I came to hoplon without Java knowledge

onetom17:09:23

@flyboarder: what platform issues have you ran into? I hit an sqlite minor version incompatibility but only because osx had a slightly older version than my prod, so that was not strictly osx specific other than that if im shell scripting, then some of the utils have different options, eg. date, ls, du, test maybe but its sooo infrequent it doesn't really matter

onetom17:09:45

@flyboarder: regarding resolution, just use the same aspect ratio when mirroring and then it won't be so crap!

onetom17:09:49

@flyboarder: also on newer OS X versions you can put 2 full screen apps next to each other and specify the split ratio between them (not from keyboard though...)

dvingo17:09:50

ahhh, the heroku deploy worked! phew

onetom17:09:19

@alandipert @danvingo: there is also brew install jetty-runner (i havent tried it yet though)

dvingo17:09:59

i'll update the getting started guide with a section on deploying to heroku

onetom17:09:07

@alandipert @micha: sounds like you would have liked acme back then 🙂 http://plan9.bell-labs.com/sys/doc/acme/acme.html

onetom17:09:34

@jamieorc @flyboarder im also using (boot-)environ still but im considering https://www.dotkam.com/tag/cprop/ (which was missing from the "Real World Clojure" article)

flyboarder17:09:01

@danvingo: are you using heroku build packs?

jamieorc17:09:06

@onetom Thanks. How do I get hoplon/ui running. boot dev throws errors that it can’t find the lib when I include it in the project.

onetom17:09:10

@micha: i've seen those strange castra errors too. i think it happens when you cancel an xhr request (because boot-reload reloaded the page for example)

dvingo17:09:04

the css static files are 404'ing though so will have to keep playing with it

onetom17:09:26

@jamieorc

git clone [email protected]:hoplon/ui
cd ui
boot build-jar
then your project will find it

tbrooke17:09:33

@flyboarder @danvingo the basic Hoplon deploy is simple - but it gets more difficult with Castra - maybe a docker image for Hoplon with Castra and Boot for good measure would be nice - a one stop image

flyboarder17:09:37

@tbrooke yeah i think when you start using hoplon you really want to use castra without knowing all the difficulties of hosting java servers, i think if we had a Serving Hoplon and Serving Hoplon with Castra in the wiki that would help guide those coming to hoplon, especially without java knowledge

tbrooke18:09:38

Any one else looked at https://www.netlify.com/ they are pretty good for static sites, Hoplon without castra, and they support build tools including leiningen - I mentioned boot to them and they said they were adding it but I’m not sure if they did

jumblerg19:09:42

@tbrooke: interesting, i’ve heard good things about them before, but looks like they’ve come a long way since they were just a cdn. let me know what you find out, will do the same.

flyboarder19:09:33

@tbrooke are you using http/2 with them?

tbrooke19:09:58

@flyboarder No consciously but they say it is enabled for all https: https://www.netlify.com/blog/2015/10/20/netlify-news-no-6

dvingo20:09:26

Thanks @flyboarder will update with what i've found

flyboarder20:09:00

@danvingo if we can solve your issues with some documentation i think it’s worth it for everyone 🙂

dvingo20:09:20

agreed 🙂

jamieorc22:09:17

Sometimes I’m getting a "core.cljs:120Uncaught ReferenceError: jQuery is not defined” error. This happens when I call a function directly in the rpc cljs file.

flyboarder22:09:00

@jamieorc I would imagine your cljs file is loading before jquery then, try adding cljsjs.jquery to the namespace in your :require

jamieorc22:09:49

@flyboarder that did it. Cheers

jamieorc22:09:26

@flyboarder I keep getting "#error {:message Server error., :data {:castra.core/exception true}}” Is there a way to see what the exception is?

flyboarder22:09:05

Should be showing up in your console no?

jamieorc22:09:05

no error there. I’m trying to send a list back from mongodb using monger. I have a similar, though slightly simpler app that works. I’ve been trouble-shooting this a while and am stumped. I can return a hard-coded list no problem. When I output the list to console, it’s what I expect. Castra blows up on the list. Yet something very similar in another app is fine with Monger.

flyboarder22:09:26

I dont use castra anymore, but I remember running into similar issues

flyboarder22:09:20

@micha do you have a suggestion for castra exceptions?

flyboarder22:09:36

I remember you solved this for me before too

jamieorc22:09:18

@flyboarder what’re you using rather than castra?

flyboarder22:09:36

🙏 No-Backend

flyboarder22:09:28

@jamieorc I kinda hate the idea of a backend for my web apps, also many databases have little to no security because they assume opperation on a trusted network. Thats like saying not to put a lock on your house because you have a fence.

jamieorc22:09:55

I’m experimenting with integrating hoplon/castra with a large existing backend, so I’m rather stuck with it

micha22:09:30

the exception stack trace is in the exception object

micha22:09:46

(.-serverStack ex) will be how you get to it

micha22:09:28

group- and error are macros from the adzerk/cljs-console library

jamieorc22:09:18

@micha thanks, I’ll have a look

jamieorc22:09:50

Oof. I thought it might be something like this: "Caused by: java.lang.RuntimeException: java.lang.Exception: Not supported: class org.bson.types.ObjectId at com.cognitect.transit.impl.WriterFactory$1.write (WriterFactory.java:129)"

jamieorc22:09:11

now I know why the other app worked. I was retrieving objects with Strings for ids rather than ObjectIds for ids.