herokudatomic

How can I use Datomic Pro on Heroku?


I'd like to use Datomic Pro (Starter Edition, for now) on Heroku. But I don't want to commit my download key into Git. Instead, the right thing to do would seem to be store it in an environment variable. That means my project.clj now contains:

:dependencies [[org.clojure/clojure "1.5.1"]
               [com.datomic/datomic-pro "0.9.4707"]]
:repositories {"my.datomic.com" {:url "https://my.datomic.com/repo"
                                 :username ~(System/getenv "DATOMIC_EMAIL")
                                 :password ~(System/getenv "DATOMIC_KEY")}}

I've set DATOMIC_EMAIL and DATOMIC_KEY in the Heroku app's config. Turns out that doesn't matter, because the project.clj is processed during the build phase, without access to the environment variables.

Now that the user-env-compile feature no longer exists, how can I get Datomic running on Heroku?

(I could fork the buildpack and force the environment variables to be used during the build phase, but I'd rather avoid going that far if I can.)


Solution

  • I think you no longer need to fork the buildpack. Heroku recently made changes to their buildpack API that allow buildpacks to see environment vars that you've set for your app.

    As described in Clojure buildpack's README, you need to set BUILD_CONFIG_ALLOWLIST var to something like this: DATOMIC_EMAIL DATOMIC_KEY and also, of course, set DATOMIC_EMAIL and DATOMIC_KEY vars accordingly.

    Hope this helps.