Module B0_docker

module B0_docker: sig .. end
B0 support for docker.

Indirect variant schemes for variants that build and run in docker containers.

Docker variant schemes allow to build and test your software on alternate platforms and environments. It also provides you a cheap and easier (albeit slow) form of cross-compilation.

The image of the container used for building needs a copy of the build program (e.g. b0) with the same version in the current PATH.



Variant schemes


type image = string 
The type for specifying docker images.
type image_build 
The type for specifying how to build a docker image.
val variant_scheme : ?loc:B0.Def.loc ->
?doc:string ->
?image_build:image_build ->
image -> B0.Variant.Scheme.t -> B0.Variant.Scheme.t
variant_scheme image s is a variant scheme that compiles the project using scheme s in a docker container image image which is assumed to exist. If it does but image_build is specified, the image will first be created using these instructions.

Low-level functions


type cmd 
A value representing the docker command.
val get : unit -> cmd B0.result
get () looks up a docker binary in the build's program PATH or in the environment variable B0_DOCKER if defined.
val cmd : cmd -> B0.Cmd.t
cmd d is d's docker command.

Images


val image_build : ?opts:B0.Cmd.t -> ?context:string -> B0.Fpath.t -> image_build
build ~opts ~context dockerfile is an image named name build from dockerfile using context (defaults to -) with opts cli arguments added to the docker build command.

FIXME. Need a way to know the root for relative files (Basically B0.Def.Loc.get_sub_root) this need to be part of the API. Also context should not be a string.

val image_create : cmd -> image -> image_build -> unit B0.result
image_create d i b creates (builds) image i with b.
val image_exists : cmd -> image -> bool B0.result
image_exists d img is true iff img exists.
val image_delete : cmd -> image -> unit B0.result
image_delete d img force deletes image img.

Containers


type container = string 
The type for container names.
val container_exists : cmd -> container -> bool B0.result
container_exists d c is true iff container c exists.
val container_create : cmd ->
?workdir:B0.Fpath.t ->
?binds:(B0.Fpath.t * B0.Fpath.t) list ->
image -> container -> unit B0.result
container_create d ~workdir ~binds i c creates a container c in detached mode with image i runs. binds are host to container directory maps and workdir is the working directory of the container.

FIXME we should ensure the volume map is the same.

val container_delete : cmd -> container -> unit B0.result
container_delete d c force deletes container c.
val container_exec : cmd ->
container -> B0.Cmd.t -> B0.OS.Cmd.status B0.result
container_exec d c cmd runs cmd in container c.