Continuous Integration and Deployment

Posted on December 2, 2019
Tags: blogging

“How should I host my statically-generated website?” I thought to myself, considering several available options. * S3 buckets: gwern uses S3 buckets, I could too * netlify: I currently have a site on Pivotal’s hosted Cloud Foundry and another on netlify, so adding many more is going to get messy. Cloud Foundry is a great option if you want to run backend services, but for a statically-generated blog, I don’t need any of that. I just want to give my site directory to someone and be done with it. It looks like netlify should work for this use case, but I’m not sure how best to run the build before deploying it.

Initially, this hosting option didn’t feel like a great fit. Netlify’s main sell is its convenient hosting of a git repo, and in this case, things are a little messier. I loved my first experience hosting with them, but my build step was javascript-based Don’t worry, it was Elm, but you can fetch Elm with this npm package., and now I wanted to convince them to run Haskell.

The first question to ask here is “Can I install Haskell through npm?” but that seemed a little too far-out for me. Netlify seems to only expect dependencies in JS, Ruby, or Python, and they don’t have many build image options (none with Haskell), so I’m not sure they’d be willing to fetch me the massive binaries for GHC regardless of how I requested them. Netlify does have an option to deploy without using their CI, and that’s likely my best option. I recently found a post by Justus Perlwitz documenting his approach to hosting a hakyll site on netlify, and he didn’t use their CI: this confirms my initial thinking that it would be a bad fit, but gives me a great path forward elsewhere: CircleCI.

I copied the .circleci/config.yml file over from Justus’ GitHub repo, but Circle kept giving me a “Process exited with code: ExitFailure (-9) (THIS MAY INDICATE OUT OF MEMORY)” error. I decided it was more valuable to get my site up than to get it running on CI, so I added a new site on netlify without Git integration, added netlify-cli to my project as a development dependency. I am not clear on how authentication works for the CLI, but running npx netlify init opened my project in the browser and let me easily give OAuth permissions to the CLI, and added a .netlify directory to my project. It’s got a file in it named state.json. This file has a UUID named “siteId” in it. It would be really insecure if that was all it took to deploy to my site, someone would just enumerate all the UUIDs with posts to deploy garbage, but I’m not sure where the CLI stores any more state. I expect it uses my SSH key for authentication, but that’s not very clear. If anyone knows the details of it, let me know. For the time being I have deployed successfully to netlify, I updated my DNS settings in cloudfront, and I’m waiting for the blog.lutra.tech CNAME record to propagate.