A Haskell DSL for Generating Dockerfiles
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.circleci Update ci to use checksum of hpack file for caching Aug 31, 2018
Control/Monad Add new commands & update existing commands to v18.03 Aug 31, 2018
Data Consistently use `++` over `<>` Aug 31, 2018
examples Initial commit. Jun 27, 2015
test Fix ambiguous imports in test suite Aug 31, 2018
.gitignore Initial commit. Jun 27, 2015
LICENSE Add new commands & update existing commands to v18.03 Aug 31, 2018
README.md Update README.md Sep 29, 2018
Setup.hs
dockerfile.cabal Remove short description in package.yaml Sep 14, 2018
package.yaml Remove short description in package.yaml Sep 14, 2018
stack.yaml Add new commands & update existing commands to v18.03 Aug 31, 2018

README.md

dockerfile - A simple Dockerfile DSL for Haskell

CircleCI

Examples

  • Write a simple Dockerfile

    {-# LANGUAGE OverloadedStrings #-}
    
    import Data.Docker
    
    main :: IO ()
    main = putStrLn $ do
        dockerfile $ do
            from "debian:stable"
            env "DEBIAN_FRONTEND" "noninteractive"
            run "apt-get -y update"
            run "apt-get -y upgrade"
            cmd ["echo", "hello world"]
    
  • Write a Dockerfile directly to a file

    {-# LANGUAGE OverloadedStrings #-}
    
    import Data.Docker
    
    main :: IO ()
    main = dockerfileWrite "Dockerfile.example $ do
        from "debian:stable"
        run "apt-get -y update"
        run "apt-get -y upgrade"
        cmd ["echo", "hello world"]
    
  • Multi-stage build (a cleaner alternative to https://github.com/fpco/haskell-scratch):

    {-# LANGUAGE OverloadedStrings #-}
    
    import Data.Docker
    
    main :: IO ()
    main = putStrLn $ do
    
        dockerfile $ do
    
            fromas "debian:stable" "base"
            env "DEBIAN_FRONTEND" "noninteractive"
    
            run "apt-get -y update"
            run "apt-get -y install netbase"
    
            let prod_img_files = [
                    "/lib/x86_64-linux-gnu/libc.so.6"
                  , "/etc/protocols"
                  ]
    
            from "scratch"
    
            forM_ prod_img_files $ \fp -> do
                copyfrom "base" fp fp
    
            entrypoint ["bash"]