Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- toDockerfileText :: EDockerfileM a -> Text
- toDockerfile :: EDockerfileM a -> Dockerfile
- putDockerfileStr :: EDockerfileM a -> IO ()
- writeDockerFile :: Text -> Dockerfile -> IO ()
- toDockerfileTextIO :: MonadIO m => EDockerfileTM m t -> m Text
- toDockerfileIO :: MonadIO m => EDockerfileTM m t -> m Dockerfile
- runDockerfileIO :: MonadIO m => EDockerfileTM m t -> m (t, Dockerfile)
- runDockerfileTextIO :: MonadIO m => EDockerfileTM m t -> m (t, Text)
- liftIO :: MonadIO m => IO a -> m a
- from :: forall m. MonadFree EInstruction m => EBaseImage -> m ()
- tagged :: Image -> Tag -> EBaseImage
- untagged :: Text -> EBaseImage
- digested :: EBaseImage -> Digest -> EBaseImage
- aliased :: EBaseImage -> ImageAlias -> EBaseImage
- add :: MonadFree EInstruction m => NonEmpty SourcePath -> TargetPath -> m ()
- user :: forall m. MonadFree EInstruction m => Text -> m ()
- label :: forall m. MonadFree EInstruction m => Pairs -> m ()
- stopSignal :: forall m. MonadFree EInstruction m => Text -> m ()
- copy :: MonadFree EInstruction m => CopyArgs -> m ()
- copyFromStage :: MonadFree EInstruction m => CopySource -> NonEmpty SourcePath -> TargetPath -> m ()
- to :: NonEmpty SourcePath -> TargetPath -> CopyArgs
- fromStage :: CopyArgs -> CopySource -> CopyArgs
- ownedBy :: CopyArgs -> Chown -> CopyArgs
- toSources :: NonEmpty Text -> NonEmpty SourcePath
- toTarget :: Text -> TargetPath
- run :: MonadFree EInstruction m => Arguments Text -> m ()
- runArgs :: forall m. MonadFree EInstruction m => Arguments Text -> RunFlags -> m ()
- cmd :: MonadFree EInstruction m => Arguments Text -> m ()
- cmdArgs :: forall m. MonadFree EInstruction m => Arguments Text -> m ()
- healthcheck :: forall m. MonadFree EInstruction m => Check Text -> m ()
- check :: Arguments args -> Check args
- interval :: Check args -> Integer -> Check args
- timeout :: Check args -> Integer -> Check args
- startPeriod :: Check args -> Integer -> Check args
- retries :: Check args -> Integer -> Check args
- workdir :: forall m. MonadFree EInstruction m => Directory -> m ()
- expose :: forall m. MonadFree EInstruction m => Ports -> m ()
- ports :: [Port] -> Ports
- tcpPort :: Int -> Port
- udpPort :: Int -> Port
- variablePort :: Text -> Port
- portRange :: Int -> Int -> Port
- udpPortRange :: Int -> Int -> Port
- volume :: forall m. MonadFree EInstruction m => Text -> m ()
- entrypoint :: MonadFree EInstruction m => Arguments Text -> m ()
- entrypointArgs :: forall m. MonadFree EInstruction m => Arguments Text -> m ()
- maintainer :: forall m. MonadFree EInstruction m => Text -> m ()
- env :: forall m. MonadFree EInstruction m => Pairs -> m ()
- arg :: forall m. MonadFree EInstruction m => Text -> Maybe Text -> m ()
- comment :: forall m. MonadFree EInstruction m => Text -> m ()
- onBuild :: MonadFree EInstruction m => EDockerfileM a -> m ()
- onBuildRaw :: forall m. MonadFree EInstruction m => Instruction Text -> m ()
- embed :: forall m. MonadFree EInstruction m => [InstructionPos Text] -> m ()
- edockerfile :: QuasiQuoter
- type EDockerfileM = Free EInstruction
- type EDockerfileTM = FreeT EInstruction
- data EBaseImage = EBaseImage Image (Maybe Tag) (Maybe Digest) (Maybe ImageAlias) (Maybe Platform)
- dockerfile :: QuasiQuoter
- instructionPos :: Instruction args -> InstructionPos args
Writting Dockerfiles (Language.Docker.EDSL
)
toDockerfileText :: EDockerfileM a -> Text Source #
runs the Dockerfile EDSL and returns a Lazy
using
PrettyPrint
import Language.Docker main :: IO () main = print $ toDockerfileText $ do from (tagged "fpco/stack-build" "lts-6.9") add ["."] "applanguage-docker" workdir "applanguage-docker" run "stack build --test --only-dependencies" cmd "stack test"
toDockerfile :: EDockerfileM a -> Dockerfile Source #
Runs the Dockerfile EDSL and returns a Dockerfile
you can pretty print
or manipulate
putDockerfileStr :: EDockerfileM a -> IO () Source #
Prints the dockerfile to stdout. Mainly used for debugging purposes
import Language.Docker main :: IO () main = putDockerfileStr $ do from (tagged "fpco/stack-build" "lts-6.9") add ["."] "applanguage-docker" workdir "applanguage-docker" run "stack build --test --only-dependencies" cmd "stack test"
writeDockerFile :: Text -> Dockerfile -> IO () Source #
Writes the dockerfile to the given file path after pretty-printing it
import Language.Docker main :: IO () main = writeDockerFile "build.Dockerfile" $ toDockerfile $ do from (tagged "fpco/stack-build" "lts-6.9") add ["."] "applanguage-docker" workdir "applanguage-docker" run "stack build --test --only-dependencies" cmd "stack test"
toDockerfileTextIO :: MonadIO m => EDockerfileTM m t -> m Text Source #
A version of toDockerfileText
which allows IO actions
toDockerfileIO :: MonadIO m => EDockerfileTM m t -> m Dockerfile Source #
A version of toDockerfile
which allows IO actions
runDockerfileIO :: MonadIO m => EDockerfileTM m t -> m (t, Dockerfile) Source #
Just runs the EDSL's writer monad
runDockerfileTextIO :: MonadIO m => EDockerfileTM m t -> m (t, Text) Source #
Runs the EDSL's writer monad and pretty-prints the result
from :: forall m. MonadFree EInstruction m => EBaseImage -> m () Source #
Constructing base images
tagged :: Image -> Tag -> EBaseImage Source #
Use a specific tag for a docker image. This function is meant to be used as an infix operator.
from $ "fpco/stack-build" tagged
"lts-10.3"
untagged :: Text -> EBaseImage Source #
Use a docker image in a FROM instruction without a tag
The following two examples are equivalent
from $ untagged "fpco/stack-build"
Is equivalent to, when having OverloadedStrings:
from "fpco/stack-build"
digested :: EBaseImage -> Digest -> EBaseImage Source #
Adds a digest checksum so a FROM instruction This function is meant to be used as an infix operator.
from $ "fpco/stack-build" digested
"sha256:abcdef123"
aliased :: EBaseImage -> ImageAlias -> EBaseImage Source #
Alias a FROM instruction to be used as a build stage. This function is meant to be used as an infix operator.
from $ "fpco/stack-build" aliased
"builder"
Syntax
add :: MonadFree EInstruction m => NonEmpty SourcePath -> TargetPath -> m () Source #
Create an ADD instruction. This is often used as a shorthand version
of copy when no extra options are needed. Currently there is no way to
pass extra options to ADD, so you are encouraged to use copy
instead.
add ["foo.js", "bar.js"] "."
stopSignal :: forall m. MonadFree EInstruction m => Text -> m () Source #
copyFromStage :: MonadFree EInstruction m => CopySource -> NonEmpty SourcePath -> TargetPath -> m () Source #
Create a COPY instruction from a given build stage.
This is a shorthand version of using copy
with combinators.
copyFromStage "builder" ["foo.js", "bar.js"] "."
to :: NonEmpty SourcePath -> TargetPath -> CopyArgs Source #
toSources :: NonEmpty Text -> NonEmpty SourcePath Source #
Converts a NonEmpty list of strings to a NonEmpty list of SourcePath
This is a convenience function when you need to pass a non-static list of
strings that you build somewhere as an argument for copy
or add
someFiles <- glob "*.js"
copy $ (toSources someFiles) to
"."
toTarget :: Text -> TargetPath Source #
Converts a Text into a TargetPath
This is a convenience function when you need to pass a string variable
as an argument for copy
or add
let destination = buildSomePath pwd add ["foo.js"] (toTarget destination)
run :: MonadFree EInstruction m => Arguments Text -> m () Source #
Create a RUN instruction with the given arguments.
run "apt-get install wget"
cmd :: MonadFree EInstruction m => Arguments Text -> m () Source #
Create a CMD instruction with the given arguments.
cmd "my-program --some-flag"
variablePort :: Text -> Port Source #
entrypoint :: MonadFree EInstruction m => Arguments Text -> m () Source #
Create an ENTRYPOINT instruction with the given arguments.
entrypoint "usrlocalbinprogram --some-flag"
maintainer :: forall m. MonadFree EInstruction m => Text -> m () Source #
onBuild :: MonadFree EInstruction m => EDockerfileM a -> m () Source #
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 Text -> m () Source #
edockerfile :: QuasiQuoter Source #
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 Source #
The type of Identity
based EDSL blocks
type EDockerfileTM = FreeT EInstruction Source #
The type of free monad EDSL blocks
data EBaseImage Source #
EBaseImage Image (Maybe Tag) (Maybe Digest) (Maybe ImageAlias) (Maybe Platform) |
Instances
Eq EBaseImage Source # | |
Defined in Language.Docker.EDSL.Types (==) :: EBaseImage -> EBaseImage -> Bool # (/=) :: EBaseImage -> EBaseImage -> Bool # | |
Ord EBaseImage Source # | |
Defined in Language.Docker.EDSL.Types compare :: EBaseImage -> EBaseImage -> Ordering # (<) :: EBaseImage -> EBaseImage -> Bool # (<=) :: EBaseImage -> EBaseImage -> Bool # (>) :: EBaseImage -> EBaseImage -> Bool # (>=) :: EBaseImage -> EBaseImage -> Bool # max :: EBaseImage -> EBaseImage -> EBaseImage # min :: EBaseImage -> EBaseImage -> EBaseImage # | |
Show EBaseImage Source # | |
Defined in Language.Docker.EDSL.Types showsPrec :: Int -> EBaseImage -> ShowS # show :: EBaseImage -> String # showList :: [EBaseImage] -> ShowS # | |
IsString EBaseImage Source # | |
Defined in Language.Docker.EDSL.Types fromString :: String -> EBaseImage # |
QuasiQuoter (Language.Docker.EDSL.Quasi
)
Instruction and InstructionPos helpers
instructionPos :: Instruction args -> InstructionPos args Source #