<commit_before>package main

import (
	"archive/tar"
	"bytes"
	"fmt"
	"github.com/fsouza/go-dockerclient"
	"io"
	"log"
	"time"
)

func constructBuildImageOptions(dockerfile []byte) (docker.BuildImageOptions, io.Reader) {
	t := time.Now()
	inputbuf, outputbuf := bytes.NewBuffer(nil), bytes.NewBuffer(nil)
	tr := tar.NewWriter(inputbuf)
	tr.WriteHeader(&tar.Header{Name: "Dockerfile", Size: 10, ModTime: t, AccessTime: t, ChangeTime: t})
	tr.Write(dockerfile)
	tr.Close()
	return docker.BuildImageOptions{
		Name:         "test",
		InputStream:  inputbuf,
		OutputStream: outputbuf,
	}, outputbuf

}

func main() {
	endpoint := "unix:///var/run/docker.sock"
	client, _ := docker.NewClient(endpoint)
	opts, outputbuf := constructBuildImageOptions([]byte("FROM base\n"))
	if err := client.BuildImage(opts); err != nil {
		log.Fatal(err)
	}
	fmt.Println(outputbuf)<commit_msg>Running things with a container.<commit_after>package main

import (
	"archive/tar"
	"bytes"
	"fmt"
	"github.com/fsouza/go-dockerclient"
	"io"
	"log"
	"time"
)

func constructBuildImageOptions(dockerfile []byte) (docker.BuildImageOptions, io.Reader) {
	t := time.Now()
	inputbuf, outputbuf := bytes.NewBuffer(nil), bytes.NewBuffer(nil)
	tr := tar.NewWriter(inputbuf)
	tr.WriteHeader(&tar.Header{Name: "Dockerfile", Size: 10, ModTime: t, AccessTime: t, ChangeTime: t})
	tr.Write(dockerfile)
	tr.Close()
	return docker.BuildImageOptions{
		Name:         "test",
		InputStream:  inputbuf,
		OutputStream: outputbuf,
	}, outputbuf

}

func main() {
	endpoint := "unix:///var/run/docker.sock"
	client, _ := docker.NewClient(endpoint)
	opts, outputbuf := constructBuildImageOptions([]byte("FROM base\n"))
	if err := client.BuildImage(opts); err != nil {
		log.Fatal(err)
	}
	fmt.Println(outputbuf)
	cmds := []string{"date"}
	imageConfig := docker.Config{Image: "test", Cmd: cmds, AttachStdout: true, AttachStderr: true}
	containerOptions := docker.CreateContainerOptions{Name: "hola", Config: &imageConfig}
	cont, err := client.CreateContainer(containerOptions)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(cont)
{'fraction_non_alphanumeric': 0.15746519443110898, 'fraction_numerical': 0.0019203072491598655, 'mean_word_length': 5.075801749271137, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6352991', 'n_tokens_mistral': 775, 'n_tokens_neox': 741, 'n_words': 149}