monotux.tech

New Hugo builder image

Hugo, Docker

I recently discovered that the container image I use to build this1 blog hadn’t been updated in a year or so, breaking my other blog. Here I will document how I replaced this image with another one from hugomods2.

Spoiler alert: it wasn’t hard!

In short, the entire change is below:

# New container image
FROM hugomods/hugo:go-git-0.125.5 AS hugo

# Explicitly copy files and run hugo
COPY . /src
RUN hugo --minify

# Replace below if you don't want to use Caddy
FROM caddy:2
COPY --from=hugo /src/public /usr/share/caddy
COPY ./Caddyfile /etc/caddy/Caddyfile

That was it. I’m sure someone else might run into this so I might as well be a good citizen and publish the above. I also read through the Dockerfile(s) used to build this container, and they looked fine so I took a chance and started using it.

Speaking of netiquette, here’s the Caddyfile driving this blog on fly.io:

{
    auto_https off
}

http://solitary-thunder-2257.fly.dev {
    redir https://www.monotux.tech{uri} permanent
}

http://monotux.tech {
    redir https://www.monotux.tech{uri} permanent
}

http://www.monotux.tech {
    root * /usr/share/caddy
    file_server
}