From 4069e1b0e1dcc2243754feefa6927d7b2ea58e8b Mon Sep 17 00:00:00 2001 From: restitux Date: Fri, 24 Feb 2023 22:37:17 -0700 Subject: [PATCH] Update executor to run built user provided container --- pipeline_executor/pipeline_executor.go | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/pipeline_executor/pipeline_executor.go b/pipeline_executor/pipeline_executor.go index aa615fd..a7bd856 100644 --- a/pipeline_executor/pipeline_executor.go +++ b/pipeline_executor/pipeline_executor.go @@ -4,7 +4,6 @@ import ( "bytes" "context" "fmt" - "io" "io/ioutil" "os" "path/filepath" @@ -131,8 +130,10 @@ func ExecutePipeline(pe PipelineExecution, db database.Database, pipelineConf co dockerBuildContext, err := os.Open(tarFile) defer dockerBuildContext.Close() + imageName := fmt.Sprintf("%v-%v:latest", pe.Pipeline.Id.String(), pe.Run.Id.String()) + buildResponse, err := cli.ImageBuild(context.Background(), dockerBuildContext, types.ImageBuildOptions{ - Tags: []string{fmt.Sprintf("%v-%v:latest", pe.Pipeline.Id.String(), pe.Run.Id.String())}, + Tags: []string{imageName}, Dockerfile: ".cursorius/Dockerfile", }) if err != nil { @@ -147,28 +148,13 @@ func ExecutePipeline(pe PipelineExecution, db database.Database, pipelineConf co } log.Debugf("build log: %v", string(response)) - imageName := "git.ohea.xyz/cursorius/pipeline-api/cursorius-pipeline:v2" - - log.Infof("Pulling image %v", imageName) - pullOutput, err := cli.ImagePull(ctx, imageName, types.ImagePullOptions{}) + err = buildResponse.Body.Close() if err != nil { - log.Errorf("could not pull image %v: %w", imageName, err) + log.Errorf("Could not close build response body: %w", err) return } - buf, err := io.ReadAll(pullOutput) - if err != nil { - log.Errorf("could not read from io.ReadCloser:, %w", err) - return - } - log.Infof("%s", buf) - - err = pullOutput.Close() - if err != nil { - log.Errorf("could not close io.ReadCloser: %w", err) - return - } - log.Info("Image pulled sucessfully") + log.Info("Image built sucessfully sucessfully") hostConfig := container.HostConfig{}