Fixes #17827
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
| ... | ... |
@@ -6408,3 +6408,30 @@ func (s *DockerSuite) TestBuildSymlinkBasename(c *check.C) {
|
| 6408 | 6408 |
c.Assert(out, checker.Matches, "bar") |
| 6409 | 6409 |
|
| 6410 | 6410 |
} |
| 6411 |
+ |
|
| 6412 |
+// #17827 |
|
| 6413 |
+func (s *DockerSuite) TestBuildCacheRootSource(c *check.C) {
|
|
| 6414 |
+ testRequires(c, DaemonIsLinux) |
|
| 6415 |
+ name := "testbuildrootsource" |
|
| 6416 |
+ ctx, err := fakeContext(` |
|
| 6417 |
+ FROM busybox |
|
| 6418 |
+ COPY / /data`, |
|
| 6419 |
+ map[string]string{
|
|
| 6420 |
+ "foo": "bar", |
|
| 6421 |
+ }) |
|
| 6422 |
+ c.Assert(err, checker.IsNil) |
|
| 6423 |
+ defer ctx.Close() |
|
| 6424 |
+ |
|
| 6425 |
+ // warm up cache |
|
| 6426 |
+ _, err = buildImageFromContext(name, ctx, true) |
|
| 6427 |
+ c.Assert(err, checker.IsNil) |
|
| 6428 |
+ |
|
| 6429 |
+ // change file, should invalidate cache |
|
| 6430 |
+ err = ioutil.WriteFile(filepath.Join(ctx.Dir, "foo"), []byte("baz"), 0644)
|
|
| 6431 |
+ c.Assert(err, checker.IsNil) |
|
| 6432 |
+ |
|
| 6433 |
+ _, out, err := buildImageFromContextWithOut(name, ctx, true) |
|
| 6434 |
+ c.Assert(err, checker.IsNil) |
|
| 6435 |
+ |
|
| 6436 |
+ c.Assert(out, checker.Not(checker.Contains), "Using cache") |
|
| 6437 |
+} |