diff --git a/compose/v3/defaults.dhall b/compose/v3/defaults.dhall deleted file mode 100644 index a0a717a..0000000 --- a/compose/v3/defaults.dhall +++ /dev/null @@ -1,126 +0,0 @@ -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 - , 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 = Service, Volume = Volume, ComposeConfig = ComposeConfig } diff --git a/compose/v3/types.dhall b/compose/v3/types.dhall index 015d962..fb3b54f 100644 --- a/compose/v3/types.dhall +++ b/compose/v3/types.dhall @@ -1,259 +1,249 @@ -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 - , 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 = - ComposeConfig - , Services = - Services - , Service = - Service - , StringOrNumber = - StringOrNumber - , Deploy = - Deploy - , Build = - Build - , StringOrList = - StringOrList - , ListOrDict = - ListOrDict - , Healthcheck = - Healthcheck - , Labels = - Labels - , Logging = - Logging - , Networks = - Networks - , Ulimits = - Ulimits - , Volumes = - Volumes - , Volume = - Volume - , Options = - Options - , DriverOpts = - DriverOpts - , Ipam = - Ipam - , External = - External - } +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 + , 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 + } + , default = + { deploy = None Deploy + , build = None Build + , cap_add = None (List Text) + , cap_drop = None (List Text) + , cgroup_parent = None Text + , command = None StringOrList + , container_name = None Text + , depends_on = None (List Text) + , devices = None (List Text) + , dns = None StringOrList + , dns_search = None (List Text) + , domainname = None Text + , entrypoint = None StringOrList + , env_file = None StringOrList + , environment = None ListOrDict + , expose = None (List StringOrNumber) + , external_links = None (List Text) + , extra_hosts = None ListOrDict + , healthcheck = None Healthcheck + , hostname = None Text + , image = None Text + , ipc = None Text + , labels = None Labels + , links = None (List Text) + , logging = None Logging + , mac_address = None Text + , network_mode = None Text + , networks = None Networks + , pid = None Text + , ports = None (List StringOrNumber) + , privileged = None Bool + , read_only = None Bool + , restart = None Text + , security_opt = None (List Text) + , shm_size = None StringOrNumber + , sysctls = None ListOrDict + , stdin_open = None Bool + , stop_grace_period = None Text + , stop_signal = None Text + , tmpfs = None StringOrList + , tty = None Bool + , ulimits = None (Map Text Ulimits) + , user = None Text + , userns_mode = None Text + , volumes = None (List Text) + , working_dir = None 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 + } + , default = + { driver = None Text + , driver_opts = None DriverOpts + , ipam = None Ipam + , external = None External + } + } + +let Volumes + : Type + = Map Text Volume.Type + +let Services + : Type + = Map Text Service.Type + +let ComposeConfig = + { Type = + { version : Text + , services : Optional Services + , networks : Optional Networks + , volumes : Optional Volumes + } + , default = + { version = "3" + , services = None Services + , networks = None Networks + , volumes = None Volumes + } + } + +in { ComposeConfig + , Services + , Service + , StringOrNumber + , Deploy + , Build + , StringOrList + , ListOrDict + , Healthcheck + , Labels + , Logging + , Networks + , Ulimits + , Volumes + , Volume + , Options + , DriverOpts + , Ipam + , External + } diff --git a/example/docker-compose-deploy.dhall b/example/docker-compose-deploy.dhall index 8af9f90..8f90924 100644 --- a/example/docker-compose-deploy.dhall +++ b/example/docker-compose-deploy.dhall @@ -1,137 +1,96 @@ -let map = - https://raw.githubusercontent.com/dhall-lang/dhall-lang/master/Prelude/List/map - -let Entry = - https://raw.githubusercontent.com/dhall-lang/dhall-lang/master/Prelude/Map/Entry - -let types = ./compose/v3/types.dhall - -let defaults = ./compose/v3/defaults.dhall - -let logging = - Some - { driver = - "syslog" - , options = - Some - [ { mapKey = - "syslog-address" - , mapValue = - Some - ( types.StringOrNumber.String - "udp://logs.papertrailapp.com:50183" - ) - } - , { mapKey = - "tag" - , mapValue = - Some (types.StringOrNumber.String "{{.Name}}") - } - ] - } - -let nginxService = - defaults.Service - ⫽ { image = - Some "recipeyak/nginx:latest" - , ports = - Some [ types.StringOrNumber.String "80:80" ] - , volumes = - Some - [ "react-static-files:/var/app/dist" - , "django-static-files:/var/app/django/static" - ] - , logging = - logging - , depends_on = - Some [ "django", "react" ] - } - : types.Service - -let djangoService = - defaults.Service - ⫽ { restart = - Some "always" - , image = - Some "recipeyak/django:latest" - , env_file = - Some (types.StringOrList.List [ ".env-production" ]) - , command = - Some (types.StringOrList.String "sh bootstrap-prod.sh") - , volumes = - Some [ "django-static-files:/var/app/static-files" ] - , logging = - logging - , depends_on = - Some [ "db" ] - } - : types.Service - -let dbService = - defaults.Service - ⫽ { image = - Some "postgres:10.1" - , command = - Some - ( types.StringOrList.List - [ "-c" - , "shared_preload_libraries=\"pg_stat_statements\"" - , "-c" - , "pg_stat_statements.max=10000" - , "-c" - , "pg_stat_statements.track=all" - ] - ) - , ports = - Some [ types.StringOrNumber.String "5432:5432" ] - , logging = - logging - , volumes = - Some [ "pgdata:/var/lib/postgresql/data/" ] - } - : types.Service - -let reactService = - defaults.Service - ⫽ { image = - Some "recipeyak/react:latest" - , command = - Some (types.StringOrList.String "sh bootstrap.sh") - , env_file = - Some (types.StringOrList.List [ ".env-production" ]) - , volumes = - Some [ "react-static-files:/var/app/dist" ] - , logging = - logging - } - : types.Service - -let toEntry = - λ(name : Text) - → { mapKey = - name - , mapValue = - Some (defaults.Volume ⫽ { driver = Some "local" }) - } - -let Output : Type = Entry Text (Optional types.Volume) - -let volumes - : types.Volumes - = map - Text - Output - toEntry - [ "pgdata", "django-static-files", "react-static-files" ] - -let services - : types.Services - = [ { mapKey = "nginx", mapValue = nginxService } - , { mapKey = "db", mapValue = dbService } - , { mapKey = "react", mapValue = reactService } - , { mapKey = "django", mapValue = djangoService } - ] - -in defaults.ComposeConfig - ⫽ { services = Some services, volumes = Some volumes } - : types.ComposeConfig +let map = + https://raw.githubusercontent.com/dhall-lang/dhall-lang/master/Prelude/List/map + +let Entry = + https://raw.githubusercontent.com/dhall-lang/dhall-lang/master/Prelude/Map/Entry + +let types = ./compose/v3/types.dhall + +let logging = + Some + { driver = "syslog" + , options = Some + [ { mapKey = "syslog-address" + , mapValue = Some + ( types.StringOrNumber.String + "udp://logs.papertrailapp.com:50183" + ) + } + , { mapKey = "tag" + , mapValue = Some (types.StringOrNumber.String "{{.Name}}") + } + ] + } + +let nginxService = + types.Service::{ + , image = Some "recipeyak/nginx:latest" + , ports = Some [ types.StringOrNumber.String "80:80" ] + , volumes = Some + [ "react-static-files:/var/app/dist" + , "django-static-files:/var/app/django/static" + ] + , logging + , depends_on = Some [ "django", "react" ] + } + +let djangoService = + types.Service::{ + , restart = Some "always" + , image = Some "recipeyak/django:latest" + , env_file = Some (types.StringOrList.List [ ".env-production" ]) + , command = Some (types.StringOrList.String "sh bootstrap-prod.sh") + , volumes = Some [ "django-static-files:/var/app/static-files" ] + , logging + , depends_on = Some [ "db" ] + } + +let dbService = + types.Service::{ + , image = Some "postgres:10.1" + , command = Some + ( types.StringOrList.List + [ "-c" + , "shared_preload_libraries=\"pg_stat_statements\"" + , "-c" + , "pg_stat_statements.max=10000" + , "-c" + , "pg_stat_statements.track=all" + ] + ) + , ports = Some [ types.StringOrNumber.String "5432:5432" ] + , logging + , volumes = Some [ "pgdata:/var/lib/postgresql/data/" ] + } + +let reactService = + types.Service::{ + , image = Some "recipeyak/react:latest" + , command = Some (types.StringOrList.String "sh bootstrap.sh") + , env_file = Some (types.StringOrList.List [ ".env-production" ]) + , volumes = Some [ "react-static-files:/var/app/dist" ] + , logging + } + +let volumes = + Some + [ { mapKey = "pgdata" + , mapValue = types.Volume::{ driver = Some "local" } + } + , { mapKey = "django-static-files" + , mapValue = types.Volume::{ driver = Some "local" } + } + , { mapKey = "react-static-files" + , mapValue = types.Volume::{ driver = Some "local" } + } + ] + +let services = + Some + [ { mapKey = "nginx", mapValue = nginxService } + , { mapKey = "db", mapValue = dbService } + , { mapKey = "react", mapValue = reactService } + , { mapKey = "django", mapValue = djangoService } + ] + +in types.ComposeConfig::{ volumes, services } diff --git a/example/docker-compose-deploy.yml b/example/docker-compose-deploy.yml index 1a03dae..7c02b36 100644 --- a/example/docker-compose-deploy.yml +++ b/example/docker-compose-deploy.yml @@ -1,69 +1,69 @@ -version: '3' -volumes: - django-static-files: - driver: local - pgdata: - driver: local - react-static-files: - driver: local services: - nginx: - image: recipeyak/nginx:latest - ports: - - 80:80 - volumes: - - react-static-files:/var/app/dist - - django-static-files:/var/app/django/static - depends_on: - - django - - react + db: + command: + - "-c" + - "shared_preload_libraries=\"pg_stat_statements\"" + - "-c" + - pg_stat_statements.max=10000 + - "-c" + - pg_stat_statements.track=all + image: postgres:10.1 logging: driver: syslog options: - tag: '{{.Name}}' syslog-address: udp://logs.papertrailapp.com:50183 - react: - env_file: - - .env-production - image: recipeyak/react:latest - command: sh bootstrap.sh + tag: "{{.Name}}" + ports: + - "5432:5432" volumes: - - react-static-files:/var/app/dist + - pgdata:/var/lib/postgresql/data/ + django: + command: sh bootstrap-prod.sh + depends_on: + - db + env_file: + - ".env-production" + image: recipeyak/django:latest logging: driver: syslog options: - tag: '{{.Name}}' syslog-address: udp://logs.papertrailapp.com:50183 - db: - image: postgres:10.1 - command: - - -c - - shared_preload_libraries="pg_stat_statements" - - -c - - pg_stat_statements.max=10000 - - -c - - pg_stat_statements.track=all - ports: - - 5432:5432 + tag: "{{.Name}}" + restart: always volumes: - - pgdata:/var/lib/postgresql/data/ + - django-static-files:/var/app/static-files + nginx: + depends_on: + - django + - react + image: recipeyak/nginx:latest logging: driver: syslog options: - tag: '{{.Name}}' syslog-address: udp://logs.papertrailapp.com:50183 - django: - env_file: - - .env-production - image: recipeyak/django:latest - command: sh bootstrap-prod.sh - restart: always + tag: "{{.Name}}" + ports: + - "80:80" volumes: - - django-static-files:/var/app/static-files - depends_on: - - db + - react-static-files:/var/app/dist + - django-static-files:/var/app/django/static + react: + command: sh bootstrap.sh + env_file: + - ".env-production" + image: recipeyak/react:latest logging: driver: syslog options: - tag: '{{.Name}}' syslog-address: udp://logs.papertrailapp.com:50183 + tag: "{{.Name}}" + volumes: + - react-static-files:/var/app/dist +version: '3' +volumes: + django-static-files: + driver: local + pgdata: + driver: local + react-static-files: + driver: local