Add service.healthcheck and extend service.depends_on

This commit is contained in:
t4ccer 2022-04-26 18:19:56 -06:00
parent cd962c840e
commit ec8ef96d52
No known key found for this signature in database
GPG key ID: 19E5A2D8B1E43F19
3 changed files with 120 additions and 2 deletions

View file

@ -1,5 +1,15 @@
# Revision history for Arion
## Next
### Changed
* Healthcheck-based dependencies in `service.depends_on`.
### Added
* Support `service.healthcheck` for defining custom healthchecks.
## 0.1.3.0 -- 2020-05-03
### Changed

View file

@ -514,7 +514,7 @@ See link:https://docs.docker.com/compose/compose-file/#depends_on[Docker Compose
[discrete]
=== details
Type:: list of strings
Type:: list of strings or attribute set of attribute set of stringss
Default::
+
----
@ -668,6 +668,89 @@ Default::
No Example:: {blank}
== services.<name>.service.healthcheck.interval
See link:https://docs.docker.com/compose/compose-file/#healthcheck[Docker Compose#healthcheck]
[discrete]
=== details
Type:: string
Default::
+
----
"30s"
----
Example::
+
----
"1m"
----
== services.<name>.service.healthcheck.retries
See link:https://docs.docker.com/compose/compose-file/#healthcheck[Docker Compose#healthcheck]
[discrete]
=== details
Type:: signed integer
Default::
+
----
3
----
No Example:: {blank}
== services.<name>.service.healthcheck.test
See link:https://docs.docker.com/compose/compose-file/#healthcheck[Docker Compose#healthcheck]
[discrete]
=== details
Type:: null or list of strings
Default::
+
----
null
----
Example::
+
----
["CMD","pg_isready"]
----
== services.<name>.service.healthcheck.timeout
See link:https://docs.docker.com/compose/compose-file/#healthcheck[Docker Compose#healthcheck]
[discrete]
=== details
Type:: string
Default::
+
----
"30s"
----
Example::
+
----
"10s"
----
== services.<name>.service.hostStoreAsReadOnly
Adds a ':ro' (read-only) access mode to the host nix store bind mount.

View file

@ -101,10 +101,33 @@ in
description = dockerComposeRef "container_name";
};
service.depends_on = mkOption {
type = listOf str;
type = either (listOf str) (attrsOf (attrsOf str));
default = [];
description = dockerComposeRef "depends_on";
};
service.healthcheck.test = mkOption {
type = nullOr (listOf str);
default = null;
example = [ "CMD" "pg_isready" ];
description = dockerComposeRef "healthcheck";
};
service.healthcheck.interval = mkOption {
type = str;
default = "30s";
example = "1m";
description = dockerComposeRef "healthcheck";
};
service.healthcheck.timeout = mkOption {
type = str;
default = "30s";
example = "10s";
description = dockerComposeRef "healthcheck";
};
service.healthcheck.retries = mkOption {
type = int;
default = 3;
description = dockerComposeRef "healthcheck";
};
service.devices = mkOption {
type = listOf str;
default = [];
@ -250,6 +273,8 @@ in
inherit (config.service) container_name;
} // lib.optionalAttrs (config.service.depends_on != []) {
inherit (config.service) depends_on;
} // lib.optionalAttrs (config.service.healthcheck.test != null) {
inherit (config.service) healthcheck;
} // lib.optionalAttrs (config.service.devices != []) {
inherit (config.service) devices;
} // lib.optionalAttrs (config.service.entrypoint != null) {