This commit is contained in:
Saufi
2026-06-16 21:03:26 +08:00
parent 296d31b90c
commit 77a6d89bc2
5 changed files with 110 additions and 0 deletions

31
deploy.sh Normal file
View File

@@ -0,0 +1,31 @@
#!/bin/bash
# Kehadiran Taklimat SPR — Production Deploy Script
# Dipanggil oleh container webhook selepas git push ke GitHub (branch master).
set -e
PROJECT_DIR="/srv/spr2026_taklimat"
LOG="$PROJECT_DIR/deploy.log"
log() { echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" | tee -a "$LOG"; }
log "=== Deploy dimulakan ==="
cd "$PROJECT_DIR"
# git jalan sebagai root dlm container; repo milik user host -> elak "dubious ownership".
git config --global --add safe.directory "$PROJECT_DIR"
log "git pull..."
git pull origin master
# Kod di-bake dalam image (bukan bind-mount) -> perlu build semula.
# Hanya service aplikasi yg di-recreate; container 'webhook' SENGAJA tidak
# disenaraikan supaya ia tidak bunuh dirinya sendiri di tengah deploy.
# Entrypoint app jalankan migrate + config/route/view:cache automatik masa boot.
log "build & recreate (app, web, queue, scheduler)..."
docker compose up -d --build --force-recreate app web queue scheduler
log "buang image lama yg tidak digunakan..."
docker image prune -f
log "=== Deploy selesai ==="