Update executor to run built user provided container
This commit is contained in:
@@ -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{}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user