Deploying Hugo in Docker
It has been approximately two years since I last configured my personal site and blog (and I have not been blogging). I have created multiple new CIVITATES services since then, so it made sense to merge the blogposts, actually document my progress and configuration of services, and show a list of Civitates services that are open to public.
Let’s start with this, a generic, Hugo site.
It’s easy to back up the volumes (and I have tons of volumes across various services. I will post a screenshot sometime), it’s vastly easy to configure with just an
.env file and/or a
docker-compose.yaml (yaml > yml), and I prefer not leaving traces of services everywhere on either of my four systems/servers when I am updating them or destroying them.
For this, it was easy. The compose file is simply
version: '3.3' services: server: command: server volumes: - '.:/src' ports: - 'YOUR_EXTERNAL_PORT:1313' image: klakegg/hugo:0.101.0
docker-compose up -d, and you run into an interesting error:
Error: Unable to locate config file or config directory. Perhaps you need to create a new site. Run
hugo help newfor details.
Well that’s easily solved. I installed hugo (ugh) and just ran
hugo new site xyz where the
docker-compose file is located.
Now, there is an issue with this. The entire purpose of docker is so that I don’t have to install hugo on my main system. To be entirely fair, you can just
docker exec -it nameofcontainer /bin/sh to get the shell into the container, and install hugo that way. That too, would work.
Either is fine.
Get a theme, install it via whatever method you prefer (I am not going to go into it now, as after this this should be just regular Hugo installation/customization/posts), and you’re golden.
Anyhoo, next few days will be spent listing the Civitates services, cleaning up the codebase and what not.