-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add certificate renewal script and update Docker setup
- Loading branch information
Showing
3 changed files
with
34 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,18 +66,8 @@ services: | |
environment: | ||
- DOMAIN=example.com | ||
- [email protected] | ||
entrypoint: ["/bin/sh", "-c"] | ||
command: | ||
- | | ||
while true; do | ||
sleep 1d | ||
if zero -d $$DOMAIN -e $$EMAIL -c /etc/nginx/ssl --renew; then | ||
echo "Certificate renewed. Restarting Nginx..." | ||
docker exec zero-nginx nginx -s reload | ||
else | ||
echo "No renewal needed or renewal failed." | ||
fi | ||
done | ||
- PROXY_CONTAINER_NAME=nginx | ||
entrypoint: /renew-certificates.sh | ||
networks: | ||
- web | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
# Check required environment variables | ||
for var in DOMAIN EMAIL PROXY_CONTAINER_NAME; do | ||
if [[ -z "${!var}" ]]; then | ||
echo "${var} environment variable is not set" >&2 | ||
exit 1 | ||
fi | ||
done | ||
|
||
# Check if proxy container is running | ||
if ! docker ps | grep -q "$PROXY_CONTAINER_NAME"; then | ||
echo "Proxy container is not running. Exiting..." >&2 | ||
exit 1 | ||
fi | ||
|
||
while true; do | ||
sleep 1d | ||
if zero -d "$DOMAIN" -e "$EMAIL" -c /etc/nginx/ssl --renew; then | ||
echo "Certificate renewed. Restarting Nginx..." | ||
docker exec "$PROXY_CONTAINER_NAME" nginx -s reload | ||
else | ||
echo "No renewal needed or renewal failed." | ||
fi | ||
done |