CGO dependency and Docker

The addition of the dependency on CGO for the extended capabilities in Hugo is causing some grief for people trying to create minimal Docker images.

If I build hugo in a golang:stretch (ie Debian) based image and run the binary in a Debian-based image, it all works. The base Debian images have the right libraries. On the downside, the image size for running the binary is around 150MB.

I, like many other Docker fans, would like to use an image based on Alpine. With this, I can build an image with the hugo binary at around 55MB, but the binary won’t run because the libraries it depends on are, of course, not there in a minimal image.

A lot of Docker fans are also Hugo fans because, until recently, Hugo was entirely statically compiled and needed no dependencies. This is a thing of beauty in Docker-land, but the beauty has faded.

Is CGO now going to a permanent dependency for the extended functionality? Are there plans to eliminate the CGO dependency (if that’s even possible)?

For now, I can still create images using Debian as a base, but my image sizes are tripled. It’s a workaround, but not a popular one.

CGO isn’t a dependency, it is a way for Go to interact with C/C++ libraries.

Libsass is written in C++ so you need a compatible version of libc++. I assume there are ways to get a “minimal setup” of that, too. But LIbsass cannot be run without it.