Watch different command/entrypoint
Description
When running with docker compose watch, i want my service to start their dev servers (those that support hotreloading & watch files)
When running with docker compose up, i want services to use their prod server (that will not start a file watcher & so on)
I was hoping to find something like services.app.develop.entrypoint or services.app.develop.command
Potential example:
services:
web:
build: .
command: npm start
develop:
command: npm dev
watch:
- action: sync
path: ./web
target: /src/web
ignore:
- node_modules/
- action: rebuild
path: package.json
watch is integrated in docker compose up (by adding --watch flag) and can even be activated dynamically, which would prevent such feature to be supported.
For your use-case, a common practice is to use a compose-dev.yaml override file to define development-focussed overrides, typically changing entrypoint/command to enable dynamic reloading, or additional port exposed to plug a debugger
Activating dynamically the watch (when there's a service.app.develop.command) could just trigger a restart action, i don't see how it would prevent the feature from being supported.
I currently use a docker-compose.dev.yaml for this purpose (and learned about the --watch recently) & would love if docker compose could allow us to move to a single one (so allowing dev specific env/ports...) If this is not a goal, I could understand not wanting to support a dev specific entrypoint too. I just felt like a toggleable watch was a step in this direction & thought that the missing entrypoint override was an oversight.
I had in mind we introduce development-only additional attributes in the develop section that would be independent from watch feature, i.e if you run docker compose up in development mode (TBD) this would merge the main service definition with some overrides set in develop, typically changing command, adding ports or volumes, etc.
this would be awesome, is there a tracking issue somewhere or is this only an idea for now?
nope, that's just an idea I have in mind for long time but didn't created an issue for it. Let's use this one :P
I had in mind we introduce development-only additional attributes in the
developsection that would be independent from watch feature, i.e if you rundocker compose upin development mode (TBD) this would merge the main service definition with some overrides set indevelop, typically changingcommand, addingportsorvolumes, etc.
That sounds super interesting, how do you think development mode should be activated?
@robinhickmann TBD. Could be a flag --develop and/or an environment variable COMPOSE_DEVELOP, or ... any suggestion is welcome