This blog, the one you’re reading right now, is github pages blog, and you can view the repository. The back-end technology for github pages is Jekyll, which is simple to use static site generation software. Static sites are much more straightforward to maintain and deal with than dynamic sites, the performance alone is probably worth it:

Lighthouse performance rating for the blog front page

Lighthouse performance rating for a blog page

I’ve previously written about running Jekyll in WSL. The major issue with this approach is that you need to install a whole pile of software. Clearly this can be scripted, but you unless you’re organised (I’m not), then you forget to either create the script in the first place, or don’t run it and go and find the original blog post. There must be a better way…

devcontainers

Someone at Microsoft has been listening and VS Code now includes devcontainer functionality. In a nutshell you add some configuration files to a .devcontainer directory in your repository and (assuming you have Docker Desktop for Windows installed) VS Code will open your repository in a container.

Rather than start this from scratch I found Carlos Mendible’s article, and this gave me the first steps. First I created a dockerfile, and it is in here that you script the coonfiguration of your environment. You also need to create a devcontainer.json. There is one crucial difference with Carlos’ method, he used the appPort property, but using this requires you to publish the ports and your application (in this case Jekyll) to listen on all interfaces and not just localhost. I’ve used the ‘forwardPorts` property instead:

    "forwardPorts": [4000]

The reason for swapping to using forwardPorts was that I could not access the site when using appPort (I suspect this was the problem of Jekyll running on the wrong interface). The other addition I have made is to include a .vscode/tasks.json:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Start jekyll (drafts, future) for codemunki.es",
            "command": "jekyll",
            "args": [
                "serve",
                "-w",
                "-D",
                "--future"
            ],
            "type": "shell",
            "problemMatcher": []
        },
        {
            "label": "Start jekyll for codemunki.es",
            "command": "jekyll",
            "args": [
                "serve",
                "-w"
            ],
            "type": "shell",
            "problemMatcher": []
        }
    ]
}

This allows me to run Jekyll from within the devcontainer easily, and view new posts as I create them.