Version: 5.0

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.

Development Only

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.

Regular Skip Check

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.

Trigger Rebuild Manually

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: gcr.io/${DEVSPACE_USERNAME}/appfrontend
preferSyncOverRebuild: true
cache:
image: gcr.io/${DEVSPACE_USERNAME}/cache
dev:
sync:
- imageName: backend
onUpload:
restartContainer: true

Explanation:
When running devspace dev using the above configuration, DevSpace would:

  • not build the image backend because dev.sync[0].imageName is referencing this image and preferSyncOverRebuild: true is configured
  • build the image frontend because although preferSyncOverRebuild: true is configured, no sync configuration is referencing this image
  • build the image cache because preferSyncOverRebuild is not set to true