Deploying a Haskell web application to the Cloud

We want to expose our logic that is programmed in the functional programming Haskell as a web service and need to deploy it as a public web service. For this we want to use a PaaS (Platform-as-a-Service) vendor, i.e., 'Cloud hoster', in order to publish this web service with minimal configuration.
1 answer

Deploying a Haskell web application to Heroku

In order to work with Heroku, we need to have our project in a Git Repository (Source Control), an account at Heroku and its toolbelt, and the Heroku Haskell Buildpack. The following paragraphs will outline the process:

1. Step: Login or Sign up for a Heroku account

You may sign up here: https://api.heroku.com/signup/devcenter
It's free for 1 instance, which is enough for testing purposes

Step 2: Install the Toolbelt

Heroku Toolbelt is a command line tool that provides functionality to interact with the Heroku platform.
The toolbelt can be downloaded here: https://toolbelt.heroku.com/

Step 3: Login

In order to use Heroku, you must login with the following command:


heroku login

...and provide your credentials

Step 4: Create an app at Heroku with the proper buildpack

Log in at Heroku and create an app instance using the following commands


echo 'web: cabal run -- -p $PORT' > Procfile
heroku create --stack=cedar --buildpack https://github.com/begriffs/heroku-buildpack-ghc.git
git push heroku master

The first deployment IS VERY SLOW, because all dependencies need to be installed on your Heroku instance. So wait a little bit the first time around.

Sometimes you need to upgrade the 15 minutes time limit for this:


heroku plugins:install https://github.com/ddollar/heroku-anvil
heroku build -r -b https://github.com/begriffs/heroku-buildpack-ghc.git

Step 5: Deploy

Now you can deploy everytime you push to master

git push heroku master

And your web application/web service is now available at [appname].herokuapp.com

Taggings: