From 9989c1b1996e29decb69c11caf24dfb3b48498dd Mon Sep 17 00:00:00 2001 From: Mohamed Marrouchi Date: Fri, 13 Sep 2024 11:07:41 +0100 Subject: [PATCH] fix: nginx autoreload --- docker/docker-compose.nginx.prod.yml | 2 +- docker/nginx/99-autoreload.sh | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 docker/nginx/99-autoreload.sh diff --git a/docker/docker-compose.nginx.prod.yml b/docker/docker-compose.nginx.prod.yml index aa158bf..aafa659 100644 --- a/docker/docker-compose.nginx.prod.yml +++ b/docker/docker-compose.nginx.prod.yml @@ -8,7 +8,7 @@ services: - /etc/localtime:/etc/localtime:ro - ./nginx/certbot/conf:/etc/letsencrypt - ./nginx/certbot/www:/var/www/certbot - command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'" + - ./nginx/99-autoreload.sh:/docker-entrypoint.d/99-autoreload.sh certbot: image: certbot/certbot diff --git a/docker/nginx/99-autoreload.sh b/docker/nginx/99-autoreload.sh new file mode 100644 index 0000000..2f3aed9 --- /dev/null +++ b/docker/nginx/99-autoreload.sh @@ -0,0 +1,6 @@ +#!/bin/sh +while :; do + # Optional: Instead of sleep, detect config changes and only reload if necessary. + sleep 6h + nginx -t && nginx -s reload +done &