gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
75.94k stars 7.54k forks source link

Improve Docker image #12885

Open jmooring opened 1 month ago

jmooring commented 1 month ago

The purpose of this issue is to solicit community feedback and hopefully reach some consensus.

As of v0.135.0 I can do things like[^1]:

docker run -v .:/site -u $(id -u):$(id -g) ghcr.io/gohugoio/hugo:v0.135.0 config
docker run -v .:/site -u $(id -u):$(id -g) ghcr.io/gohugoio/hugo:v0.135.0 env
docker run -v .:/site -u $(id -u):$(id -g) ghcr.io/gohugoio/hugo:v0.135.0 list all
docker run -v .:/site -u $(id -u):$(id -g) ghcr.io/gohugoio/hugo:v0.135.0 new foo.md
docker run -v .:/site -u $(id -u):$(id -g) ghcr.io/gohugoio/hugo:v0.135.0 server

But I can't build the site like this:

docker run -v .:/site -u $(id -u):$(id -g) ghcr.io/gohugoio/hugo:v0.135.0 

Instead, I have to pass an empty entry point:

docker run --rm -v .:/site -u $(id -u):$(id -g) --entrypoint "" ghcr.io/gohugoio/hugo:v0.135.0 hugo

Or pass in a CLI flag to override the default --help flag defined in the Dockerfile. For example:

docker run --rm -v .:/site -u $(id -u):$(id -g) ghcr.io/gohugoio/hugo:v0.135.0 --minify

Additionally, the current version:

  1. Is not the extended version
  2. Does not support Hugo modules
  3. Does not support AsciiDoc, Pandoc, or reStructuredText (which is probably fine)
  4. Does not support PostCSS
  5. Does not support GitInfo
  6. Does not write to host cache directory (cacheDir / HUGO_CACHEDIR / os.CacheDir)
  7. I'm not sure if css.TailwindCSS works

Now that we can build an image, it would be good to define what we actually want it to do.

Some time ago I created a repo to test docker images: https://github.com/jmooring/hugo-docker-test

Our Docker image doesn't need to pass that test, but we should consider what we want to support: https://github.com/jmooring/hugo-docker-test?tab=readme-ov-file#site-characteristics

There's an open issue about how to document usage: https://github.com/gohugoio/hugoDocs/issues/2727

[^1]: The -u $(id -u):$(id -g) flag is required to set correct permissions on published files. Without this, owner and group were set to root during my Linux testing.

bep commented 1 month ago

So, the image will need to be able to build a Hugo site. If that's not the case, please create a bug, but I'm not taking improvement requests for this particular feature. It was supposed to be a simple thing and we have already spent hundreds of hours on it.

@jmooring I'm closing this, create a new bug track the actual bug.

If the image as it is is not useful, lets just remove it. We don't have the budget to maintain all the bells and whistles.

bep commented 1 month ago

I'm reopening this, the timing of this got me a little grumpy. We have spent a stupid amount of time just getting the build setup working, and I kind of assumed that the people who started that process found the Docker image we've had living in the project for years both working and useful.

That said, I'm already maintaining 2 complex Docker files for the Hugo build, I'm not adding another to that plate, so let us focus on the "getting it in a working state",.