packages feed

docker-build-cacher 2.1.0 → 2.1.1

raw patch · 2 files changed

+22/−10 lines, 2 files

Files

docker-build-cacher.cabal view
@@ -2,11 +2,11 @@ -- -- see: https://github.com/sol/hpack ----- hash: bba2ebc1d94e53e264f8fc6617af435725332ab983d4665a9360298eed6f98e5+-- hash: 307458352ac122d4179e82aba4f68459442bf1608564a04a683d50ff91ea2518  name:           docker-build-cacher-version:        2.1.0-synopsis:       Builds a services with docker and caches all of its intermediate stages+version:        2.1.1+synopsis:       Builds a docker image and caches all of its intermediate stages description:    A CLI tool to speed up multi-stage docker file builds by caching intermediate category:       Operations homepage:       https://github.com/seatgeek/docker-build-cacher#readme
src/Docker/Cacher/Inspect.hs view
@@ -137,7 +137,13 @@ shouldBustCache :: Stage SourceImage -> StageCache -> Shell StageCache shouldBustCache sourceStage cached@Cached {..} = do   printLn ("----> Checking cache buster files for stage " % s) (stageName stage)-  withContainer (buildImageName stage) checkFiles -- Create a container to inspect the files+  result <- withContainer (buildImageName stage) checkFiles -- Create a container to inspect the files+  case result of+    Left _ -> do+      err+        "----> Could not create the container, impossible to inspect the cache"+      return $ NotCached sourceStage+    Right stCache -> return stCache  where   checkFiles containerId = do     hasChanged <- fold@@ -163,7 +169,10 @@     if isDirectory fileStat       then do         printLn-          ("------>'" % fp % "' is a directory, assuming files inside it changed")+          ( "------>'"+          % fp+          % "' is a directory, assuming files inside it changed"+          )           file         return $ Just file       else do@@ -297,12 +306,15 @@  -- | Creates a container from a stage and passes the container id to the --   given shell as an argument-withContainer :: ImageName a -> (Text -> Shell b) -> Shell b+withContainer :: ImageName a -> (Text -> Shell b) -> Shell (Either Line b) withContainer (ImageName imageName) action = do-  containerId <- inproc "docker" ["create", imageName] empty-  result      <- fold (action (format l containerId)) Fold.list-  _           <- removeContainer containerId -- Ignore the return code of this command-  select result -- yield each result as a separate line+  result <- inprocWithErr "docker" ["create", imageName, "sh"] empty+  case result of+    Left  errorMsg    -> return (Left errorMsg)+    Right containerId -> do+      res <- fold (action (format l containerId)) Fold.list+      _   <- removeContainer containerId -- Ignore the return code of this command+      select (map Right res) -- yield each result as a separate line  where   removeContainer containerId =     proc "docker" ["rm", format l containerId] empty