procBuildImage
    :: ( Member Proc r
      , Member Filesystem r
      , Member (Exception DockerEx) r)
    => Path -- ^ Directory containing the @Dockerfile@
    -> Image
    -> Eff r Image
procBuildImage path img = do
    exists <- doesDirectoryExist path
    when (not exists) $
        throwException (MissingRecipe path)
    (status, _stdout, stderr) <- docker "build" ["--tag", imageRepr img, pathToText unixSeparator path]
    when (isFailure status) $
        throwException (parseError stderr)
    -- TODO Parse correct output
    return img

-- | Tag a Docker 'Image' with a 'Tag'.
--
-- If the 'Image' does not exist a 'NoSuchImage' exception will be
-- raised.
procBuildImage
    :: ( Member Proc r
      , Member Filesystem r
      , Member (Exception DockerEx) r)
    => Path -- ^ Directory containing the @Dockerfile@
    -> Image
    -> Eff r Image
procBuildImage path img = do
    exists <- doesDirectoryExist path
    when (not exists) $
        throwException (MissingRecipe path)
    (status, _stdout, stderr) <- docker "build" ["--tag", imageRepr img, pathToText unixSeparator path]
    when (isFailure status) $
        throwException (parseError stderr)
    -- TODO Parse correct output
    return img

-- | Tag a Docker 'Image' with a 'Tag'.
--
-- If the 'Image' does not exist a 'NoSuchImage' exception will be
-- raised.
procBuildImage path img = do
    exists <- doesDirectoryExist path
    when (not exists) $
        throwException (MissingRecipe path)
    (status, _stdout, stderr) <- docker "build" ["--tag", imageRepr img, pathToText unixSeparator path]
    when (isFailure status) $
        throwException (parseError stderr)
    -- TODO Parse correct output
    return img

-- | Tag a Docker 'Image' with a 'Tag'.
--
-- If the 'Image' does not exist a 'NoSuchImage' exception will be
-- raised.