A Heroku Buildpack for Factor applications.
When Heroku receives your code, this buildpack downloads Factor and places your code in the work
directory, so your repo's root should be that of the work
directory.
If your app is USING
large vocabularies that could delay start up time, such as furnace
, this buildpack allow you to create a pre-baked, cached image. To do so, add a system.properties
file to the root of your project with a factor.image.using
property specifying which vocabularies to include in the image. For example:
$ cat system.properties
factor.image.using=furnace
This is an example of creating a Furnace web app on Heroku using this buildpack. The code for this example is based on an article from Re: Factor about getting started with Furnace, which explains in detail how the app works.
To get started, first follow the Heroku Quickstart. For "Step 4: Deploy An Application," follow these steps:
-
Create an empty directory, change to, and initialize a Git repo:
$ mkdir hello-factor $ cd hello-factor $ git init
-
Create a Heroku app using this buildpack. A randomly generated app name will be generated.
$ heroku create --buildpack https://github.com/ryanbrainard/heroku-buildpack-factor.git Creating salty-depths-9179... done, stack is cedar BUILDPACK_URL=https://github.com/ryanbrainard/heroku-buildpack-factor.git http://salty-depths-9179.herokuapp.com/ | [email protected]:salty-depths-9179.git Git remote heroku added
-
Create a file at
webapps/hello/hello.factor
with the following contents. This is the code for the web application that will run on Heroku. Note that the server binds to thePORT
environment variable. Heroku will automatically supply a value forPORT
during start up of the web dyno.USING: accessors furnace.actions http.server http.server.dispatchers http.server.responses io.servers kernel namespaces environment math.parser ; IN: webapps.hello TUPLE: hello < dispatcher ; : <hello-action> ( -- action ) <page-action> [ "Hello, world!" "text/plain" <content> ] >>display ; : <hello> ( -- dispatcher ) hello new-dispatcher <hello-action> "" add-responder ; : run-hello ( -- ) <hello> main-responder set-global "PORT" os-env string>number httpd wait-for-server ; MAIN: run-hello
-
Create a file called
Procfile
with the following contents. TheProcfile
tells Heroku how to start your application.web: ./factor -run=webapps.hello
-
Create a file called
system.properties
in the root with the following contents. This is an optional file that will pre-bake in thefurnace
vocabularies into the image to speed start up times.factor.image.using=furnace
-
Add and commit everything to Git:
$ git add . $ git commit -m init [master (root-commit) 867242e] init 3 files changed, 25 insertions(+) create mode 100644 Procfile create mode 100644 system.properties create mode 100644 webapps/hello/hello.factor
-
Push to Heroku. The first push will take longer because the image is being prepared, but subsequent pushes should be faster.
$ git push heroku master Counting objects: 7, done. Delta compression using up to 4 threads. Compressing objects: 100% (3/3), done. Writing objects: 100% (7/7), 758 bytes, done. Total 7 (delta 0), reused 0 (delta 0) -----> Heroku receiving push -----> Fetching custom buildpack... cloning with git...done -----> Factor app detected -----> Downloading Factor... done -----> Preparing image... done -----> Preparing work dir... done -----> Discovering process types Procfile declares types -> web -----> Compiled slug size is 46.0MB -----> Launching... done, v4 http://salty-depths-9179.herokuapp.com deployed to Heroku To [email protected]:salty-depths-9179.git * [new branch] master -> master
-
View your running app:
$ heroku open