@@ -1599,111 +1599,6 @@ COPY --from=prebuild /the-future/hello.txt /the-future/hello.txt
1599
1599
require .Equal (t , "hello from the past\n hello from the future\n /the-past/hello.txt" , strings .TrimSpace (out ))
1600
1600
})
1601
1601
1602
- t .Run ("MultistageRunCopyMinimal" , func (t * testing.T ) {
1603
- t .Parallel ()
1604
-
1605
- srv := gittest .CreateGitServer (t , gittest.Options {
1606
- Files : map [string ]string {
1607
- "Dockerfile" : fmt .Sprintf (`
1608
- FROM %[1]s AS a
1609
- RUN date > /date.txt
1610
- FROM %[1]s
1611
- COPY --from=a /date.txt /date.txt
1612
- ` , testImageAlpine ),
1613
- },
1614
- })
1615
-
1616
- // Given: an empty registry
1617
- testReg := setupInMemoryRegistry (t , setupInMemoryRegistryOpts {})
1618
- testRepo := testReg + "/test"
1619
- ref , err := name .ParseReference (testRepo + ":latest" )
1620
- require .NoError (t , err )
1621
- _ , err = remote .Image (ref )
1622
- require .ErrorContains (t , err , "NAME_UNKNOWN" , "expected image to not be present before build + push" )
1623
-
1624
- // When: we run envbuilder with GET_CACHED_IMAGE
1625
- _ , err = runEnvbuilder (t , runOpts {env : []string {
1626
- envbuilderEnv ("GIT_URL" , srv .URL ),
1627
- envbuilderEnv ("CACHE_REPO" , testRepo ),
1628
- envbuilderEnv ("GET_CACHED_IMAGE" , "1" ),
1629
- envbuilderEnv ("DOCKERFILE_PATH" , "Dockerfile" ),
1630
- envbuilderEnv ("VERBOSE" , "1" ),
1631
- }})
1632
- require .ErrorContains (t , err , "error probing build cache: uncached RUN command" )
1633
- // Then: it should fail to build the image and nothing should be pushed
1634
- _ , err = remote .Image (ref )
1635
- require .ErrorContains (t , err , "NAME_UNKNOWN" , "expected image to not be present before build + push" )
1636
-
1637
- // When: we run envbuilder with PUSH_IMAGE set
1638
- _ , err = runEnvbuilder (t , runOpts {env : []string {
1639
- envbuilderEnv ("GIT_URL" , srv .URL ),
1640
- envbuilderEnv ("CACHE_REPO" , testRepo ),
1641
- envbuilderEnv ("PUSH_IMAGE" , "1" ),
1642
- envbuilderEnv ("DOCKERFILE_PATH" , "Dockerfile" ),
1643
- envbuilderEnv ("VERBOSE" , "1" ),
1644
- }})
1645
- require .NoError (t , err )
1646
-
1647
- // Then: the image should be pushed
1648
- _ , err = remote .Image (ref )
1649
- require .NoError (t , err , "expected image to be present after build + push" )
1650
-
1651
- // Then: re-running envbuilder with GET_CACHED_IMAGE should succeed
1652
- ctrID , err := runEnvbuilder (t , runOpts {env : []string {
1653
- envbuilderEnv ("GIT_URL" , srv .URL ),
1654
- envbuilderEnv ("CACHE_REPO" , testRepo ),
1655
- envbuilderEnv ("GET_CACHED_IMAGE" , "1" ),
1656
- envbuilderEnv ("DOCKERFILE_PATH" , "Dockerfile" ),
1657
- envbuilderEnv ("VERBOSE" , "1" ),
1658
- }})
1659
- require .NoError (t , err )
1660
-
1661
- // Then: the cached image ref should be emitted in the container logs
1662
- ctx , cancel := context .WithCancel (context .Background ())
1663
- t .Cleanup (cancel )
1664
- cli , err := client .NewClientWithOpts (client .FromEnv , client .WithAPIVersionNegotiation ())
1665
- require .NoError (t , err )
1666
- defer cli .Close ()
1667
- logs , err := cli .ContainerLogs (ctx , ctrID , container.LogsOptions {
1668
- ShowStdout : true ,
1669
- ShowStderr : true ,
1670
- })
1671
- require .NoError (t , err )
1672
- defer logs .Close ()
1673
- logBytes , err := io .ReadAll (logs )
1674
- require .NoError (t , err )
1675
- require .Regexp (t , `ENVBUILDER_CACHED_IMAGE=(\S+)` , string (logBytes ))
1676
-
1677
- // When: we pull the image we just built
1678
- rc , err := cli .ImagePull (ctx , ref .String (), image.PullOptions {})
1679
- require .NoError (t , err )
1680
- t .Cleanup (func () { _ = rc .Close () })
1681
- _ , err = io .ReadAll (rc )
1682
- require .NoError (t , err )
1683
-
1684
- // When: we run the image we just built
1685
- ctr , err := cli .ContainerCreate (ctx , & container.Config {
1686
- Image : ref .String (),
1687
- Entrypoint : []string {"sleep" , "infinity" },
1688
- Labels : map [string ]string {
1689
- testContainerLabel : "true" ,
1690
- },
1691
- }, nil , nil , nil , "" )
1692
- require .NoError (t , err )
1693
- t .Cleanup (func () {
1694
- _ = cli .ContainerRemove (ctx , ctr .ID , container.RemoveOptions {
1695
- RemoveVolumes : true ,
1696
- Force : true ,
1697
- })
1698
- })
1699
- err = cli .ContainerStart (ctx , ctr .ID , container.StartOptions {})
1700
- require .NoError (t , err )
1701
-
1702
- // Then: The files from the image are present.
1703
- out := execContainer (t , ctr .ID , "/bin/sh -c 'cat /date.txt'" )
1704
- require .NotEmpty (t , strings .TrimSpace (out ))
1705
- })
1706
-
1707
1602
t .Run ("MultistgeCacheMissAfterChange" , func (t * testing.T ) {
1708
1603
t .Parallel ()
1709
1604
dockerfilePrebuildContents := fmt .Sprintf (`
0 commit comments