Reduce Rebuilds During Dev
preferSyncOverRebuild
The preferSyncOverRebuild
option expects a boolean which decides if DevSpace should skip rebuilding an image during devspace dev
in case the file sync is configured for a container which references this image using the imageName
option.
Using preferSyncOverRebuild: true
does not affect devspace deploy
because file sync is not being started even if it may be configured in devspace.yaml. So, this option takes effect during image builds via devspace dev
.
Even if this option is enabled, DevSpace may still skip building an image if neither the Dockerfile nor any files within the context have changed since the latest rebuild.
DevSpace will still rebuild when the -b / --force-rebuild
flag is explicitly provided.
Default Value For preferSyncOverRebuild
preferSyncOverRebuild: false
Example: Prefer Sync Over Rebuild
images:
backend:
image: john/appbackend
preferSyncOverRebuild: true
frontend:
image: dscr.io/${DEVSPACE_USERNAME}/appfrontend
preferSyncOverRebuild: true
cache:
image: dscr.io/${DEVSPACE_USERNAME}/cache
dev:
sync:
- imageSelector: backend
onUpload:
restartContainer: true
Explanation:
When running devspace dev
using the above configuration, DevSpace would:
- not build the image
backend
becausedev.sync[0].imageName
is referencing this image andpreferSyncOverRebuild: true
is configured - build the image
frontend
because althoughpreferSyncOverRebuild: true
is configured, no sync configuration is referencing this image - build the image
cache
becausepreferSyncOverRebuild
is not set totrue