Search code examples
haskellyesodketer

Including extra directories with Keter


I have a Yesod site and have created a handler for handling downloads and enforcing constraints. My Yesod project directory has a subdirectory called downloads, and it contains files I want the user to be able to download if they are logged in. The handler works great in my development and staging boxes, but breaks when I transfer to production. I tracked the problem down to yesod keter not archiving the files when it builds its bundle.

How do I convince keter to include the directory?


Solution

  • All the yesod keter command does is create a .tar.gz compressed archive file with the .keter extension containing the following subdirectories:

    • config: an exact copy of the identically named directory in your source tree
    • dist: contains a subdirectory bin containing your app's binary
    • static: an exact copy of the identically named directory in your source tree

    Note that the path to your app's binary is set in config/keter.yml via the exec setting while the path to your static files is set via the root setting. The exact set of files included by the yesod keter command is specified in the findFiles function if you want to take a look at the source code.

    If you want to customize the contents of your .keter file it is probably most straightforward to write a shell script to create the archive. With this script you can add arbitrary extra directories to the archive.

    The bare minimum bash script you'd need to emulate the behaviour of yesod keter is as follows:

    #!/bin/bash
    tar cvf myapp.keter config/ dist/bin/ static/
    

    You can customize this however you want to produce the correct content. Adding download/ to the end of this command line should do the trick.