add first try for image build
This commit is contained in:
parent
e9262382c4
commit
198713c229
5 changed files with 47 additions and 19 deletions
5
.bashrc
Normal file
5
.bashrc
Normal file
|
@ -0,0 +1,5 @@
|
|||
_bb_tasks() {
|
||||
COMPREPLY=( $(compgen -W "$(bb tasks |tail -n +3 |cut -f1 -d ' ')" -- ${COMP_WORDS[COMP_CWORD]}) );
|
||||
}
|
||||
# autocomplete filenames as well
|
||||
complete -f -F _bb_tasks bb
|
4
bb.edn
4
bb.edn
|
@ -1,5 +1,5 @@
|
|||
{:deps {dda/dda-devops-build {:local/root "."}}
|
||||
:tasks
|
||||
{:requires ([dda.devops-build.main :as main])
|
||||
image-build (apply main/build *command-line-args*)}}
|
||||
{:requires ([dda.devops-build.image :as image])
|
||||
image-build (image/dbuild {:name "myimage"})}}
|
||||
|
||||
|
|
12
src/main/clj/dda/devops_build/devops.clj
Normal file
12
src/main/clj/dda/devops_build/devops.clj
Normal file
|
@ -0,0 +1,12 @@
|
|||
(ns dda.devops-build.devops
|
||||
(:require [clojure.spec.alpha :as s]))
|
||||
|
||||
(s/def ::name string?)
|
||||
(s/def ::module string?)
|
||||
(s/def ::stage string?)
|
||||
(s/def ::project-root-path string?)
|
||||
(s/def ::build-dir-name string?)
|
||||
|
||||
(s/def ::devops
|
||||
(s/keys :req-un [::name]
|
||||
:opt-un [::module ::stage ::project-root-path ::build-dir-name]))
|
28
src/main/clj/dda/devops_build/image.clj
Normal file
28
src/main/clj/dda/devops_build/image.clj
Normal file
|
@ -0,0 +1,28 @@
|
|||
(ns dda.devops-build.image
|
||||
(:require [clojure.spec.alpha :as s]
|
||||
[babashka.process :as p]
|
||||
[babashka.tasks :as t]
|
||||
[orchestra.core :refer [defn-spec]]
|
||||
[dda.devops-build.devops :as d]))
|
||||
|
||||
(s/def ::options (s/* #{"-h"}))
|
||||
(s/def ::cmd-args (s/cat :options ::options
|
||||
:args any?))
|
||||
|
||||
(defn invalid-args-msg
|
||||
[spec args]
|
||||
(s/explain spec args)
|
||||
(println (str "Bad commandline arguments\n")))
|
||||
|
||||
(defn-spec
|
||||
dbuild any?
|
||||
[devops ::d/devops]
|
||||
(let [{:keys [name]} devops]
|
||||
(t/shell "echo 'docker" "build" "-t" name "--file" "{path}/image/Dockerfile" "{path}/image")))
|
||||
|
||||
(defn drun [& cmd-args]
|
||||
(let [parsed-args-cmd (s/conform ::cmd-args cmd-args)]
|
||||
(if (= ::s/invalid parsed-args-cmd)
|
||||
(invalid-args-msg ::cmd-args cmd-args)
|
||||
(-> (p/process "docker run" "-it" "{name}" "/bin/bash")
|
||||
(p/check)))))
|
|
@ -1,17 +0,0 @@
|
|||
(ns dda.devops-build.main)
|
||||
(require '[clojure.spec.alpha :as s])
|
||||
|
||||
(s/def ::options (s/* #{"-h"}))
|
||||
(s/def ::cmd-args (s/cat :options ::options
|
||||
:args any?))
|
||||
|
||||
(defn invalid-args-msg
|
||||
[spec args]
|
||||
(s/explain spec args)
|
||||
(println (str "Bad commandline arguments\n")))
|
||||
|
||||
(defn build [& cmd-args]
|
||||
(let [parsed-args-cmd (s/conform ::cmd-args cmd-args)]
|
||||
(if (= ::s/invalid parsed-args-cmd)
|
||||
(invalid-args-msg ::cmd-args cmd-args)
|
||||
(println parsed-args-cmd))))
|
Loading…
Reference in a new issue