Skip to content

Commit b96c822

Browse files
authored
Merge pull request #6 from mlabs-haskell/t4/healthcheck
2 parents a414df7 + b54dd1a commit b96c822

File tree

4 files changed

+108
-15
lines changed

4 files changed

+108
-15
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
## Prerequisites
2323

2424
- nix
25-
- [arion](https://docs.hercules-ci.com/arion/#_installation)
25+
- arion - Use patched one from `nix develop`!
2626
- [nami wallet](https://namiwallet.io/) installed as browser extension
2727
- Funds in wallet obtained from [faucet](https://testnets.cardano.org/en/testnets/cardano/tools/faucet/)
2828

arion-compose.nix

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,35 @@ in {
1212
# ports = [ "host:container" ]
1313
config.services = {
1414
nft-marketplace.service = {
15-
depends_on =
16-
[ "cardano-transaction-lib-server" "nft-marketplace-server" ];
15+
depends_on = {
16+
nft-marketplace-server.condition = "service_healthy";
17+
ogmios.condition = "service_healthy";
18+
# TODO: Change to `service_healthy` when healthcheck endpoints are implemented
19+
cardano-transaction-lib-server.condition = "service_started";
20+
ogmios-datum-cache.condition = "service_started";
21+
};
1722
image = "nginx:1.20.2-alpine";
1823
ports = [ "8080:80" ];
1924
volumes = [
2025
"${toString ./.}/nft-marketplace/build:/usr/share/nginx/html"
2126
"${toString ./.}/config/nginx.conf:/etc/nginx/nginx.conf"
2227
];
28+
healthcheck = {
29+
test = [
30+
"CMD"
31+
"${pkgs.curl}/bin/curl"
32+
"--location"
33+
"--request"
34+
"GET"
35+
"nft-marketplace"
36+
"-i"
37+
"--fail"
38+
];
39+
interval = "5s";
40+
timeout = "5s";
41+
retries = 3;
42+
};
43+
useHostStore = true;
2344
};
2445
cardano-transaction-lib-server.service = {
2546
command =
@@ -36,18 +57,20 @@ in {
3657
"--node-config"
3758
"/config/testnet-config.json"
3859
];
39-
depends_on = [ "cardano-node" ];
60+
depends_on = { cardano-node.condition = "service_healthy"; };
4061
image = "cardanosolutions/ogmios:v5.2.0-testnet";
4162
ports = [ "1337:1337" ];
4263
volumes = [
4364
"${toString ./.}/data/cardano-node/ipc:/ipc"
4465
"${toString ./.}/config:/config"
4566
];
46-
4767
};
4868
ogmios-datum-cache.service = {
4969
command = [ "${ogmios-datum-cache}/bin/ogmios-datum-cache" ];
50-
depends_on = [ "ogmios" "postgresql-db" "nft-marketplace-server" ];
70+
depends_on = {
71+
ogmios.condition = "service_healthy";
72+
postgresql-db.condition = "service_healthy";
73+
};
5174
ports = [ "9999:9999" ];
5275
useHostStore = true;
5376
volumes = [
@@ -63,6 +86,16 @@ in {
6386
"${toString ./.}/data/cardano-node/ipc:/ipc"
6487
"${toString ./.}/data/cardano-node/cardano-node-data:/data"
6588
];
89+
healthcheck = {
90+
test = [
91+
"CMD-SHELL"
92+
"CARDANO_NODE_SOCKET_PATH=/ipc/node.socket /bin/cardano-cli query tip --testnet-magic 1097911063"
93+
];
94+
interval = "10s";
95+
timeout = "5s";
96+
start_period = "15m";
97+
retries = 3;
98+
};
6699
};
67100
postgresql-db.service = {
68101
command = [ "-c" "stats_temp_directory=/tmp" ];
@@ -73,6 +106,12 @@ in {
73106
};
74107
image = "postgres:14";
75108
ports = [ "5432:5432" ];
109+
healthcheck = {
110+
test = [ "CMD" "pg_isready" "-U" "seabug" ];
111+
interval = "5s";
112+
timeout = "5s";
113+
retries = 3;
114+
};
76115
volumes =
77116
[ "${toString ./.}/data/postgres-data:/var/lib/postgresql/data" ];
78117
};
@@ -84,8 +123,23 @@ in {
84123
"--nft-storage-key"
85124
"NFT_STORAGE_KEY_HERE"
86125
];
87-
depends_on = [ "postgresql-db" ];
126+
depends_on = { postgresql-db.condition = "service_healthy"; };
88127
ports = [ "8008:9999" ];
128+
healthcheck = {
129+
test = [
130+
"CMD"
131+
"${pkgs.curl}/bin/curl"
132+
"--location"
133+
"--request"
134+
"GET"
135+
"nft-marketplace-server:9999/healthz"
136+
"-i"
137+
"--fail"
138+
];
139+
interval = "5s";
140+
timeout = "5s";
141+
retries = 3;
142+
};
89143
useHostStore = true;
90144
restart = "always";
91145
volumes = [ "${toString ./.}/config/tmp:/tmp" ];

flake.lock

Lines changed: 41 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@
77
"github:input-output-hk/cardano-node/73f9a746362695dc2cb63ba757fbcabb81733d23";
88
};
99
flake-utils = { url = "github:numtide/flake-utils"; };
10+
# https://github.com/hercules-ci/arion/pull/153
11+
arion = {
12+
url = "github:t4ccer/arion/69b9109dea2b4d48f35c614456463bd0234e2e80";
13+
};
1014
};
11-
outputs = { self, nixpkgs, cardano-node, flake-utils }:
15+
outputs = { self, nixpkgs, cardano-node, flake-utils, arion }:
1216
flake-utils.lib.eachDefaultSystem (system:
1317
let pkgs = nixpkgs.legacyPackages.${system};
1418
in rec {
@@ -19,6 +23,7 @@
1923
curl
2024
ipfs
2125
cardano-node.packages.${system}.cardano-cli
26+
arion.packages.${system}.arion
2227
];
2328
};
2429
});

0 commit comments

Comments
 (0)