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:

  • not dealing with Google Cloud or AWS complexities

  • and also not managing my own VPS

  • a Datalog database

Heroku

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 + deps.edn

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.

Datahike

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 (justbrew install heroku) you can have your Datahike powered web app up and running within a few minutes:

clj -X:new create :template '"https://github.com/kommen/datahike-heroku@1ad6b45a6ee49a785f34ba9f12b10db3cae80399"' \
  :name myorg/testapp    
Bash

The template's README has the rest of the few steps needed get the app live.