Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions pkg/client/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,13 @@ func (c *Client) Build(ctx context.Context, opts BuildOptions) error {
pathsConfig.hostRunImagePath = hostRunImagePath
}

runImage, warnings, err := c.validateRunImage(ctx, runImageName, fetchOptions, bldr.StackID)
runImageFetchOptions := fetchOptions
// Run image extensions create a local ephemeral run image from this base image.
if !opts.Layout() && (len(opts.Extensions) > 0 || len(bldr.OrderExtensions()) > 0) {
runImageFetchOptions.Daemon = true
}

runImage, warnings, err := c.validateRunImage(ctx, runImageName, runImageFetchOptions, bldr.StackID)
if err != nil {
return errors.Wrapf(err, "invalid run-image '%s'", runImageName)
}
Expand Down Expand Up @@ -686,7 +692,10 @@ func (c *Client) Build(ctx context.Context, opts BuildOptions) error {

lifecycleOpts.FetchRunImageWithLifecycleLayer = func(runImageName string) (string, error) {
ephemeralRunImageName := fmt.Sprintf("pack.local/run-image/%x:latest", randString(10))
runImage, err := c.imageFetcher.Fetch(ctx, runImageName, fetchOptions)
runImageFetchOptions := fetchOptions
// local.FromBaseImage requires the base image to be available in the daemon.
runImageFetchOptions.Daemon = true
runImage, err := c.imageFetcher.Fetch(ctx, runImageName, runImageFetchOptions)
if err != nil {
return "", err
}
Expand Down
14 changes: 14 additions & 0 deletions pkg/client/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1910,6 +1910,20 @@ api = "0.2"
`)
})
})

it("fetches the run image into the daemon when publishing", func() {
fakeImageFetcher.RemoteImages[fakeDefaultRunImage.Name()] = fakeDefaultRunImage

h.AssertNil(t, subject.Build(context.TODO(), BuildOptions{
Image: "some/app",
Builder: defaultBuilderName,
Publish: true,
Extensions: []string{"extension.1.id"},
}))

args := fakeImageFetcher.FetchCalls[defaultRunImageName]
h.AssertEq(t, args.Daemon, true)
})
})

//TODO: "all buildpacks are added to ephemeral builder" test after extractPackaged() is completed.
Expand Down
Loading