language-docker-2.0.1: Dockerfile parser, pretty-printer and embedded DSL

Safe HaskellNone
LanguageHaskell2010

Language.Docker

Contents

Synopsis

Documentation

type Dockerfile = [InstructionPos] #

Type of the Dockerfile AST

Parsing Dockerfiles (Language.Docker.Syntax and Language.Docker.Parser)

Pretty-printing Dockerfiles (Language.Docker.PrettyPrint)

prettyPrint :: Dockerfile -> String #

Pretty print a Dockerfile to a String

Writting Dockerfiles (Language.Docker.EDSL)

toDockerfileStr :: EDockerfileM a -> 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-docker"
    workdir "applanguage-docker"
    run (words "stack build --test --only-dependencies")
    cmd (words "stack test")

toDockerfile :: EDockerfileM a -> Dockerfile #

Runs the Dockerfile EDSL and returns a Dockerfile you can pretty print or manipulate

toDockerfileStrIO :: MonadIO m => EDockerfileTM m t -> m String #

A version of toDockerfileStr which allows IO actions

toDockerfileIO :: MonadIO m => EDockerfileTM m t -> m Dockerfile #

A version of toDockerfile which allows IO actions

runDockerfileIO :: MonadIO m => EDockerfileTM m t -> m (t, Dockerfile) #

Just runs the EDSL's writer monad

runDockerfileStrIO :: MonadIO m => EDockerfileTM m t -> m (t, String) #

Runs the EDSL's writer monad and pretty-prints the result

liftIO :: MonadIO m => forall a. IO a -> m a #

Lift a computation from the IO monad.

from :: forall m. MonadFree EInstruction m => EBaseImage -> m () #

Constructing base images

Syntax

user :: forall m. MonadFree EInstruction m => String -> m () #

label :: forall m. MonadFree EInstruction m => Pairs -> m () #

stopSignal :: forall m. MonadFree EInstruction m => String -> m () #

runArgs :: forall m. MonadFree EInstruction m => Arguments -> m () #

cmdArgs :: forall m. MonadFree EInstruction m => Arguments -> m () #

healthcheck :: forall m. MonadFree EInstruction m => Check -> m () #

workdir :: forall m. MonadFree EInstruction m => Directory -> m () #

expose :: forall m. MonadFree EInstruction m => Ports -> m () #

ports :: [Port] -> Ports #

volume :: forall m. MonadFree EInstruction m => String -> m () #

entrypointArgs :: forall m. MonadFree EInstruction m => Arguments -> m () #

maintainer :: forall m. MonadFree EInstruction m => String -> m () #

env :: forall m. MonadFree EInstruction m => Pairs -> m () #

arg :: forall m. MonadFree EInstruction m => String -> Maybe String -> m () #

comment :: forall m. MonadFree EInstruction m => String -> m () #

onBuild :: MonadFree EInstruction m => EDockerfileM a -> 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"

onBuildRaw :: forall m. MonadFree EInstruction m => Instruction -> m () #

embed :: forall m. MonadFree EInstruction m => [InstructionPos] -> m () #

edockerfile :: QuasiQuoter #

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
    |]

Support types for the EDSL

type EDockerfileM = Free EInstruction #

The type of Identity based EDSL blocks

type EDockerfileTM = FreeT EInstruction #

The type of free monad EDSL blocks

QuasiQuoter (Language.Docker.EDSL.Quasi)

Types (Language.Docker.Syntax)

data Chown #

Constructors

Chown String 
NoChown 

Instances

Eq Chown # 

Methods

(==) :: Chown -> Chown -> Bool #

(/=) :: Chown -> Chown -> Bool #

Ord Chown # 

Methods

compare :: Chown -> Chown -> Ordering #

(<) :: Chown -> Chown -> Bool #

(<=) :: Chown -> Chown -> Bool #

(>) :: Chown -> Chown -> Bool #

(>=) :: Chown -> Chown -> Bool #

max :: Chown -> Chown -> Chown #

min :: Chown -> Chown -> Chown #

Show Chown # 

Methods

showsPrec :: Int -> Chown -> ShowS #

show :: Chown -> String #

showList :: [Chown] -> ShowS #

data Check #

Constructors

Check CheckArgs 
NoCheck 

Instances

Eq Check # 

Methods

(==) :: Check -> Check -> Bool #

(/=) :: Check -> Check -> Bool #

Ord Check # 

Methods

compare :: Check -> Check -> Ordering #

(<) :: Check -> Check -> Bool #

(<=) :: Check -> Check -> Bool #

(>) :: Check -> Check -> Bool #

(>=) :: Check -> Check -> Bool #

max :: Check -> Check -> Check #

min :: Check -> Check -> Check #

Show Check # 

Methods

showsPrec :: Int -> Check -> ShowS #

show :: Check -> String #

showList :: [Check] -> ShowS #

type Image = String #

type Tag = String #

data Ports #

Instances

IsList Ports # 

Associated Types

type Item Ports :: * #

Eq Ports # 

Methods

(==) :: Ports -> Ports -> Bool #

(/=) :: Ports -> Ports -> Bool #

Ord Ports # 

Methods

compare :: Ports -> Ports -> Ordering #

(<) :: Ports -> Ports -> Bool #

(<=) :: Ports -> Ports -> Bool #

(>) :: Ports -> Ports -> Bool #

(>=) :: Ports -> Ports -> Bool #

max :: Ports -> Ports -> Ports #

min :: Ports -> Ports -> Ports #

Show Ports # 

Methods

showsPrec :: Int -> Ports -> ShowS #

show :: Ports -> String #

showList :: [Ports] -> ShowS #

type Item Ports # 
type Item Ports = Port

type Arguments = [String] #

type Pairs = [(String, String)] #

Re-exports from parsec

data ParseError :: * #

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.

Instruction and InstructionPos helpers