#18 - Unified handling of container creation

This commit is contained in:
Tim Zöller 2020-08-05 09:12:23 +02:00
parent 8794b4a991
commit ce0460a35a

View file

@ -35,21 +35,12 @@
init)) init))
(defn create-from-docker-file (defn create-from-docker-file
[{:keys [exposed-ports env-vars command docker-file] "Creates a testcontainer from a provided Dockerfile"
:or {docker-file "Dockerfile"}}] [{:keys [docker-file] :as options}]
(let [docker-image (-> (ImageFromDockerfile.) (->> (.withDockerfile (ImageFromDockerfile.) (Paths/get "." (into-array [docker-file])))
(.withDockerfile (Paths/get "." (into-array [docker-file])))) (GenericContainer.)
container (GenericContainer. docker-image)] (assoc options :container)
(.setExposedPorts container (map int exposed-ports)) init))
(if (some? env-vars)
(doseq [[k v] env-vars]
(.addEnv container k v)))
(if (some? command)
(.setCommand container command))
{:container container
:exposed-ports (.getExposedPorts container)
:env-vars (.getEnvMap container)
:host (.getHost container)}))
(defn map-classpath-resource! (defn map-classpath-resource!
"Maps a resource in the classpath to the given container path. Should be called before starting the container!" "Maps a resource in the classpath to the given container path. Should be called before starting the container!"