• 2016-09-08

    Haskell and Docker: Down the rabbit hole and back

    For the past couple of years I've been learning Haskell, and while I enjoy reading new materials in forms of books, papers, blogs posts and even tweets, thankfully I quickly came to realize that the best way to learn is to build things.

    That's not to say I just jumped right in. I spent a long time just playing around with the language, exploring various language features, libraries and getting to know the ecosystem in general. Not doing anything serious 1.

    At the time that was a bit more painful than now because now-a-days there's a lot more resources and organized materials around. The community has really stepped up! 2

    Anyhow... Building things. I've been using docker since it was released and have grown from resident docker fan-boy to resident expert over time. Also I've been involved with the Python API wrapper since the early days so it made sense to try and write a Haskell API wrapper. At the time that was the closest I came to web development (the docker daemon listens on a HTTP API) as I felt comfortable.

    The first attempt was awful. But it worked! I was able to launch containers and everything. Of course, the API of the library was horrendous. There were very little type guarantees for anything and the whole thing was just one big giant IO blob.

    Having realized this, I went on a crusade to learn all the fancy type machinery and make use of every trick and extension under the sun. That attempt went on and off for a couple of months until I realized that I created a monster and that I didn't need half the stuff I was using. So, having went from one extreme to the other I decided to delete everything and start fresh. I had some guidance from a couple of friends (thank you!) and I was getting pretty close to an API I was (more) happy with and that should be usable by most people. The library being usable was one criteria, but the other one was that it's more or less straightforward to contribute to. The reason being that the Docker Engine API is kind of huge at this point and I'm certainly either going to miss something, or implement it wrong, and it should be more or less easy for anyone to go in, and contribute a bugfix or a feature. Naturally, this dragged on since obviously I was doing this for fun and in my spare time. Thankfully, I got help somewhere along the way when James Parker jumped in. He was instrumental in getting the library in better shape so that we can finally release that major refactored version.

    Read more…

    docker haskell

  • 2016-02-17

    Handling Permissions with Docker Volumes

    In this post I'll try to explain the method I use to avoid having permission issues when using Docker Volumes. This is pre Docker 1.10 (which added user namespaces) and I will talk about those in my next post.

    Before we begin let me explain what are Docker Volumes and what they're used for. The official Docker docs explain this feature as follows:

    A data volume is a specially-designated directory within one or more containers
    that bypasses the Union File System.

    The main use-case for volumes is for persisting data between container runs (seeing as container are ephemeral). This is useful for data directories when running databases (such as PostgreSQL) within containers. Other than persisting databases it's useful for sharing code folders from your host system to the container when running in your development environment.

    Read more…

    docker root sudo volumes

  • 2014-06-18

    Celery - Best Practices

    If you've worked with Django at some point you probably had the need for some background processing of long running tasks. Chances are you've used some sort of task queue, and Celery is currently the most popular project for this sort of thing in the Python (and Django) world (but there are others).

    While working on some projects that used Celery for a task queue I've gathered a number of best practices and decided to document them. Nevertheless, this is more a rant about what I think should be the proper way to do things, and about some underused features that the celery ecosystem offers.

    Read more…

    celery django python

  • 2014-04-06

    Setting up Systemd on Debian in 10 minutes

    Recently I've been reading more and more about Systemd. Now, most distros have already moved to Systemd but I'm using Debian and was stuck with init which was the default. Given the recent discussion on the Debian mailing lists about migrating to systemd as the new default, I was even more inclined to make the switch now and get used to it before it's forced upon us.

    Actually I was really looking forward to it, but as Linux goes I was expecting it to be a pain, so I was pleasantly surprised that it only took me 10 minutes and wasn't a hassle at all.

    I've decided to document the steps I've taken in case that someone finds it useful.

    Read more…

    debian init linux systemd