From 9a072061a1fe3e1848cf53160443528dd063ec67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=B6rdle=20Bot?= Date: Sat, 22 Nov 2025 16:56:30 +0100 Subject: [PATCH] Add deployment script and health checks for zero-downtime updates --- docker-compose.example.yml | 6 ++++++ scripts/deploy.sh | 25 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100755 scripts/deploy.sh diff --git a/docker-compose.example.yml b/docker-compose.example.yml index 10cccad..37975f4 100644 --- a/docker-compose.example.yml +++ b/docker-compose.example.yml @@ -18,6 +18,12 @@ services: volumes: - ./data:/app/data - ./public/uploads:/app/public/uploads + healthcheck: + test: [ "CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/api/daily" ] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s # Initialize DB if needed and run migration command: > sh -c "npx -y prisma@6.19.0 db push && node scripts/migrate-covers.mjs && node server.js" diff --git a/scripts/deploy.sh b/scripts/deploy.sh new file mode 100755 index 0000000..f3b6287 --- /dev/null +++ b/scripts/deploy.sh @@ -0,0 +1,25 @@ +#!/bin/bash +set -e + +echo "๐Ÿš€ Starting optimized deployment..." + +# Pull latest changes +echo "๐Ÿ“ฅ Pulling latest changes from git..." +git pull + +# Build new image in background (doesn't stop running container) +echo "๐Ÿ”จ Building new Docker image (this runs while app is still online)..." +docker compose build + +# Quick restart with pre-built image +echo "๐Ÿ”„ Restarting with new image (minimal downtime)..." +docker compose up -d + +# Clean up old images +echo "๐Ÿงน Cleaning up old images..." +docker image prune -f + +echo "โœ… Deployment complete!" +echo "" +echo "๐Ÿ“Š Showing logs (Ctrl+C to exit)..." +docker compose logs -f