Configure path to resourceDir from command line or environment variable

Given that the cache directory is configurable via hugo --cacheDir and environment variable CACHE_DIR, I was wondering, why the same is not the case for the value of resourceDir.

I am using a parametrized docker-compose.yml file to run the same Hugo project simulating different environments from development to production. For development, I use hugo server, for production I use hugo --watch with a local Caddy server. This allows me to have consistent builds and even run Chrome Lighthouse locally with realistic scores.

How to separate the resourceDir instances?

I have not yet found out, how to configure, where Hugo puts the resources folder through the docker-compose.yml file.

Workaround 1: configure resourceDir in config/hugo.yaml to be located within cacheDir

A workaround is to configure the resourceDir via config/hugo.yaml. However, I would like to avoid adapting the config to my local setup. When building with GitHub Actions, I would prefer Hugo to behave as close to the defaults as possible, which would not be the case if I changed the production configuration to put resources into the cache dir.

Workaround 2: mount a local directory at /srv/resources

I currently map a local directory to /srv/resources, which allows me to separate the resources between environments. However, it also comes with the side-effect of creating a resources directory owned by root at the top-level of the Hugo project. This side-effect is a consequence of Docker mounting my custom resources directory into /srv and that cannot avoided (see for example Nested bind mounts create empty directory on the host · Issue #26051 · moby/moby · GitHub)

For illustration, here is the top part of my docker-compose.yml:

version: "3.8"

name: hugo_server_controller

    container_name: ${SITE_ID}_${DEVEL_SERVE_ENV}_hugo_server
    image: ${IMAGE_HUGO_FULL}   # Hugo Modules and Node.js

      - ${GLOBAL_ENV_FILE:-/dev/null}   # The values for all environment variables for container are generated using a Python script

      - ${DEVEL_SERVE_HUGO_ROOT}:/src
      - ${DEVEL_SERVE_HUGO_MODULES}:/modules
      - ${DEVEL_SERVE_CONTENT}:/content
      - ${DEVEL_SERVE_HUGO_CONF}:/config
      - ${DEVEL_SERVE_CACHE}:/cache
      - ${DEVEL_SERVE_RESOURCES}:/src/resources
      - ${DEVEL_SERVE_DESTINATION}:/destination
      - hugo
      - server
      - --contentDir=/content
      - --configDir=/config
      - --cacheDir=/cache
      - --destination=/destination
      - --environment=${DEVEL_SERVE_HUGO_ENV}