New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Watch not triggering build when file changed inside Docker #4109
Comments
@aripalo recently added a Gatsby Dockerfile at https://github.com/aripalo/gatsby-docker/. What happens if you try your site with that Docker image, do you see the same issue? |
Thanks for you tip. But unfortunately I had encountered the same behaviour with the Dockerfile of @aripalo. The file in the container changed but doesn't trigger the build. |
Hmm I can't replicate the issue you've described, using your container or the gatsby-docker container. Changing files in the src folder will trigger a rebuild. Doing either of:
will show You can see the two file changes at the bottom, each one trggering a new pair of 'Compiling... Compiled' messages. I'm running macOS and Docker Version 17.12.0-ce-mac49 (21995). Is there something else in your setup that could be causing this? |
Yesterday I tried the following things:
But unfortunately no luck. I don't know where a difference between yours and my setup could be.. |
Hmm I'm not sure what else to suggest. Here's the output from my
|
I think I installed docker "the old fashioned way", by downloading Docker for Mac from https://docs.docker.com/docker-for-mac/install/ |
Soo... I've came across with some other troubles when using Docker for other applications and it seems like that the problem did had something to do with Thank you very much for your effort and keep up the good work :) |
Great! I'm glad it worked out :) |
@benedictdudel I am seeing the exactly same issue on Windows. Would you mind sharing the detailed steps? I have the latest nightly built Docker desktop with wsl 2 enabled. |
When webpack dev server tries to look for changes and you are using wsl or docker the fsevents are not going to be fired (taht's why it doesn't trigger the refresh) so you need to override the watch webpack dev server options a little bit. /**
* Implement Gatsby's Node APIs in this file.
*
* See: https://www.gatsbyjs.org/docs/node-apis/
*/
// You can delete this file if you're not using it
const path = require('path');
exports.onCreateWebpackConfig = ({ actions, getConfig }) => {
const config = getConfig();
config.devServer = {
watchOptions: {
aggregateTimeout: 500, // delay before reloading
poll: 1000 // enable polling since fsevents are not supported in docker
}
};
actions.replaceWebpackConfig(config);
}; |
As of gatsby 4.22 in docker on linux, I get this working with: export function onCreateWebpackConfig({ actions }){
const watchConf = {
watchOptions: {
aggregateTimeout: 500, // delay before reloading
poll: 1000, // enable polling since fsevents are not supported in docker
ignored: ['**/node_modules', '**/public'] // keep CPU usage minimal
}
}
actions.setWebpackConfig(watchConf)
}
Thanks to you all for this long path of help ! |
Description
I created a minimal Dockerfile for developing a Gatsby page. Unfortunately changes in files do not trigger a rebuild inside a Docker container. See below for the minimal Dockerfile.
While debugging the problem I have noticed that the container and host both got a different timezone. So files in the container have a different timestamp:
Container:
-rw-r--r-- 1 node staff 245 Feb 17 14:17 page-2.js
Host:
-rw-r--r-- 1 user 370035326 245 17 Feb 15:17 page-2.js
Maybe the different timezones causing the problem but I never encountered any problem with other "watchers".
Environment
Gatsby version: latest
Node.js version: LTS
Operating System: macOS (host) / Debian (container)
Actual result
A changed file doesn't trigger the rebuild.
Expected behavior
A changed file should trigger the rebuild.
Steps to reproduce
1. Create a
Dockerfile
with the following content2. Build the container
3. Create a container
4. Change any file in
src
directory and verify file changed in the containerThe text was updated successfully, but these errors were encountered: