From aac278212d21f876988861bd8d925e64ea0fadf5 Mon Sep 17 00:00:00 2001 From: JB Trystram Date: Tue, 7 May 2024 18:29:02 +0200 Subject: [PATCH] Add health-check to containers podman 4.9 allow healthcheck to conditionnaly mark the service ready. This will allow for smoother dependencies between the services Taken from https://github.com/immich-app/immich/discussions/6320#discussioncomment-9115741 --- immich-database.container | 6 ++++++ immich-machine-learning.container | 6 ++++++ immich-microservices.container | 9 ++++++++- immich-redis.container | 9 ++++++++- immich-server.container | 6 ++++++ 5 files changed, 34 insertions(+), 2 deletions(-) diff --git a/immich-database.container b/immich-database.container index 9556343..9133f07 100644 --- a/immich-database.container +++ b/immich-database.container @@ -4,6 +4,12 @@ ContainerName=immich_postgres EnvironmentFile=immich.env Image=docker.io/tensorchord/pgvecto-rs:pg14-v0.2.0@sha256:90724186f0a3517cf6914295b5ab410db9ce23190a2d9d0b9dd6463e3fa298f0 Volume=pgdata:/var/lib/postgresql/data +HealthCmd=["/usr/bin/pg_isready"] +HealthStartPeriod=30s +HealthInterval=10s +HealthTimeout=5s +HealthRetries=5 +Notify=healthy [Service] Restart=always diff --git a/immich-machine-learning.container b/immich-machine-learning.container index 8ca601b..b84cfb6 100644 --- a/immich-machine-learning.container +++ b/immich-machine-learning.container @@ -4,6 +4,12 @@ ContainerName=immich_machine_learning EnvironmentFile=immich.env Image=ghcr.io/immich-app/immich-machine-learning:v1.101.0 Volume=model-cache:/cache +HealthCmd='["/bin/bash", "-c", "exec 5<>/dev/tcp/127.0.0.1/3003"]' +HealthStartPeriod=30s +HealthInterval=10s +HealthTimeout=5s +HealthRetries=5 +Notify=healthy [Service] Restart=always diff --git a/immich-microservices.container b/immich-microservices.container index 9db5a18..0a9cce0 100644 --- a/immich-microservices.container +++ b/immich-microservices.container @@ -10,6 +10,13 @@ Exec=start.sh microservices Image=immich-server.image Volume=/home/raid/immich:/usr/src/app/upload:z Volume=/etc/localtime:/etc/localtime:ro +HealthCmd='["/bin/bash", "-c", "exec 5<>/dev/tcp/127.0.0.1/3002"]' +HealthStartPeriod=30s +HealthInterval=10s +HealthTimeout=5s +HealthRetries=5 +Notify=healthy [Service] -Restart=always \ No newline at end of file +Restart=always + diff --git a/immich-redis.container b/immich-redis.container index ca9a2d7..96c7061 100644 --- a/immich-redis.container +++ b/immich-redis.container @@ -2,6 +2,13 @@ Pod=immich.pod ContainerName=immich_redis Image=docker.io/redis:6.2-alpine@sha256:51d6c56749a4243096327e3fb964a48ed92254357108449cb6e23999c37773c5 +HealthCmd='["/usr/local/bin/redis-cli", "ping"]' +HealthStartPeriod=30s +HealthInterval=10s +HealthTimeout=5s +HealthRetries=5 +Notify=healthy [Service] -Restart=always \ No newline at end of file +Restart=always + diff --git a/immich-server.container b/immich-server.container index 500bf1d..5eb7271 100644 --- a/immich-server.container +++ b/immich-server.container @@ -10,6 +10,12 @@ Exec=start.sh immich Image=immich-server.image Volume=/home/raid/immich:/usr/src/app/upload:z Volume=/etc/localtime:/etc/localtime:ro +HealthCmd='["/bin/bash", "-c", "exec 5<>/dev/tcp/127.0.0.1/3001"]' +HealthStartPeriod=30s +HealthInterval=10s +HealthTimeout=30s +HealthRetries=10 +Notify=healthy [Service] Restart=always