32 lines
1.0 KiB
Bash
32 lines
1.0 KiB
Bash
#!/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 ==="
|