Datahike + Heroku = Instant Datalog backed Clojure Web App
Some time ago I looked into easy simple deployment options for a hobby Clojure web app.
My main objectives being:
I used Heroku in my Ruby on Rails heydays, where it shined with simplicity. Turns out, it is still around and it looks well suited for deploying a Clojure app.
Heroku + Clojure +
Heroku has an integration with Leiningen and a complete guide for Clojure with a demo app. However, I prefer the Clojure CLI tools with a
deps.edn over Leiningen for managing my projects.
One can do that by just providing a custom
bin/build file in the app repository, together with a
Procfile which in tandem tell Heroku exactly how to build and then run the app.
You all know Datomic, which I love and use in production. Datahike is also a Datalog database, which started as a port of DataScript, but has quite evolved and can persist data into a bunch of backends, including PostgresSQL.
Datahike + Heroku PostgreSQL
The Postgres database once can provision for an Heroku app can be used with out of the box Datahike with after they fixed a configuration issue. One just has to deconstruct the
DATABASE_URL Heroku provides and feed it into the Datahike configuration.
Up and Running
To tie it all together, I made an app template: https://github.com/kommen/datahike-heroku
If you have
clj-new (which you really should, btw) and the Heroku command line tools installed (just
brew install heroku) you can have your Datahike powered web app up and running within a few minutes:
README has the rest of the few steps needed get the app live.