summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Docker.hs
diff options
context:
space:
mode:
authorAntoine Eiche2015-05-11 00:00:00 +0200
committerJoey Hess2015-05-12 11:05:47 -0400
commitc83c68115f1e56e64ba46ddcb4e82454764bc39d (patch)
tree808d02f8c47b78916e7ab43694f589666ec059b7 /src/Propellor/Property/Docker.hs
parent3790a65dd5e1558ffe5a89577788f68288570d3a (diff)
Docker images related properties.
- a property to pull image from standard Docker Hub registry. - a property to build image from a local directory (with a Dockerfile).
Diffstat (limited to 'src/Propellor/Property/Docker.hs')
-rw-r--r--src/Propellor/Property/Docker.hs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/Propellor/Property/Docker.hs b/src/Propellor/Property/Docker.hs
index d04ed4bf..745b5622 100644
--- a/src/Propellor/Property/Docker.hs
+++ b/src/Propellor/Property/Docker.hs
@@ -11,6 +11,8 @@ module Propellor.Property.Docker (
configured,
container,
docked,
+ imageBuilt,
+ imagePulled,
memoryLimited,
garbageCollected,
tweaked,
@@ -43,6 +45,7 @@ import Propellor.Types.Docker
import Propellor.Types.CmdLine
import qualified Propellor.Property.File as File
import qualified Propellor.Property.Apt as Apt
+import qualified Propellor.Property.Cmd as Cmd
import qualified Propellor.Shim as Shim
import Utility.SafeCommand
import Utility.Path
@@ -138,6 +141,21 @@ docked ctr@(Container _ h) =
]
]
+-- | Build the image from a directory containing a Dockerfile.
+imageBuilt :: FilePath -> Image -> Property NoInfo
+imageBuilt directory image = describe built msg
+ where
+ msg = "docker image " ++ image ++ " built from " ++ directory
+ built = Cmd.cmdProperty' dockercmd ["build", "--tag", image, "./"] workDir
+ workDir p = p { cwd = Just directory }
+
+-- | Pull the image from the standard Docker Hub registry.
+imagePulled :: Image -> Property NoInfo
+imagePulled image = describe pulled msg
+ where
+ msg = "docker image " ++ image ++ " pulled"
+ pulled = Cmd.cmdProperty dockercmd ["pull", image]
+
propigateContainerInfo :: (IsProp (Property i)) => Container -> Property i -> Property HasInfo
propigateContainerInfo ctr@(Container _ h) p = propigateContainer ctr p'
where