Skip to content

Commit

Permalink
move tar writer close
Browse files Browse the repository at this point in the history
  • Loading branch information
zulkhair committed Aug 8, 2024
1 parent 2306458 commit e4af4bb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion common/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,12 @@ func pullImageIfNotExists(ctx context.Context, cli *client.Client, imageName str

func buildImage(ctx context.Context, cli *client.Client, dockerfile Dockerfile, imageName string) error {
fmt.Println("Building image ", imageName)

// Enable BuildKit via environment variable
os.Setenv("DOCKER_BUILDKIT", "1")

buf := new(bytes.Buffer)
tw := tar.NewWriter(buf)
defer tw.Close()

// Add the Dockerfile to the tar archive
header := &tar.Header{
Expand All @@ -312,6 +315,10 @@ func buildImage(ctx context.Context, cli *client.Client, dockerfile Dockerfile,
return err
}

if err := tw.Close(); err != nil {
return eris.Wrap(err, "Failed to close tar writer")
}

// Read the tar archive
tarReader := bytes.NewReader(buf.Bytes())

Expand Down

0 comments on commit e4af4bb

Please sign in to comment.