greenpeace / planet4

Built on top of Wordpress tech, Greenpeace Planet 4 powers digital platforms to engage with millions and win campaigns around the world.
https://planet4.greenpeace.org
Creative Commons Attribution Share Alike 4.0 International
66 stars 27 forks source link

Running "make watch" causes bad performance of local environment #105

Closed Inwerpsel closed 10 months ago

Inwerpsel commented 3 years ago

Brief summary of task:

Currently we have 2 options to watch for file changes in the SCSS and JS files in https://github.com/greenpeace/planet4-master-theme and https://github.com/greenpeace/planet4-plugin-gutenberg-blocks/ .

1) run npm start in both directories from your host OS. This has the best performance, but that way we can't be sure which version of npm is being used. That can lead to a number of surprises. For example a bug could be occurring only in the version we use in CI and not in the version the developer has installed. Even though it's rare, this kind of bugs is usually hard to detect and time consuming when they do occur.

2) run make watch. Which will run npm start inside of the PHP container. This way there is a predictable npm version which is performing the tasks. The downside is that it slows down the PHP container. This is mainly an issue for Mac users, where Docker file system performance is still really bad.

Ideally we have a solution which has both advantages and neither disadvantage. This could be achieved by adding a container that has only the expected npm version on it, and only runs npm start inside both repos. Or maybe the same container can be spun up twice, one for planet4-master-theme and one for planet4-plugin-gutenberg-blocks. Then we could exclude certain directories from the PHP container's volumes, including among which the node_modules folders. This could solve or alleviate performance issues associated with file system slowness.

Relevant documentation:

The docker-compose file: https://github.com/greenpeace/planet4-docker-compose/blob/70dd54b1a61ea14b2772255b6bad0e2a020bd447/docker-compose.yml#L45-L45

Other resources:

File system performance of Docker on Mac: https://github.com/docker/for-mac/issues/1592

Estimated length of task:

Timeline for task:

Dependencies on other work:

Example of similar work:

Help: