-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Dockerfile parser, pretty-printer and embedded DSL -- -- All functions for parsing, printing and writting Dockerfiles are -- exported through Language.Docker. For more fine-grained -- operations look for specific modules that implement a certain -- functionality. See the GitHub project for the source-code and -- examples. @package language-docker @version 1.0.0 module Language.Docker.Syntax type Image = String type Tag = String data Ports Ports :: [Integer] -> Ports PortStr :: String -> Ports type Directory = String data BaseImage UntaggedImage :: Image -> BaseImage TaggedImage :: Image -> Tag -> BaseImage DigestedImage :: Image -> ByteString -> BaseImage -- | Type of the Dockerfile AST type Dockerfile = [InstructionPos] type Source = String type Destination = String type Arguments = [String] type Pairs = [(String, String)] -- | All commands available in Dockerfiles data Instruction From :: BaseImage -> Instruction Add :: Source -> Destination -> Instruction User :: String -> Instruction Label :: Pairs -> Instruction Stopsignal :: String -> Instruction Copy :: Source -> Destination -> Instruction Run :: Arguments -> Instruction Cmd :: Arguments -> Instruction Shell :: Arguments -> Instruction Workdir :: Directory -> Instruction Expose :: Ports -> Instruction Volume :: String -> Instruction Entrypoint :: Arguments -> Instruction Maintainer :: String -> Instruction Env :: Pairs -> Instruction Arg :: String -> Instruction Healthcheck :: String -> Instruction Comment :: String -> Instruction OnBuild :: Instruction -> Instruction EOL :: Instruction type Filename = String type Linenumber = Int -- | Instruction with additional location information required for -- creating good check messages data InstructionPos InstructionPos :: Instruction -> Filename -> Linenumber -> InstructionPos instruction :: InstructionPos -> Instruction sourcename :: InstructionPos -> Filename instance GHC.Show.Show Language.Docker.Syntax.InstructionPos instance GHC.Classes.Ord Language.Docker.Syntax.InstructionPos instance GHC.Classes.Eq Language.Docker.Syntax.InstructionPos instance GHC.Show.Show Language.Docker.Syntax.Instruction instance GHC.Classes.Ord Language.Docker.Syntax.Instruction instance GHC.Classes.Eq Language.Docker.Syntax.Instruction instance GHC.Show.Show Language.Docker.Syntax.BaseImage instance GHC.Classes.Ord Language.Docker.Syntax.BaseImage instance GHC.Classes.Eq Language.Docker.Syntax.BaseImage instance GHC.Classes.Ord Language.Docker.Syntax.Ports instance GHC.Classes.Eq Language.Docker.Syntax.Ports instance GHC.Show.Show Language.Docker.Syntax.Ports instance Data.String.IsString Language.Docker.Syntax.Ports module Language.Docker.Syntax.Lift instance Language.Haskell.TH.Syntax.Lift Language.Docker.Syntax.InstructionPos instance Language.Haskell.TH.Syntax.Lift Language.Docker.Syntax.Instruction instance Language.Haskell.TH.Syntax.Lift Language.Docker.Syntax.BaseImage instance Language.Haskell.TH.Syntax.Lift Language.Docker.Syntax.Ports module Language.Docker.PrettyPrint -- | Pretty print a Dockerfile to a String prettyPrint :: Dockerfile -> String -- | Pretty print a InstructionPos to a String prettyPrintInstructionPos :: InstructionPos -> String prettyPrintBaseImage :: BaseImage -> Doc prettyPrintPairs :: Pairs -> Doc prettyPrintPair :: (String, String) -> Doc prettyPrintArguments :: Arguments -> Doc prettyPrintJSON :: Arguments -> Doc prettyPrintInstruction :: Instruction -> Doc module Language.Docker.Normalize -- | Remove new line escapes and join escaped lines together on one line to -- simplify parsing later on. Escapes are replaced with line breaks to -- not alter the line numbers. normalizeEscapedLines :: String -> String module Language.Docker.Lexer lexer :: TokenParser () reserved :: String -> Parser () reservedOp :: String -> Parser () natural :: Parser Integer commaSep :: Parser a -> Parser [a] stringLiteral :: Parser String brackets :: Parser a -> Parser a identifier :: Parser String lexeme :: Parser a -> Parser a module Language.Docker.Parser comment :: Parser Instruction taggedImage :: Parser BaseImage digestedImage :: Parser BaseImage untaggedImage :: Parser BaseImage baseImage :: Parser BaseImage from :: Parser Instruction cmd :: Parser Instruction copy :: Parser Instruction shell :: Parser Instruction stopsignal :: Parser Instruction quotedValue :: Parser String rawValue :: Parser String singleValue :: Parser String pair :: Parser (String, String) pairs :: Parser Pairs remainingPairs :: Parser Pairs label :: Parser Instruction arg :: Parser Instruction env :: Parser Instruction user :: Parser Instruction add :: Parser Instruction expose :: Parser Instruction run :: Parser Instruction untilEol :: Parser String untilOccurrence :: String -> Parser String workdir :: Parser Instruction volume :: Parser Instruction maintainer :: Parser Instruction argumentsExec :: Parser Arguments argumentsShell :: Parser Arguments arguments :: Parser Arguments entrypoint :: Parser Instruction onbuild :: Parser Instruction eolInstruction :: Parser Instruction healthcheck :: Parser Instruction parseInstruction :: Parser Instruction contents :: Parser a -> Parser a eol :: Parser () dockerfile :: Parser Dockerfile parseString :: String -> Either ParseError Dockerfile parseFile :: String -> IO (Either ParseError Dockerfile) module Language.Docker.EDSL.Types data EBaseImage EUntaggedImage :: String -> EBaseImage ETaggedImage :: String -> String -> EBaseImage EDigestedImage :: String -> ByteString -> EBaseImage data EInstruction next From :: EBaseImage -> next -> EInstruction next Add :: Source -> Destination -> next -> EInstruction next User :: String -> next -> EInstruction next Label :: Pairs -> next -> EInstruction next StopSignal :: String -> next -> EInstruction next Copy :: Source -> Destination -> next -> EInstruction next RunArgs :: Arguments -> next -> EInstruction next CmdArgs :: Arguments -> next -> EInstruction next Shell :: Arguments -> next -> EInstruction next Workdir :: Directory -> next -> EInstruction next Expose :: Ports -> next -> EInstruction next Volume :: String -> next -> EInstruction next EntrypointArgs :: Arguments -> next -> EInstruction next Maintainer :: String -> next -> EInstruction next Env :: Pairs -> next -> EInstruction next Arg :: String -> next -> EInstruction next Comment :: String -> next -> EInstruction next Healthcheck :: String -> next -> EInstruction next OnBuildRaw :: Instruction -> next -> EInstruction next Embed :: [InstructionPos] -> next -> EInstruction next instance GHC.Base.Functor Language.Docker.EDSL.Types.EInstruction instance GHC.Classes.Ord Language.Docker.EDSL.Types.EBaseImage instance GHC.Classes.Eq Language.Docker.EDSL.Types.EBaseImage instance GHC.Show.Show Language.Docker.EDSL.Types.EBaseImage instance Data.String.IsString Language.Docker.EDSL.Types.EBaseImage module Language.Docker.EDSL -- | The type of Identity based EDSL blocks type EDockerfileM = Free EInstruction -- | The type of free monad EDSL blocks type EDockerfileTM = FreeT EInstruction type EInstructionM = Free EInstruction type EInstructionTM = FreeT EInstruction embed :: forall m_asNo. MonadFree EInstruction m_asNo => [InstructionPos] -> m_asNo () onBuildRaw :: forall m_asNl. MonadFree EInstruction m_asNl => Instruction -> m_asNl () healthcheck :: forall m_asNi. MonadFree EInstruction m_asNi => String -> m_asNi () comment :: forall m_asNf. MonadFree EInstruction m_asNf => String -> m_asNf () arg :: forall m_asNc. MonadFree EInstruction m_asNc => String -> m_asNc () env :: forall m_asN9. MonadFree EInstruction m_asN9 => Pairs -> m_asN9 () maintainer :: forall m_asN6. MonadFree EInstruction m_asN6 => String -> m_asN6 () entrypointArgs :: forall m_asN3. MonadFree EInstruction m_asN3 => Arguments -> m_asN3 () volume :: forall m_asN0. MonadFree EInstruction m_asN0 => String -> m_asN0 () expose :: forall m_asMX. MonadFree EInstruction m_asMX => Ports -> m_asMX () workdir :: forall m_asMU. MonadFree EInstruction m_asMU => Directory -> m_asMU () shell :: forall m_asMR. MonadFree EInstruction m_asMR => Arguments -> m_asMR () cmdArgs :: forall m_asMO. MonadFree EInstruction m_asMO => Arguments -> m_asMO () runArgs :: forall m_asML. MonadFree EInstruction m_asML => Arguments -> m_asML () copy :: forall m_asMH. MonadFree EInstruction m_asMH => Source -> Destination -> m_asMH () stopSignal :: forall m_asME. MonadFree EInstruction m_asME => String -> m_asME () label :: forall m_asMB. MonadFree EInstruction m_asMB => Pairs -> m_asMB () user :: forall m_asMy. MonadFree EInstruction m_asMy => String -> m_asMy () add :: forall m_asMu. MonadFree EInstruction m_asMu => Source -> Destination -> m_asMu () from :: forall m_asLN. MonadFree EInstruction m_asLN => EBaseImage -> m_asLN () runDockerWriter :: (MonadWriter [Instruction] m) => EDockerfileM a -> m a runDockerWriterIO :: (Monad m, MonadTrans t, Monad (t m), MonadWriter [Instruction] (t m), MonadIO (t m)) => EDockerfileTM m a -> t m a runDef :: MonadWriter [t] m => (t1 -> t) -> t1 -> m b -> m b runDef2 :: MonadWriter [t] m => (t1 -> t2 -> t) -> t1 -> t2 -> m b -> m b runD :: MonadWriter [Instruction] m => EInstruction (m b) -> m b instructionPos :: Instruction -> InstructionPos -- | Runs the Dockerfile EDSL and returns a Dockerfile you can -- pretty print or manipulate toDockerfile :: EDockerfileM a -> Dockerfile -- | runs the Dockerfile EDSL and returns a String using -- PrettyPrint -- --
-- import Language.Docker -- -- main :: IO () -- main = writeFile "something.dockerfile" $ toDockerfileStr $ do -- from (tagged "fpco/stack-build" "lts-6.9") -- add "." "applanguage-dockerfile" -- workdir "applanguage-dockerfile" -- run (words "stack build --test --only-dependencies") -- cmd (words "stack test") --toDockerfileStr :: EDockerfileM a -> String untagged :: String -> EBaseImage tagged :: String -> String -> EBaseImage digested :: String -> ByteString -> EBaseImage ports :: [Integer] -> Ports port :: Integer -> Ports run :: MonadFree EInstruction m => String -> m () entrypoint :: MonadFree EInstruction m => String -> m () cmd :: MonadFree EInstruction m => String -> m () -- | ONBUILD Dockerfile instruction -- -- Each nested instruction gets emitted as a separate ONBUILD -- block -- --
-- toDockerfile $ do -- from "node" -- run "apt-get update" -- onBuild $ do -- run "echo more-stuff" -- run "echo here" --onBuild :: MonadFree EInstruction m => EDockerfileM a -> m () -- | A version of toDockerfile which allows IO actions toDockerfileIO :: MonadIO m => EDockerfileTM m t -> m Dockerfile -- | A version of toDockerfileStr which allows IO actions toDockerfileStrIO :: MonadIO m => EDockerfileTM m t -> m String -- | Just runs the EDSL's writer monad runDockerfileIO :: MonadIO m => EDockerfileTM m t -> m (t, Dockerfile) -- | Runs the EDSL's writer monad and pretty-prints the result runDockerfileStrIO :: MonadIO m => EDockerfileTM m t -> m (t, String) module Language.Docker.EDSL.Quasi -- | Quasiquoter for embedding dockerfiles on the EDSL -- --
-- putStr $ toDockerfile $ do -- from "node" -- run "apt-get update" -- [edockerfile| -- RUN apt-get update -- CMD node something.js -- |] --edockerfile :: QuasiQuoter edockerfileE :: String -> ExpQ dockerfile :: QuasiQuoter dockerfileE :: String -> ExpQ filterEOL :: [InstructionPos] -> [InstructionPos] module Language.Docker -- | Type of the Dockerfile AST type Dockerfile = [InstructionPos] parseString :: String -> Either ParseError Dockerfile parseFile :: String -> IO (Either ParseError Dockerfile) -- | Pretty print a Dockerfile to a String prettyPrint :: Dockerfile -> String -- | Pretty print a InstructionPos to a String prettyPrintInstructionPos :: InstructionPos -> String -- | runs the Dockerfile EDSL and returns a String using -- PrettyPrint -- --
-- import Language.Docker -- -- main :: IO () -- main = writeFile "something.dockerfile" $ toDockerfileStr $ do -- from (tagged "fpco/stack-build" "lts-6.9") -- add "." "applanguage-dockerfile" -- workdir "applanguage-dockerfile" -- run (words "stack build --test --only-dependencies") -- cmd (words "stack test") --toDockerfileStr :: EDockerfileM a -> String -- | Runs the Dockerfile EDSL and returns a Dockerfile you can -- pretty print or manipulate toDockerfile :: EDockerfileM a -> Dockerfile -- | A version of toDockerfileStr which allows IO actions toDockerfileStrIO :: MonadIO m => EDockerfileTM m t -> m String -- | A version of toDockerfile which allows IO actions toDockerfileIO :: MonadIO m => EDockerfileTM m t -> m Dockerfile -- | Just runs the EDSL's writer monad runDockerfileIO :: MonadIO m => EDockerfileTM m t -> m (t, Dockerfile) -- | Runs the EDSL's writer monad and pretty-prints the result runDockerfileStrIO :: MonadIO m => EDockerfileTM m t -> m (t, String) -- | Lift a computation from the IO monad. liftIO :: MonadIO m => forall a. IO a -> m a from :: forall m_asLN. MonadFree EInstruction m_asLN => EBaseImage -> m_asLN () tagged :: String -> String -> EBaseImage untagged :: String -> EBaseImage digested :: String -> ByteString -> EBaseImage add :: forall m_asMu. MonadFree EInstruction m_asMu => Source -> Destination -> m_asMu () user :: forall m_asMy. MonadFree EInstruction m_asMy => String -> m_asMy () label :: forall m_asMB. MonadFree EInstruction m_asMB => Pairs -> m_asMB () stopSignal :: forall m_asME. MonadFree EInstruction m_asME => String -> m_asME () copy :: forall m_asMH. MonadFree EInstruction m_asMH => Source -> Destination -> m_asMH () run :: MonadFree EInstruction m => String -> m () runArgs :: forall m_asML. MonadFree EInstruction m_asML => Arguments -> m_asML () cmd :: MonadFree EInstruction m => String -> m () cmdArgs :: forall m_asMO. MonadFree EInstruction m_asMO => Arguments -> m_asMO () workdir :: forall m_asMU. MonadFree EInstruction m_asMU => Directory -> m_asMU () expose :: forall m_asMX. MonadFree EInstruction m_asMX => Ports -> m_asMX () ports :: [Integer] -> Ports port :: Integer -> Ports volume :: forall m_asN0. MonadFree EInstruction m_asN0 => String -> m_asN0 () entrypoint :: MonadFree EInstruction m => String -> m () entrypointArgs :: forall m_asN3. MonadFree EInstruction m_asN3 => Arguments -> m_asN3 () maintainer :: forall m_asN6. MonadFree EInstruction m_asN6 => String -> m_asN6 () env :: forall m_asN9. MonadFree EInstruction m_asN9 => Pairs -> m_asN9 () arg :: forall m_asNc. MonadFree EInstruction m_asNc => String -> m_asNc () comment :: forall m_asNf. MonadFree EInstruction m_asNf => String -> m_asNf () -- | ONBUILD Dockerfile instruction -- -- Each nested instruction gets emitted as a separate ONBUILD -- block -- --
-- toDockerfile $ do -- from "node" -- run "apt-get update" -- onBuild $ do -- run "echo more-stuff" -- run "echo here" --onBuild :: MonadFree EInstruction m => EDockerfileM a -> m () onBuildRaw :: forall m_asNl. MonadFree EInstruction m_asNl => Instruction -> m_asNl () embed :: forall m_asNo. MonadFree EInstruction m_asNo => [InstructionPos] -> m_asNo () -- | Quasiquoter for embedding dockerfiles on the EDSL -- --
-- putStr $ toDockerfile $ do -- from "node" -- run "apt-get update" -- [edockerfile| -- RUN apt-get update -- CMD node something.js -- |] --edockerfile :: QuasiQuoter -- | The type of Identity based EDSL blocks type EDockerfileM = Free EInstruction -- | The type of free monad EDSL blocks type EDockerfileTM = FreeT EInstruction data EBaseImage EUntaggedImage :: String -> EBaseImage ETaggedImage :: String -> String -> EBaseImage EDigestedImage :: String -> ByteString -> EBaseImage dockerfile :: QuasiQuoter -- | All commands available in Dockerfiles data Instruction From :: BaseImage -> Instruction Add :: Source -> Destination -> Instruction User :: String -> Instruction Label :: Pairs -> Instruction Stopsignal :: String -> Instruction Copy :: Source -> Destination -> Instruction Run :: Arguments -> Instruction Cmd :: Arguments -> Instruction Shell :: Arguments -> Instruction Workdir :: Directory -> Instruction Expose :: Ports -> Instruction Volume :: String -> Instruction Entrypoint :: Arguments -> Instruction Maintainer :: String -> Instruction Env :: Pairs -> Instruction Arg :: String -> Instruction Healthcheck :: String -> Instruction Comment :: String -> Instruction OnBuild :: Instruction -> Instruction EOL :: Instruction -- | Instruction with additional location information required for -- creating good check messages data InstructionPos InstructionPos :: Instruction -> Filename -> Linenumber -> InstructionPos data BaseImage UntaggedImage :: Image -> BaseImage TaggedImage :: Image -> Tag -> BaseImage DigestedImage :: Image -> ByteString -> BaseImage type Image = String type Tag = String data Ports type Directory = String type Source = String type Destination = String type Arguments = [String] type Pairs = [(String, String)] type Filename = String type Linenumber = Int -- | The abstract data type ParseError represents parse errors. It -- provides the source position (SourcePos) of the error and a -- list of error messages (Message). A ParseError can be -- returned by the function parse. ParseError is an -- instance of the Show and Eq classes. data ParseError :: * instruction :: InstructionPos -> Instruction instructionPos :: Instruction -> InstructionPos sourcename :: InstructionPos -> Filename module Language.Docker.Predef appendLnIfMissing :: FilePath -> Text -> IO () dockerIgnore :: Text -> IO () addGlob :: (MonadIO m, MonadFree EInstruction m) => String -> Destination -> m () copyGlob :: (MonadIO m, MonadFree EInstruction m) => String -> Destination -> m () stackBuild :: (Monad m, MonadIO m, MonadFree EInstruction m) => m () stackBuild' :: (Monad m, MonadIO m, MonadFree EInstruction m) => String -> m () -> m () nodejs :: (Monad m, MonadIO m, MonadFree EInstruction m) => m () nodejs' :: (Monad m, MonadIO m, MonadFree EInstruction m) => String -> m () -> m ()