Don't build images on deploy command if the calculation of images to build is an empty list #4739
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed changes
On deploy command, we are calculating which images have to be built. It might happen that there are not images to build e.g. no build section defined, or deploying just a subset of services from a compose with using public images. In that case, internal logic within the build function was considering that all the images had to be built. In most of the cases that wouldn't generate issues, but in other cases it would generate unnecessary builds.
For example, having a compose file like this:
and the following okteto manifest:
The Okteto manifest is considering to deploy 2 services that directly use a public image and there is no need to build.
If you deploy that manifest, you will see how the
foo
image is being built even if it is not necessary.How to validate
Using the scenario described above, execute
okteto deploy
and see thatfoo
image is not being build. Add that service withindeploy.compose.services
, execute it, and see how the image is now build. (it is expected that the build offoo
fails because the folderfoo
doesn't existWithout these changes, the first deploy would have triggered the deploy, and it shouldn't