<commit_before>(ns clj-docker.image
  (:require [clj-docker.client :as client]
            [cheshire.core :as json]
            [k2nr-utils.tar  :refer [create-archive with-open-tar add-entry]]
            [clojure.java.io :refer [file input-stream delete-file]]))

(defn build-from-stream [cli body-stream & {:keys [name quiet no-cache stream]}]
  (client/post cli "/build"
               {:headers {"Content-Type" "application/tar"}
                :query-params {:t name
                               :q quiet
                               :nocache no-cache}
                :body body-stream
                :as (if stream :stream :json)}))

(defn build-from-dir [cli path & opts]
  (let [tar (create-archive path)
        response (build-from-stream cli (input-stream tar) opts)]
    (delete-file tar)
    response))

(defn build-from-file [cli path & opts]
  (let [docker-file (file path)
        tar (with-open-tar
              "dockerfile.tar.gz"
              (fn [tar]
                (add-entry tar docker-file "Dockerfile")))
        response (build-from-stream cli (input-stream tar) opts)]
    (delete-file tar)
    response))

(defn create [cli name & {:keys [repo tag registry stream]}]
  (client/post cli "/images/create"
               {:query-params {:fromImage name
                               :repo      repo
                               :tag       tag
                               :registry  registry}
                :as (if stream :stream :json)}))

(defn push [cli name & {:keys [registry stream]}]
  (client/post cli (str "/images/" name "/push")
               {:query-params {:registry registry}<commit_msg>fix error when build<commit_after>(ns clj-docker.image
  (:require [clj-docker.client :as client]
            [cheshire.core :as json]
            [k2nr-utils.tar  :refer [create-archive with-open-tar add-entry]]
            [clojure.java.io :refer [file input-stream delete-file]]))

(defn build-from-stream [cli body-stream & {:keys [name quiet no-cache stream]}]
  (client/post cli "/build"
               {:headers {"Content-Type" "application/tar"}
                :query-params {:t name
                               :q quiet
                               :nocache no-cache}
                :body body-stream
                :as (if stream :stream :json)}))

(defn build-from-dir [cli path & opts]
  (let [tar (create-archive path)
        response (apply build-from-stream cli (input-stream tar) opts)]
    (delete-file tar)
    response))

(defn build-from-file [cli path & opts]
  (let [docker-file (file path)
        tar (with-open-tar
              "dockerfile.tar.gz"
              (fn [tar]
                (add-entry tar docker-file "Dockerfile")))
        response (apply build-from-stream cli (input-stream tar) opts)]
    (delete-file tar)
    response))

(defn create [cli name & {:keys [repo tag registry stream]}]
  (client/post cli "/images/create"
               {:query-params {:fromImage name
                               :repo      repo
                               :tag       tag
                               :registry  registry}
                :as (if stream :stream :json)}))

(defn push [cli name & {:keys [registry stream]}]
  (client/post cli (str "/images/" name "/push")
               {:query-params {:registry registry}
{'fraction_non_alphanumeric': 0.1263221517074645, 'fraction_numerical': 0.0006044122091266244, 'mean_word_length': 1.7086743044189854, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6056390', 'n_tokens_mistral': 980, 'n_tokens_neox': 950, 'n_words': 274}