Haskell Container Deployment
Created at 2016-07-24T00:13:43.000Z

This post explains how I deployed Yesod application on Heroku. Code is available here: https://github.com/hi-ogawa/yesod-experiment

I put whole process into single docker-compose.yml file. Main services are listed below:

  • test: run cabal test
  • builder: run cabal install and create tar file of executable called production.tar.gz
  • distributor: build production image following Dockerfile.dist
  • flyway_production: run migration on production db by using flyway as dockerized one

Architecture

2016-07-24 18.11.18

Notes

  • Since test service and builder service share same build cache via docker named volume, there's no overhead to download/install dependency for each deployment.
  • Thanks to new feature of docker-compose (e.g. named volume, extends), I could put many logic in one docker-compose.yml file.
  • All docker-compose commands are wrapped with Makefile.

Improvements

  • use stack instead of directly dealing with cabal
  • put docker-compose services (below steps) into automated pipeline (e.g. self-hosted Jenkins or other cloud services)
    • run test service
    • run builder service
    • build distributor service
    • push production image to repository

References