reneklacan / yesod-heroku-example

Minimal example of a pipeline for deploying Yesod app to Heroku through CircleCI.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

yesod-heroku-example

Minimal example of a pipeline for deploying Yesod to Heroku through CircleCI.

How it works?

When you push change to the repository, CircleCI builds yesod application, runs tests and pushes statically linked binary to the Heroku.

As the Yesod app is statically compiled resulting binary doesn't need any dependencies.

Required CircleCI Environment Variables

Environment variables you need to define in CircleCI project settings:

Do It Yourself Guide

  1. Create a minimal Yesod app tack new YOUR_APP_NAME yesod-minimal
  2. Update src/Main.hs to use port from the PORT env var (example)
  3. Create .circleci directory in the root of your project and add config.yml and setup-heroku.sh
  4. Create a Heroku project with null buildpack heroku create YOUR_PROJECT_NAME --buildpack http://github.com/ryandotsmith/null-buildpack.git
  5. Add Heroku remote to your project heroku git:remote -a YOUR_HEROKU_PROJECT_NAME
  6. Add Procfile with default web process pointing to binary which will be created durinng CircleCI build - dist/YOUR_APP_NAME (example)
  7. Push your changes to your project's repo (Github or Bitbucket will both work)
  8. Create new CircleCI project for project's repository and add required environment variables (HEROKU_PROJECT, HEROKU_LOGIN, HEROKU_API_KEY) in CircleCI's project settings. (In case you are not familiar with CircleCI check out CircleCI 2.0 - First Steps)
  9. Now when you commit and push to your repository it will trigger CircleCI build which will deploy your app to Heroku
  10. Once CircleCI build is finished, visit your app on Heroku and verify that it works - https://YOUR_HEROKU_PROJECT_NAME.herokuapp.com/
  11. Celebrate

Alternatives

Another good alternative is to use Stack's docker integration to build a docker image and deploy it to Heroku Container Registry.

About

Minimal example of a pipeline for deploying Yesod app to Heroku through CircleCI.


Languages

Language:Haskell 67.0%Language:Shell 24.9%Language:Emacs Lisp 8.1%