You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: eng/docker-tools/DEV-GUIDE.md
+85-1Lines changed: 85 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -171,7 +171,7 @@ The `generateBuildMatrix` command is key to understanding how builds are paralle
171
171
1.**Reads the manifest.json** - Understands which images exist
172
172
2.**Builds a dependency graph** - Knows that `runtime-deps` must build before `runtime`
173
173
3.**Groups by platform** - Creates jobs for each OS/Architecture combo
174
-
4.**Optimizes with caching** - Can detect and exclude unchanged images
174
+
4.**Optimizes with caching** - Can detect and exclude unchanged images (see [Image Caching](#image-caching) below)
175
175
176
176
### Controlling Which Build Stages Run
177
177
@@ -338,6 +338,34 @@ The `autobuilder` label is how the infrastructure tracks that the failure cycle
338
338
339
339
---
340
340
341
+
### Image Caching
342
+
343
+
The infrastructure includes caching to avoid rebuilding images that haven't changed. Caching operates at two levels:
344
+
345
+
**1. Matrix Trimming (job-level caching)**
346
+
347
+
When `trimCachedImagesForMatrix` is enabled, the `generateBuildMatrix` command excludes platforms from the build matrix if they would result in cache hits. This means no build job is even created for those platforms—they're completely skipped.
348
+
349
+
**2. Build-time Caching**
350
+
351
+
Even if a platform isn't trimmed from the matrix, the `build` command checks each image against the cache before building. If the image is cached, it outputs `CACHE HIT`, pulls the previously-built image from the registry, and skips the actual Docker build.
352
+
353
+
#### Cache Conditions
354
+
355
+
An image is considered cached when **both** of the following conditions are true:
356
+
357
+
1. **Base image digest is unchanged** — The digest of the base image (FROM image) matches the digest recorded in the image info file from the last successful publish. If the upstream base image has been updated, this condition fails and the image will be rebuilt.
358
+
359
+
2. **Dockerfile commit is unchanged** — The git commit URL for the Dockerfile matches the commit URL recorded in the image info file. If you've modified the Dockerfile, this condition fails and the image will be rebuilt.
360
+
361
+
Caching compares against the published image info stored in the [versions repo](https://github.com/dotnet/versions). This means caching compares against what's been officially published, not what's in your current branch.
362
+
363
+
#### Disabling Caching
364
+
365
+
To force a rebuild regardless of cache state, set the `noCache` parameter to `true` when queuing the build. This disables both matrix trimming and build-time caching.
366
+
367
+
---
368
+
341
369
## Common Customization Patterns
342
370
343
371
### Pattern: Adding Build Arguments
@@ -389,3 +417,59 @@ When you queue a new run, you can override these as runtime parameters:
389
417
2. Set `sourceBuildPipelineRunId` to the run ID containing the artifacts you need (find the build ID in the URL when viewing a pipeline run, e.g., `buildId=123456`)
390
418
391
419
This avoids the multi-hour rebuild cycle when you just need to retry a failed operation.
420
+
421
+
---
422
+
423
+
## Troubleshooting
424
+
425
+
### Why isn't my Dockerfile being built?
426
+
427
+
When you trigger a pipeline run, you might find that your Dockerfile isn't being built.
428
+
429
+
#### Symptom 1: The Dockerfile isn't included in any build job
430
+
431
+
If your Dockerfile doesn't appear in any build job, first verify the Dockerfile is included in the manifest file.
432
+
433
+
**How to verify:** Check `manifest.json` to ensure your Dockerfile path is defined under the appropriate repo and image. You can also run `generateBuildMatrix` locally to see which Dockerfiles are included:
**How to fix:** Add the Dockerfile to `manifest.json` under the correct repo, image, and platform configuration.
440
+
441
+
#### Symptom 2: The pipeline job isn't running at all
442
+
443
+
If the Dockerfile is in the manifest but you don't see a build job for it, the build matrix was likely trimmed due to [matrix trimming](#image-caching).
444
+
445
+
**How to verify:** Look at the "Generate platformDependencyGraph Matrix" step output in the `GenerateBuildMatrix` job. This is an example of what the output in that step looks like:
If your Dockerfile path doesn't appear in any of the matrix legs, it was trimmed.
458
+
459
+
**How to fix:** Set the `noCache` parameter to `true` when queuing the build.
460
+
461
+
#### Symptom 3: The build output shows `CACHE HIT`
462
+
463
+
If your build job runs but you see `CACHE HIT` in the output of the `Build Images` step and the Dockerfile isn't actually built, the [build-time caching](#image-caching) determined that the image doesn't need to be rebuilt. This is an example of what the output in that step looks like:
0 commit comments