Rerender on file change in Docker setup

I actually found a way which is more convenient for me. Docker compose has an experimental feature that syncs local files with the container’s files: Docker Compose Experiment: Sync Files and Automatically Rebuild Services with Watch Mode

My Dockerfile is simply:

FROM hugomods/hugo:latest


COPY . /src/

EXPOSE 1313

ENTRYPOINT [ "hugo", "server"] 

And my docker-compose.yml is:

version: '3'
services:
  hugo:
    build: .
    ports:
      - "1313:1313"
    x-develop:
      watch:
        - action: sync
          path: ./content
          target: /src/content

In my terminal, I run

docker compose up -d && docker compose alpha watch

…and everything works as if I was running Hugo locally!

1 Like