This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-03-11
Channels
- # ai (2)
- # announcements (5)
- # babashka (16)
- # beginners (24)
- # calva (22)
- # clerk (2)
- # clj-yaml (4)
- # cljsrn (1)
- # clojure (15)
- # clojure-dev (7)
- # data-science (5)
- # datalevin (1)
- # emacs (21)
- # events (1)
- # hyperfiddle (33)
- # lsp (71)
- # membrane (1)
- # podcasts-discuss (1)
- # practicalli (11)
- # re-frame (17)
- # reagent (3)
- # sci (1)
- # shadow-cljs (47)
- # transit (1)
Has anyone gotten clojure w/deps.edn running on heroku recently? I tried the blank project.clj trick and the build script runs, but for whatever reason doesn't see my uberjar.clj
file
uberjar.clj
file? Do I assume you mean the built project-name.jar
uberjar file?
I used to use the following customised Leiningen build for Clojure CLI projects previously - but since then have cancelled all my Heroku accounts (Note: I used to work for Heroku 2012-2017)
https://practical.li/clojure-web-services/projects/status-monitor-deps/deployment-via-ci/ (this content will be deprecated soon)
Rather than the build from source approach on Heroku, a docker image could be created locally and deployed on Heroku.
Or if possible to change your deployment service, consider https://render.com/ (there are other services too) (Note: I dont work for any cloud service company)
(ns uberjar
(:require [clojure.tools.build.api :as b]
[org.corfield.build :as bb]
[clojure.java.shell :as sh]))
(defn -main
"Builds an uberjar"
[& _]
(let [tailwind-run-result (sh/sh "bb" "tailwind")]
(when (not= 0 (:exit tailwind-run-result))
(binding [*out* *err*]
(println (:err tailwind-run-result)))))
(let [class-dir "target/classes"
uber-file "target/standalone.jar"
opts {:class-dir class-dir
:compile-opts {:direct-linking false}
:main 'proj.main
:uber-file uber-file
:exclude ["license(.)*"]
:src-dirs ["src"]
:resource-dirs ["resources" "prod"]}]
(b/delete {:path class-dir})
(bb/uber opts)
(println "Uberjar is built.")
opts
(shutdown-agents)))
Was a bin/build
script added to the project with a command that would run the relevant code from the uberjar namespace to create the uberjar on Heroku?
This would be the same command run locally to create the uberjar file?
I'm running a deps.edn
project on Heroku, but from sources, and with a custom buildpack. :) So probably not useful to you at all.
remote: java.lang.NullPointerException
remote: at clojure.tools.deps.alpha.util.maven$make_session.invokeStatic(maven.clj:221)
remote: at clojure.tools.deps.alpha.util.maven$make_session.invoke(maven.clj:216)
remote: at clojure.tools.deps.alpha.extensions.maven$read_descriptor$fn__1047.invoke(maven.clj:111)
remote: at clojure.tools.deps.alpha.util.session$retrieve$reify__356.apply(session.clj:28)
remote: at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
remote: at clojure.tools.deps.alpha.util.session$retrieve.invokeStatic(session.clj:25)
remote: at clojure.tools.deps.alpha.util.session$retrieve.invoke(session.clj:18)
remote: at clojure.tools.deps.alpha.util.session$retrieve_local.invokeStatic(session.clj:35)
remote: at clojure.tools.deps.alpha.util.session$retrieve_local.invoke(session.clj:30)
remote: at clojure.tools.deps.alpha.extensions.maven$read_descriptor.invokeStatic(maven.clj:111)
remote: at clojure.tools.deps.alpha.extensions.maven$read_descriptor.invoke(maven.clj:106)
remote: at clojure.tools.deps.alpha.extensions.maven$eval1074$fn__1075.invoke(maven.clj:146)
remote: at clojure.lang.MultiFn.invoke(MultiFn.java:244)
remote: at clojure.tools.deps.alpha$expand_deps$children_task__662$fn__664$fn__665.invoke(alpha.clj:405)
remote: at clojure.tools.deps.alpha.util.concurrent$submit_task$task__298.invoke(concurrent.clj:35)
remote: at clojure.lang.AFn.call(AFn.java:18)
remote: at java.util.concurrent.FutureTask.run(FutureTask.java:266)
remote: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
remote: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
remote: at java.lang.Thread.run(Thread.java:750)
remote: Execution error (NullPointerException) at clojure.tools.deps.alpha.util.maven/make-session (maven.clj:221).
remote: null
remote:
remote: Full report at:
remote: /tmp/clojure-6079687224478408742.edn
remote: ! Failed to build.
remote: ! Push rejected, failed to compile Clojure app.
remote:
remote: ! Push failed
remote: !
Oh, another tidbit - I ended up being fed up with fiddling with building on Heroku whenever my build process would require something new. Ended up switching to Docker images (although with Podman instead of Docker), and definitely won't look back at pure source-based deployment.
WRT that error - there should be a way to print that report as well. I think you can add -J-Dclojure.main.report=stderr
to the clojure
command to do that.
I was able to run deps.edn project with this buikdpack https://github.com/andersmurphy/heroku-buildpack-clojure-tools.git and bin/build . It's important to set right versions of Clojure and jdk for app by system.properties and CLOJURE_CLI_VERSION env variable.
upgrading the jdk version from 8 mysteriously solved everything. not gonna think on it too hard
What version of jdk you use now?