From 5e17795228559079d456d5660e92be43119d8918 Mon Sep 17 00:00:00 2001 From: Juerg Lang Date: Sat, 26 Aug 2023 22:12:37 +0200 Subject: [PATCH] worked on :docker module --- .../modules/ModuleDockerSection.java | 1 + .../com/github/jlangch/venice/docker.venice | 23 ++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/github/jlangch/venice/impl/docgen/cheatsheet/modules/ModuleDockerSection.java b/src/main/java/com/github/jlangch/venice/impl/docgen/cheatsheet/modules/ModuleDockerSection.java index c9c1d66c4..2f5079b46 100644 --- a/src/main/java/com/github/jlangch/venice/impl/docgen/cheatsheet/modules/ModuleDockerSection.java +++ b/src/main/java/com/github/jlangch/venice/impl/docgen/cheatsheet/modules/ModuleDockerSection.java @@ -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)); diff --git a/src/main/resources/com/github/jlangch/venice/docker.venice b/src/main/resources/com/github/jlangch/venice/docker.venice index 38606a65c..3d1292627 100644 --- a/src/main/resources/com/github/jlangch/venice/docker.venice +++ b/src/main/resources/com/github/jlangch/venice/docker.venice @@ -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 | @@ -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) @@ -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*) @@ -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*))))