microsoft / DockerTools

Tools For Docker, including Visual Studio Provisioning and Publishing
Other
175 stars 26 forks source link

Docker compose up specify services to not recreate. #307

Closed DatKyle closed 1 year ago

DatKyle commented 3 years ago

I have a compose file with 3 services that I don't want to be recreated when starting the Docker-compose project:

  1. Angular build
  2. SQL Server
  3. Azurite

When I added <DockerComposeUpArguments>--no-recreate</DockerComposeUpArguments> to the .dcproj it failed to build as --force-recreate is also applied to the Docker-compose up command, causing a conflict between the 2 arguments

The main reason for not wanting to recreate services is because the angular takes 4 minutes to complete an initial build and then 10 seconds to recompile new changes. When the container is recreated it has to do an initial build, and since all services are recreated when you start the Docker-compose project it takes ages to develop and test.

Question

Is there a way to specify services to not be recreated or a way to remove the --force-recreate argument?

ravipal commented 3 years ago

@DatKyle, The --force-recreate is used only when a change is detected in docker artifacts or the previous cache is missing. As long as the compose file and it's services aren't changed, then the --force-recreate will not be used. At this time, we don't have a way to override this behavior.

If your scenario is to exclude one or more services (that don't change often) from starting or debugging, consider Launch a subset of Compose services

DatKyle commented 3 years ago

Hi @ravipal, Thank you for the response and the extra info on how the --force-recreate is applied to the command. Although using the --force-recreate for any changes to the file or services is the exact thing I'm trying to avoid because it recreates all services.

The exact issue is when we make any changes, all services get recreated. So when we make a change to our API, the Angular gets recreated, which takes a long time to build. So it would be beneficial for us if there was a way to remove the --force-recreate or if the tool selectively removed containers for recreation instead of just assuming all containers need recreating.

Where would I go to make a suggestion to change this behaviour?

ravipal commented 3 years ago

@DatKyle, This is the right place for such suggestions in addition to VS developer community. We will look into removing the --force-recreate flag.