Fork me on GitHub
#fulcro
<
2022-04-27
>
tony.kay06:04:47

Fulcro 3.5.19 released. Includes a bugfix for tempid remappings (held in network queues), and a new active-routes helper in dynamic-routing.

❤️ 1
sheluchin19:04:59

I've never published anything in Clojure before. Could someone please link me to some resources where I can learn about how to deploy a Fulcro app with a backend? If it's in the docs, I think I'm not searching for the right words. Not sure it's entirely Fulcro-specific or not - probably not - but I don't have the awareness to discern that right now, so I thought I'd ask here. For background, I do have experience doing this kind of thing for Python applications.

xceno19:04:12

It's not fulcro specific, but take the rad demo for example: Your server is a standard ring backend. The only thing you'd have to add is a main function to start the server, like so:

(ns my-app.server-main
  (:require
    [mount.core :as mount]
    my-app.components.server)
  (:gen-class))

;; This is a separate file for the uberjar only. We control the server in dev mode from src/dev/user.clj
(defn -main [& _]
  (println "Starting Application...")
  (mount/start-with-args {:config "config/prod.edn"}))
Anything else depends on how you want to deploy it. So if you'd instead like to deploy it as datomic ion You'd do something like this:
(def http-direct-handler
  "Our main HTTP-Direct entry point.
  See: "
  (wrap-catchall
    (fn [request]
      (mount/start-with-args {:config "config/prod.edn"})
      (server/middleware request)))))
And expose that function in a datomic-ion config. I don't have any links to share right now. But anything that deploys any kind of clojure app should be useful to you.

Jakub Holý (HolyJak)21:04:42

This https://github.com/holyjak/fulcro-billing-app/blob/main/build.sh also builds the full app, with front and back, into a jar + dependencies jar. If you run the commented-out last line it will put all that into a docker container that you can deploy anywhere, eg http://fly.io

dvingo01:04:31

The best mental model I've found is realizing that at the end of it your goal is to launch a jvm process with the proper code (classpath) on some machine (on a local machine, a VPS, in a docker container in a managed system, etc). Studying these docs for clojure.main and playing with examples made a lot of things click for me: https://clojure.org/reference/repl_and_main#_the_clojure_main_namespace When you use clj or clojure command-line tools this is what they're doing: https://github.com/clojure/brew-install/blob/690dadd12c8718fc7682cf68c8dd84db9d3843c5/src/main/resources/clojure/install/clojure#L485 You can make a copy of the clojure shell script on your system and add echo statements to see what it does to gain more insights too So your deploy process becomes answering the questions: • where you want your program to run • how you copy your source code there • how to invoke java there

dvingo01:04:19

this means you can use any method to start clojure. Making an uberjar of your project and executing java -cp app.jar clojure.main -m co.myapp.server-entry is one way. You can also install the clojure cli on a server and start your app with a clojure source file: clj -M /srv/app/start.clj

Hukka06:04:07

I know this is totally not relevant for a beginner project, but you could run clojure without starting JVM/java by compiling to native too

sheluchin13:04:36

Thanks for the advice everyone. Hopefully I get it running soon enough. At the moment I'm trying to just follow along with the build.sh that @U0522TWDA posted, but when I run: clojure -M:shadow-cli release :main, I get this cryptic exception that I can't figure out the root of... looks like a malformed spec, but I don't know where.

dvingo13:04:22

that looks like a defn has some syntax errors someplace:

Caused by: Syntax error macroexpanding clojure.core/defn
this error should show up in a repl as well if that's easier to debug

sheluchin13:04:03

When I just run the app, I don't get such an error anywhere... it runs as it should..

sheluchin13:04:43

And linting my src/ directory doesn't show anything obvious either.

dvingo14:04:17

could be you need to add another deps.edn alias to that invocation for release clojure -M:shadow-cli release :main -A:dev etc

dvingo14:04:00

you can start a clojure repl then invoke the shadow.cli from there, would probably give better errors

dvingo14:04:34

not sure if you saw this, but auspicious timing for your question: https://www.metosin.fi/blog/packaging-clojure/

sheluchin14:04:27

No, haven't seen that. Thanks very much for that link too!

Jakub Holý (HolyJak)14:04:04

>

#object[clojure.spec.alpha$and_spec_impl$reify__655 0x288ca5f0 "clojure.spec.alpha$and_spec_impl$reify__655@288ca5f0"] is not a fn, expected predicate fn
is really weird. I would verify that you have clojure core spec (not the lib but spec for clojure.core itself) and look at the versions of clojure and clojure.spec and this lib. Are they ok?

sheluchin14:04:14

Ah ha, looks like it's because I didn't include the hyperfiddle/rcf dep. That makes sense, I just wish the trace offered some hint about that. I'll see if running shadow from the REPL gives better output.

sheluchin15:04:29

No, that's not quite it either. Really strange, I don't understand it, but as long as I have :extra-paths ["src/dev"], and there's an empty (ns user) in there, it builds. Otherwise it gives me that exception about defn. Anyone have an idea about what I could be doing wrong here?

:shadow-cli {:extra-paths ["src/dev" "resources"]
                        :extra-deps
                        {thheller/shadow-cljs {:mvn/version "2.16.12"}
                         binaryage/devtools {:mvn/version "1.0.0"}}
                        :main-opts ["-m" "shadow.cljs.devtools.cli"]},
$ tree src/dev/
src/dev/
└── user.clj

0 directories, 1 file

$ cat src/dev/user.clj
(ns user)
I don't want dev on my classpath at all for release, so I shouldn't need it as an :extra-path.

Jakub Holý (HolyJak)15:04:41

Bad autocorrect. Ask in #clojure

sheluchin15:04:15

Okay, thanks.

dvingo16:04:47

it's expected to need a :dev profile or similar when compiling clojurescript - but you seem to have a different setup. I'm not sure without a repository to look at the details

sheluchin22:04:56

I fiddled around with it, couldn't figure it out. Got some more help and still couldn't get to the bottom of it. Ultimately ended up deleting my ~/.m2 and after that things just worked :man-shrugging: My config is kinda in a state of transition right now as I work on deployment for the first time, but I'm sure there's some mess in there that I should clean up. I've been putting off getting too deep into the config stuff, but this is a good opportunity to get more familiar and iterate.

dvingo17:04:15

oh man, that's rough. I don't have much feedback other than at the higher level of problem solving in general. I only recently read the book Rich Hickey commended here: https://youtu.be/f84n5oFoZBc?t=493 (how to solve it) and wow! it had such a major impact on how I approach situations like this where you are seeing crazy behavior. it gives you systematic way to go about solving problems that feature unknown information (ie. all problems) perhaps not directly applicable for this situation but likely will help going forward

❤️ 1
sheluchin19:04:29

Ah, yes... Polya's How to Solve It. I've been meaning to check that out since I saw it mentioned in the back of The Little Schemer. The only thing that's been holding me back is, well, learning other stuff 😛 and my math is a bit rusty, so I don't want to distract too much from programming by brushing up on my math skills. You found the book generally applicable towards solving programming problems? Was it heavy on the math or can you just read through it somewhat casually? Anyhow, I'm making good progress on the deployment effort today. That Metosin article was quite helpful in seeing the big picture. I think I'm just going to deploy without Docker or an Uberjar for now - just using the git checkout method - but will eventually move towards containerizing it. I like the idea of being able to hack directly on my deployment in the initial stages of my project launch, which a deployed artifact wouldn't allow, as far as I understand.

dvingo20:04:21

ha yea I had the same problem (I'll get to it eventually - and oh maybe I need to brush up on math first) something made me think of it again recently and I decided to just go for it and read it. It turns out that it only features basic math as the book is intended for a mass audience. the other fascinating thing I learned from it is that "Heuristics" used to be treated as a scientific field - the field of solving problems and it was believed that you could improve upon solving all problems instead of treating them randomly. From the book: "The aim of heuristic is to study the methods and rules of discovery and invention". and goes on to say "The present booklet is an attempt to revive heuristic in a modern and modest form" It is really unfortunate the way language works sometimes when words change meaning and a new word isn't used. It's really difficult to search because of the modern meaning of heuristic, but I did find this: https://pure.mpg.de/rest/items/item_2139307_11/component/file_2404607/content > The German philosopher Gottfried Wilhelm Leibniz (1646–1716) had a similar, though even grander goal in the seventeenth century, namely to develop an algorithm for solving any conceivable problem, using a universal language that would allow every possible problem to be represented. and https://en.wikipedia.org/wiki/De_Arte_Combinatoria it's pretty fascinating stuff and a shame that we no longer (in the mass/popular culture) have such high regard for the art and science of problem solving. It's one of the nice things about the clojure community (and its creator) that this sort of meta-reasoning is encouraged just a few more resources 😛 I watched these recently and they touch on some similar concepts, but more directly applied to programming https://www.youtube.com/watch?v=S-LWg-tHboY https://www.youtube.com/watch?v=FihU5JxmnBg

❤️ 1
sheluchin14:05:57

@U051V5LLP Alright, you've convinced me.. I'm going to start on How To Solve It 🙂 That is an interesting bit about Heuristics. I guess that in a way, that area of study somewhat paved the way for the machine learning and AI approaches to programming that are gaining popularity today. They're more generalized ways of solving problems, rather than the specialized domain modelling sort of work many programmers are used to. I've seen that Stuart Holloway talk before. It's pretty good. Like many Clojure talks, it's probably a good one to revisit once in a while. I'll check out the other one. I too enjoy Clojure's Hammock Driven development style and approach to problems. Anyway, thanks for the links and stuff. I'm automating my deployment process with Babashka and Spire :thumbsup:

❤️ 1
dvingo14:05:32

Nice! Feel free to share any inspiring/enlightening talks/books you come across as well 🙂 For the debugging talk I found his slides to be very helpful in digesting the info: https://github.com/stuarthalloway/presentations/blob/master/Conj_2015/DebuggingWithTheScientificMethod.pdf Looking forward to hearing about your automated deployment too!

Mateusz Mazurczak20:04:53

Will there be a support for react version 18?

tony.kay23:04:22

I don’t see why not. React has generally been good at BW compat.

tony.kay23:04:32

I don’t see anything in their release announcement that is a deal-breaker

Mateusz Mazurczak07:04:13

There is one thing: Warning: ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17.

Nundrum21:04:49

How do I use vim-fireplace with Fulcro? I can :Connect to the nREPL, but anything I try to evaluate just returnes Fireplace: no default ClojureScript REPL.

maxxcan22:04:51

hello everybody. I introduce myself. I want to make a mobile app with fulcro and re-frame. My problem is that I want to use the bbdd of a wordpress that I create before. Which is most advisable, I will connect to mysql of wordpress with fulcro-sql (I think that is problematic with mysql) or I will use h2 which can be connected to mysql?? Thanks

lgessler23:04:41

what's a bbdd?

lgessler23:04:13

I assume from the rest of what you said that bbdd means the mysql instance, right?

maxxcan23:04:26

yes, sorry I mean database.

Hukka06:04:37

What would it mean to have fulcro and re-frame at the same time?

lgessler14:04:15

I haven't worked with fulcro-rad so I can't really help you @U412V0LRG, but hopefully someone who has can 🙂

Patrick Brown12:04:16

Personal Experience: At first I wanted to incorporate Re-frame into Fulcro, but I found it’s going a little too far against the grain and my reasons for wanting to do so were very lame. I do think that if subscriptions really fit your project’s domain there can be some value found with Re-frame.

maxxcan14:04:52

thanks @U036UJBDM5G My point of view is a create a full app with version for web and version for mobile

maxxcan14:04:11

I think that fulcro could to be the answer

Patrick Brown14:04:31

It can be. It can also be overkill. Where Fulcro excels is in limiting complexity of the complex, but that comes with a learning curve. It’s great fun to learn. It just isn’t the usual web dev paradigm. It also isn’t exactly a ‘Hello World’ use a lein template framework.