Skip to content

Improve Docker image #12885

Open
Open
@jmooring

Description

@jmooring

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

As of v0.135.0 I can do things like1:

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 repository to test docker images:
https://github.com/jmooring/hugo-feature-test

Our Docker image doesn't need to pass that test, but we should consider what we want to support.

There's an open issue about how to document usage:
gohugoio/hugoDocs#2727

Footnotes

  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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions