Skip to content

Commit

Permalink
worked on :docker module
Browse files Browse the repository at this point in the history
  • Loading branch information
jlangch committed Aug 26, 2023
1 parent e36701f commit 5e17795
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public DocSection section() {
final DocSection images = new DocSection("Images", id());
all.addSection(images);
images.addItem(diBuilder.getDocItem("docker/images", false));
images.addItem(diBuilder.getDocItem("docker/image-pull", false));
images.addItem(diBuilder.getDocItem("docker/image-remove", false));
images.addItem(diBuilder.getDocItem("docker/image-prune", false));

Expand Down
23 changes: 15 additions & 8 deletions src/main/resources/com/github/jlangch/venice/docker.venice
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,14 @@


(defn
^{ :arglists '("(docker/run image-id & options)")
^{ :arglists '("(docker/run image-tag-or-id & options)")
:doc """
Create and run a new container from an image.

Options:

| :detach {true, false} | Run container in background and print container ID |
| :publish port | Publish a container's port(s) to the host |
| :envs vars | Set environment variable (a sequence of env var defs) |
| :memory limit | Memory limit |
| :name name | Assign a name to the container |
Expand All @@ -175,17 +176,22 @@
| :args arg | Argument passed to container process (a sequence of args) |
"""
:examples '(
"(println (docker/ps :format :table))"
"(docker/ps :all true :format :json)"
"(docker/ps :quiet true :format :json)"
"(docker/ps :last 3 :format :json)"
"(println (docker/ps :all true :format :json))" )
"""
;; Run an ArangoDB container
(docker/run "arangodb/arangodb:3.10.10"
:publish "8529:8529"
:envs ["ARANGO_ROOT_PASSWORD=xxxxxx"
"ARANGODB_OVERRIDE_DETECTED_TOTAL_MEMORY=8G"
"ARANGODB_OVERRIDE_DETECTED_NUMBER_OF_CORES=1"]
:args ["--database.auto-upgrade"])
""")
:see-also '("docker/start" "docker/stop" "docker/cp") }

run [& options]
run [image-tag-or-id & options]

(let [opts (apply hash-map options)
detach (:detach opts false)
publish (:publish opts nil)
envs (:envs opts [])
memory (:memory opts 0)
name (:name opts nil)
Expand All @@ -196,6 +202,7 @@
cmdargs* ["run"]
cmdargs* (if detach (conj cmdargs* "--detach") cmdargs*)
cmdargs* (if quiet (conj cmdargs* "--quiet") cmdargs*)
cmdargs* (if (some? publish) (conj cmdargs* "--publish" publish) cmdargs*)
cmdargs* (if (pos? memory) (conj cmdargs* "--memory" memory) cmdargs*)
cmdargs* (if (some? name) (conj cmdargs* "--name" name) cmdargs*)
cmdargs* (if (some? workdir) (conj cmdargs* "--workdir" workdir) cmdargs*)
Expand All @@ -205,7 +212,7 @@
cmdargs* (if (and (some? envs) (vector? envs))
(into cmdargs* (interleave (lazy-seq (constantly "--env")) envs))
cmdargs*)
cmdargs* (conj cmdargs* image-id)
cmdargs* (conj cmdargs* image-tag-or-id)
cmdargs* (if (and (some? args) (vector?)) (into cmdargs* args) cmdargs*)]
(:out (apply docker/cmd cmdargs*))))

Expand Down

0 comments on commit 5e17795

Please sign in to comment.