directus icon indicating copy to clipboard operation
directus copied to clipboard

Reloading extensions while running the docker container on windows does not work

Open philipkaiser opened this issue 3 years ago • 8 comments

Describe the Bug

When developing extensions, on mac and linux extensions are automatically reloaded if a file in the extensions directory changes. You will see a log INFO: Reloading extensions that indicates that the new extension bundle was loaded. However on a windows 11 machine (and on windows 10 for a colleague of mine too) the extensions seem not to reload when a file changes, although the log INFO: Watching extensions for changes... appears during startup and the EXTENSIONS_AUTO_RELOAD is set to true.

To Reproduce

This bug only occurs on a windows machine.

  • create a docker-compose.yml:
version: "3.2"
services:
  test-directus:
    container_name: test-directus
    image: directus/directus:10.1.1
    restart: always
    ports:
      - ${PORT}:${PORT}
    volumes:
      - ./extensions:/directus/extensions
      - ./data:/directus/database
    env_file:
      - ./.env
  • create a .env in the same directory:
PUBLIC_URL=http://localhost:8055
PORT=8055

ACCESS_TOKEN_TTL=1d

KEY=255d861b-5ea1-5996-9aa3-922530ec40b1
SECRET=6116487b-cda1-52c2-b5b5-c8022c45e263

EXTENSIONS_AUTO_RELOAD=true

[email protected]
ADMIN_PASSWORD=1234
  • create the extensions and data directories
  • build and start the container via docker-compose up -d
  • run docker logs -f test-directus in your terminal
  • create test-endpoint/index.js in extensions/endpoints, e.g. by creating one using the directus-extension-sdk
  • check the terminal with the docker logs
  • there does not appear the log INFO: Reloading extensions
  • when testing the endpoint, e.g. with postman, you get a 404 not found response

Directus Version

v10.1.1

Hosting Strategy

Self-Hosted (Docker Image)

philipkaiser avatar May 25 '23 08:05 philipkaiser

This is an issue with docker volumes on Windows. Not sure if we can solve this from our end https://forums.docker.com/t/file-system-watch-does-not-work-with-mounted-volumes/12038

br41nslug avatar May 25 '23 15:05 br41nslug

@br41nslug maybe not solve it but a fallback like a file system polling would be great.

There seems to be a temporary workaround (https://github.com/merofeev/docker-windows-volume-watcher) I haven't tried yet, but this is pretty much a dealbreaker for Windows developers to build directus extensions.

mattwltr avatar Sep 07 '23 14:09 mattwltr

@mattwltr another workaround is to use WSL2 for your extension development

br41nslug avatar Sep 07 '23 14:09 br41nslug

@br41nslug haven't tried that either but according to some replies on the link you posted earlier this year, WSL2 doesn't solve the problem.

mattwltr avatar Sep 07 '23 14:09 mattwltr

We should check whether this works and document if it does:

    # directus container
    environment:
      CHOKIDAR_USEPOLLING: true

paescuj avatar Jan 17 '24 16:01 paescuj

We should check whether this works and document if it does:

    # directus container
    environment:
      CHOKIDAR_USEPOLLING: true

Confirming, this indeed does fix the problem.

Additional note: This is a common problem when using Docker containers running Linux on a Windows host. Using polling as a workaround is the de-facto solution.

Tygara191 avatar Feb 27 '24 00:02 Tygara191

We should check whether this works and document if it does:

    # directus container
    environment:
      - CHOKIDAR_USEPOLLING: true

Confirming, this indeed does fix the problem.

Additional note: This is a common problem when using Docker containers running Linux on a Windows host. Using polling as a workaround is the de-facto solution.

I get this A block sequence may not be used as an implicit map key when I try to include that in my docker-compose

Blanco237 avatar Aug 01 '24 19:08 Blanco237

I get this A block sequence may not be used as an implicit map key when I try to include that in my docker-compose

It should be

    # directus container
    environment:
      CHOKIDAR_USEPOLLING: true

or

    # directus container
    environment:
      - CHOKIDAR_USEPOLLING=true

paescuj avatar Aug 02 '24 12:08 paescuj