-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dockercompose: fix spurious full rebuild instead of Live Update (#5242)
Occasionally, when using Live Update with a Docker Compose project, a file change would trigger a full rebuild instead of Live Update despite matching a sync path. The root cause here is that the Docker Compose target watched files in addition to the image target, so there was a race: if the Docker Compose target saw the file but the image target hadn't yet, the Docker Compose builder would take over and do a full rebuild. This has probably been exacerbated by the API transition as there's now greater potential for timing-related issues like this to manifest. The reason the Docker Compose target watches for files is because in some cases, there IS no image target for a Docker Compose service. If there's no `docker_build` or `custom_build` configured, and the Docker Compose service has a `build:` section in its YAML, the Docker Compose build and deployer watched for file changes and then triggered a build via passing the `--build` flag to the `docker-compose up` call. To address this, the Docker Compose target now behaves more like a Kubernetes target. It does not watch for any files. Instead, image targets are created for both services that will be managed by Tilt (via `docker_build` or `custom_build`) as well as those that will be built by Docker Compose. (NOTE: If a Docker Compose service has no `build:` section and there's no corresponding `docker_build` or `custom_build` call for it, there will be no target, as no image builds will occur. This is commonly seen for infra deps that are pulled from a registry.) The image targets for Docker Compose managed builds have a new `BuildDetails` type of `DockerComposeBuild` to go along with the pre-existing `DockerBuild` and `CustomBuild` types. This ensures that all file changes are tie to the image, so it will pass through the `LiveUpdateBuildAndDeployer` first, and fallback to the `DockerComposeBuildAndDeployer` if not Live Update-eligible. (This is always the case for `DockerComposeBuild` targets currently!) The `DockerComposeBuildAndDeployer` looks at the image targets and either builds the set of Tilt-managed images for the service OR delegates to `docker-compose up` by including the `--build` flag. The `DockerComposeBuild` targets are created during Docker Compose assembly during Tiltfile loading if no Tilt-managed builder exists. This is kinda icky - it'd probably be nicer to create these as stubs when `docker_compose()` is called and allow `docker_build` and `custom_build` to override them, but that's a bigger yak shave than practical for this fix.
- Loading branch information
Showing
16 changed files
with
358 additions
and
386 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.