Skip to content

Latest commit

 

History

History
95 lines (63 loc) · 2.29 KB

heroku.org

File metadata and controls

95 lines (63 loc) · 2.29 KB

You push your code to heroku.

git push heroku master 

Heroku then builds your code. Since we want it to build *.cljs files, we can supply our own bin/build executable script to run our desired commands.

Heroku then launches the process, specified in it’s Procfile.

The app specified in the Procfile is run on a Dyno.

Explicitly set buildpack

heroku buildpacks:set heroku/clojure

CLJS buildpack 4 heroku

Clojure buildpack can be configured to run custom command:

heroku config:add BUILD_CONFIG_WHITELIST=BUILD_COMMAND
heroku config:add BUILD_COMMAND="lein with-profile production do cljsbuild once, compile :all"

Export the BUILD_COMMAND variable to build time environment. Set custom BUILD_COMMAND. Here it is cljsbuild followed by the clojure compilation.

Initially just do cljs with

heroku config:add BUILD_CONFIG_WHITELIST=BUILD_COMMAND
heroku config:add BUILD_COMMAND="lein cljsbuild once"

https://elements.heroku.com/buildpacks/heroku/heroku-buildpack-clojure

Make it a PHP default app

Heroku wont host simple html-javascript apps, so we need to trick it by telling it that it is a PHP app instead.

$ echo '{}' > composer.json
$ git add composer.json
$ git commit -m "add composer.json for PHP app detection"
$ heroku buildpacks:set heroku/php

Try Again Sept 2020.

overview

We are going to do a standard clojure side project that will serve up the clojurescript. So we aren’t going to try to deploy a front end without a backend.

steps

procfile

have a <project>/Procfile file with:

╭─fenton@ss9 ~/projects/supps ‹heroku-work*› 
╰─$ cat Procfile 
web: clj -m supps.core -p$PORT

build file

The build file is what is run after a deployment.

╭─fenton@ss9 ~/projects/supps ‹heroku-work*› 
╰─$ cat bin/build                                       1 ↵
#!/usr/bin/env bash

echo "Starting to build cljs application"
echo "----------------------------------"
clojure -m cljs.main -O advanced -o resources/public/cljs-out/fe_dev-main.js -c supps.core

FILE=resources/public/cljs-out/fe_dev-main.js

if [ -f "$FILE" ]; then
    echo "Finished building file: $FILE"
    exit 0
else
    echo "Build of $FILE failed!"
    exit 1
fi