Reloading extensions while running the docker container on windows does not work
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
.envin 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
extensionsanddatadirectories - build and start the container via
docker-compose up -d - run
docker logs -f test-directusin your terminal - create
test-endpoint/index.jsinextensions/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)
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 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 another workaround is to use WSL2 for your extension development
@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.
We should check whether this works and document if it does:
# directus container
environment:
CHOKIDAR_USEPOLLING: true
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.
We should check whether this works and document if it does:
# directus container environment: - CHOKIDAR_USEPOLLING: trueConfirming, 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
I get this
A block sequence may not be used as an implicit map keywhen 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