Last active
August 11, 2022 09:47
-
-
Save Akanoa/d8b1fa516331886f04de6266fc403813 to your computer and use it in GitHub Desktop.
Dhall Docker-Compose DSL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let Map = | |
https://raw.githubusercontent.com/dhall-lang/dhall-lang/master/Prelude/Map/Type | |
let types = ./types.dhall | |
let Service = | |
{ deploy = None types.Deploy | |
, build = None types.Build | |
, cap_add = None (List Text) | |
, cap_drop = None (List Text) | |
, cgroup_parent = None Text | |
, command = None types.StringOrList | |
, container_name = None Text | |
, depends_on = None (List Text) | |
, devices = None (List Text) | |
, dns = None types.StringOrList | |
, dns_search = None (List Text) | |
, domainname = None Text | |
, entrypoint = None types.StringOrList | |
, env_file = None types.StringOrList | |
, environment = None types.ListOrDict | |
, expose = None (List types.StringOrNumber) | |
, external_links = None (List Text) | |
, extra_hosts = None types.ListOrDict | |
, healthcheck = None types.Healthcheck | |
, hostname = None Text | |
, image = None Text | |
, ipc = None Text | |
, labels = None types.Labels | |
, links = None (List Text) | |
, logging = None types.Logging | |
, mac_address = None Text | |
, network_mode = None Text | |
, networks = None types.Networks | |
, pid = None Text | |
, profiles = None (List Text) | |
, ports = None (List types.StringOrNumber) | |
, privileged = None Bool | |
, read_only = None Bool | |
, restart = None Text | |
, security_opt = None (List Text) | |
, shm_size = None types.StringOrNumber | |
, sysctls = None types.ListOrDict | |
, stdin_open = None Bool | |
, stop_grace_period = None Text | |
, stop_signal = None Text | |
, tmpfs = None types.StringOrList | |
, tty = None Bool | |
, ulimits = None (Map Text types.Ulimits) | |
, user = None Text | |
, userns_mode = None Text | |
, volumes = None (List Text) | |
, working_dir = None Text | |
} | |
: types.Service | |
let Volume = | |
{ driver = None Text | |
, driver_opts = None types.DriverOpts | |
, ipam = None types.Ipam | |
, external = None types.External | |
} | |
: types.Volume | |
let ComposeConfig = | |
{ version = "3" | |
, services = None types.Services | |
, networks = None types.Networks | |
, volumes = None types.Volumes | |
} | |
: types.ComposeConfig | |
in { Service, Volume, ComposeConfig } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let Map = | |
https://raw.githubusercontent.com/dhall-lang/dhall-lang/master/Prelude/Map/Type | |
let StringOrNumber | |
: Type | |
= < String : Text | Number : Natural > | |
let ListOrDict | |
: Type | |
= < Dict : Map Text Text | List : List (Optional StringOrNumber) > | |
let Build | |
: Type | |
= < String : Text | |
| Object : { context : Text, dockerfile : Text, args : ListOrDict } | |
> | |
let StringOrList | |
: Type | |
= < String : Text | List : List Text > | |
let Healthcheck | |
: Type | |
= { disable : Bool | |
, interval : Text | |
, retries : Natural | |
, test : StringOrList | |
, timeout : Text | |
} | |
let Labels | |
: Type | |
= < Object : Map Text Text | List : List Text > | |
let Options | |
: Type | |
= Map Text (Optional StringOrNumber) | |
let Logging | |
: Type | |
= { driver : Text, options : Optional Options } | |
let Networks | |
: Type | |
= < List : List Text | |
| Object : | |
Optional | |
{ aliases : List Text, ipv4_address : Text, ipv6_address : Text } | |
> | |
let Ulimits | |
: Type | |
= < Int : Natural | Object : { hard : Natural, soft : Natural } > | |
let Resource | |
: Type | |
= { cpus : Text, memory : Text } | |
let Deploy | |
: Type | |
= { mode : Text | |
, replicas : Natural | |
, labels : Labels | |
, update_config : | |
{ parallelism : Natural | |
, delay : Text | |
, failure_action : Text | |
, monitor : Text | |
, max_failure_ratio : Natural | |
} | |
, resources : { limits : Resource, reservations : Resource } | |
, restartPolicy : | |
{ condition : Text | |
, delay : Text | |
, maxAttempts : Natural | |
, window : Text | |
} | |
, placement : { constraints : List Text } | |
} | |
let Service | |
: Type | |
= { deploy : Optional Deploy | |
, build : Optional Build | |
, cap_add : Optional (List Text) | |
, cap_drop : Optional (List Text) | |
, cgroup_parent : Optional Text | |
, command : Optional StringOrList | |
, container_name : Optional Text | |
, depends_on : Optional (List Text) | |
, devices : Optional (List Text) | |
, dns : Optional StringOrList | |
, dns_search : Optional (List Text) | |
, domainname : Optional Text | |
, entrypoint : Optional StringOrList | |
, env_file : Optional StringOrList | |
, environment : Optional ListOrDict | |
, expose : Optional (List StringOrNumber) | |
, external_links : Optional (List Text) | |
, extra_hosts : Optional ListOrDict | |
, healthcheck : Optional Healthcheck | |
, hostname : Optional Text | |
, image : Optional Text | |
, ipc : Optional Text | |
, labels : Optional Labels | |
, links : Optional (List Text) | |
, logging : Optional Logging | |
, mac_address : Optional Text | |
, network_mode : Optional Text | |
, networks : Optional Networks | |
, pid : Optional Text | |
, profiles: Optional (List Text) | |
, ports : Optional (List StringOrNumber) | |
, privileged : Optional Bool | |
, read_only : Optional Bool | |
, restart : Optional Text | |
, security_opt : Optional (List Text) | |
, shm_size : Optional StringOrNumber | |
, sysctls : Optional ListOrDict | |
, stdin_open : Optional Bool | |
, stop_grace_period : Optional Text | |
, stop_signal : Optional Text | |
, tmpfs : Optional StringOrList | |
, tty : Optional Bool | |
, ulimits : Optional (Map Text Ulimits) | |
, user : Optional Text | |
, userns_mode : Optional Text | |
, volumes : Optional (List Text) | |
, working_dir : Optional Text | |
} | |
let DriverOpts | |
: Type | |
= Map Text StringOrNumber | |
let Ipam | |
: Type | |
= { driver : Text, config : List { subnet : Text } } | |
let External | |
: Type | |
= < Bool : Bool | Object : { name : Text } > | |
let Volume | |
: Type | |
= { driver : Optional Text | |
, driver_opts : Optional DriverOpts | |
, ipam : Optional Ipam | |
, external : Optional External | |
} | |
let Volumes | |
: Type | |
= Map Text (Optional Volume) | |
let Services | |
: Type | |
= Map Text Service | |
let ComposeConfig | |
: Type | |
= { version : Text | |
, services : Optional Services | |
, networks : Optional Networks | |
, volumes : Optional Volumes | |
} | |
in { ComposeConfig | |
, Services | |
, Service | |
, StringOrNumber | |
, Deploy | |
, Build | |
, StringOrList | |
, ListOrDict | |
, Healthcheck | |
, Labels | |
, Logging | |
, Networks | |
, Ulimits | |
, Volumes | |
, Volume | |
, Options | |
, DriverOpts | |
, Ipam | |
, External | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment