-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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 code and automatically rebuild when something changes #184
Comments
👍 |
1 similar comment
👍 |
+1. If this is to be part of fig up, how about an opt in flag? web:
watch:
- *.py
- *.css
- *.coffee |
👍 Where this gets documented, it's probably worth noting the following pattern that helps avoiding unnecessary package manager (pip/npm/bower/et al) action:
|
💯 |
+1 |
2 similar comments
👍 |
👍 |
It's been a few months, and I couldn't tell from the merge referenced above, was a "watch" ability integrated? |
No, |
It's still on the table though - see ROADMAP.md |
An idea from @fxdgear: instead of rebuilding, it could also be useful to just restart the container when the code changes. E.g. when you've mounted your code with a volume. |
Now that we have a
That said, if we go down the #693 path, we'll have to revisit this. |
👍 For this to be really awesome, there's got to be a way for docker build to accept or pass through some type of credentials without storing it in the image. I'm thinking private github modules but it really applies to any environment. The following is a NodeJS-based example using my current version of "fig up --watch" which is just a nodemon-based script: I run Now, I still want to do things like |
what about the right tool for the right job ? wouldn't guard :shell do
watch(/Dockerfile$/) { `fig build` }
watch(/fig.yml$/) { `fig up -d` }
end Anyway, it would be a nice addition. |
This sounds out of scope for fig or |
@ches I didn't realize
In
|
@amjibaly looks like you need to install ssh in your container @docteurklein I tend to agree, there are existing tools which would handle this pretty easily (the python watchdog package includes a cli called |
@dnephin I installed ssh, now I'm getting this error:
Running |
@amjibaly you're totally off-topic, no? |
@docteurklein yeah my bad. FYI @ches it turns out that |
wouldn't it be too slow to work with everyday programming process? rebuild take time, restart too. |
Not entirely sure if this should be something Docker Compose should do! I for one have several other build steps in between of noticing a file change and ultimately restarting the application; such as compiling, transpiring, concatenation etc. Restarting the application when a file changes is something that should be handled by developer tools inside of the container. I'd rather see better support for multiple Docker Compose environment configurations in order to better support a developer configuration which are different from a prod configuration to accommodate for restart on file-change. |
I've actually done an implementation of a feature like this at one point (in figgo) and I'm -1 on |
+1 |
I'd say it's not stale |
This issue has been automatically marked as not stale anymore due to the recent activity. |
compose now offers option to run builds using the docker CLI builder, which can be configured to use BuildKit. As the later doesn't require to send the whole docker context to daemon before a build start, and offers advanced caching capabilities, it seems a good candidate so service images can be rebuilt on a regular basis. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
spam for stale bot |
This issue has been automatically marked as not stale anymore due to the recent activity. |
i followed this thread from 2014 now to 2020 to find a clue on how to auto build microservices (Go) binary in dev when a file is change. am getting tired of running two many terminal so am looking into docker to see how it can help my life |
6 years into the request and I still cannot easily rebuild my docker without creating freaking volumes. |
2021 lol |
I found a way to do this, that I like. I'm using I put this in my Dockerfile-
This is
The With this setup-- I mount the code directory into I like this approach because I don't have to modify code, or install framework specific packages/CLI tools, to be able to live reload.
|
A watch and rebuild would be a really handy feature. As per the previous comment, a common work around is mounting one's app over the immutable version you have baked into your image. I see this often and it defeats the intent of containerisation + introduces false confidence as the running image is not representative of a particular build. |
Started playing with a wrapper script to add Immediate weaknesses:
|
I'm surprised this is still not a feature. ndeloof is working on this for Docker v2, but this should be in v3 itself as well. This is the entrypoint.sh file for a backend Django/Python application -
The container itself is alpine linux so I could use a file watch like inotify-tools. The issue now is that inotify-tools is blocking! So how do I simultaneously run Daphne while watching for file changes? Maybe I could run Daphne as a background process using a trailing &, but again, does that mean that Daphne will pick up file changes if inotify-tools kills the container and then the script restarts? This is a major major issue. Will somebody fix this? |
I expected inotify was working as expected under Docker Desktop, will need to change. A potential implementation of |
No updates on this after 8 years?! |
Sadly, no. |
@ndeloof any news on your PR? |
+1! |
The experimental |
Here is more context for those wondering:
TL;DR: |
Compose could watch your code and automatically kick off builds when something changes. This would mean:
It could either be an option to
up
(docker-compose up --watch
), an option in the config file specifying directories to watch/ignore, or perhaps a separate command (docker-compose watch
).Thanks to @samalba for the suggestion!
The text was updated successfully, but these errors were encountered: