|
12 | 12 | # ports = [ "host:container" ] |
13 | 13 | config.services = { |
14 | 14 | 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 | + }; |
17 | 22 | image = "nginx:1.20.2-alpine"; |
18 | 23 | ports = [ "8080:80" ]; |
19 | 24 | volumes = [ |
20 | 25 | "${toString ./.}/nft-marketplace/build:/usr/share/nginx/html" |
21 | 26 | "${toString ./.}/config/nginx.conf:/etc/nginx/nginx.conf" |
22 | 27 | ]; |
| 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; |
23 | 44 | }; |
24 | 45 | cardano-transaction-lib-server.service = { |
25 | 46 | command = |
|
36 | 57 | "--node-config" |
37 | 58 | "/config/testnet-config.json" |
38 | 59 | ]; |
39 | | - depends_on = [ "cardano-node" ]; |
| 60 | + depends_on = { cardano-node.condition = "service_healthy"; }; |
40 | 61 | image = "cardanosolutions/ogmios:v5.2.0-testnet"; |
41 | 62 | ports = [ "1337:1337" ]; |
42 | 63 | volumes = [ |
43 | 64 | "${toString ./.}/data/cardano-node/ipc:/ipc" |
44 | 65 | "${toString ./.}/config:/config" |
45 | 66 | ]; |
46 | | - |
47 | 67 | }; |
48 | 68 | ogmios-datum-cache.service = { |
49 | 69 | 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 | + }; |
51 | 74 | ports = [ "9999:9999" ]; |
52 | 75 | useHostStore = true; |
53 | 76 | volumes = [ |
|
63 | 86 | "${toString ./.}/data/cardano-node/ipc:/ipc" |
64 | 87 | "${toString ./.}/data/cardano-node/cardano-node-data:/data" |
65 | 88 | ]; |
| 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 | + }; |
66 | 99 | }; |
67 | 100 | postgresql-db.service = { |
68 | 101 | command = [ "-c" "stats_temp_directory=/tmp" ]; |
|
73 | 106 | }; |
74 | 107 | image = "postgres:14"; |
75 | 108 | ports = [ "5432:5432" ]; |
| 109 | + healthcheck = { |
| 110 | + test = [ "CMD" "pg_isready" "-U" "seabug" ]; |
| 111 | + interval = "5s"; |
| 112 | + timeout = "5s"; |
| 113 | + retries = 3; |
| 114 | + }; |
76 | 115 | volumes = |
77 | 116 | [ "${toString ./.}/data/postgres-data:/var/lib/postgresql/data" ]; |
78 | 117 | }; |
|
84 | 123 | "--nft-storage-key" |
85 | 124 | "NFT_STORAGE_KEY_HERE" |
86 | 125 | ]; |
87 | | - depends_on = [ "postgresql-db" ]; |
| 126 | + depends_on = { postgresql-db.condition = "service_healthy"; }; |
88 | 127 | 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 | + }; |
89 | 143 | useHostStore = true; |
90 | 144 | restart = "always"; |
91 | 145 | volumes = [ "${toString ./.}/config/tmp:/tmp" ]; |
|
0 commit comments