diff --git a/pkg/container/container_types.go b/pkg/container/container_types.go index cba2ebf7..a3954329 100644 --- a/pkg/container/container_types.go +++ b/pkg/container/container_types.go @@ -53,11 +53,11 @@ type Container interface { // NewDockerBuildExecutorInput the input for the NewDockerBuildExecutor function type NewDockerBuildExecutorInput struct { - ContextDir string - Dockerfile string - Container Container - ImageTag string - Platform string + ContextDir string + Dockerfile string + BuildContext io.Reader + ImageTag string + Platform string } // NewDockerPullExecutorInput the input for the NewDockerPullExecutor function diff --git a/pkg/container/docker_build.go b/pkg/container/docker_build.go index 72150234..fdc04d8d 100644 --- a/pkg/container/docker_build.go +++ b/pkg/container/docker_build.go @@ -48,8 +48,8 @@ func NewDockerBuildExecutor(input NewDockerBuildExecutorInput) common.Executor { Dockerfile: input.Dockerfile, } var buildContext io.ReadCloser - if input.Container != nil { - buildContext, err = input.Container.GetContainerArchive(ctx, input.ContextDir+"/.") + if input.BuildContext != nil { + buildContext = io.NopCloser(input.BuildContext) } else { buildContext, err = createBuildContext(ctx, input.ContextDir, input.Dockerfile) } diff --git a/pkg/runner/action.go b/pkg/runner/action.go index 4d6b8fc4..9bab9ba1 100644 --- a/pkg/runner/action.go +++ b/pkg/runner/action.go @@ -257,16 +257,20 @@ func execAsDocker(ctx context.Context, step actionStep, actionName string, based if !correctArchExists || rc.Config.ForceRebuild { logger.Debugf("image '%s' for architecture '%s' will be built from context '%s", image, rc.Config.ContainerArchitecture, contextDir) - var actionContainer container.Container + var buildContext io.ReadCloser if localAction { - actionContainer = rc.JobContainer + buildContext, err = rc.JobContainer.GetContainerArchive(ctx, contextDir+"/.") + if err != nil { + return err + } + defer buildContext.Close() } prepImage = container.NewDockerBuildExecutor(container.NewDockerBuildExecutorInput{ - ContextDir: contextDir, - Dockerfile: fileName, - ImageTag: image, - Container: actionContainer, - Platform: rc.Config.ContainerArchitecture, + ContextDir: contextDir, + Dockerfile: fileName, + ImageTag: image, + BuildContext: buildContext, + Platform: rc.Config.ContainerArchitecture, }) } else { logger.Debugf("image '%s' for architecture '%s' already exists", image, rc.Config.ContainerArchitecture)