# 11. Strategi Deployment

## Environment

- **Local:** `.env` dari `.env.example`; DB SQLite/MySQL; queue sync atau redis.
- **Staging:** Mirip production; data anonymized atau copy terbatas; untuk UAT.
- **Production:** MySQL/PostgreSQL, Redis (queue + cache), env aman (APP_KEY, DB, REDIS, payment keys).

## Server (Contoh)

- **App:** PHP 8.2+, Nginx/Apache, Laravel (single node awal).
- **Queue worker:** `php artisan queue:work` (supervisor atau systemd).
- **Scheduler:** `php artisan schedule:run` (cron setiap menit).

## CI/CD (Rekomendasi)

- **Build:** `composer install --no-dev`, `npm ci && npm run build`.
- **Test:** `php artisan test` sebelum deploy.
- **Deploy:** Git pull / artifact, `php artisan migrate --force`, `php artisan config:cache`, `php artisan route:cache`, restart queue.
- **Zero-downtime:** Rolling atau blue-green jika sudah multi-node.

## Monitoring & Log

- Log: Laravel log + error tracking (Sentry, Flare).
- Health check: `/up` (Laravel default) untuk load balancer.
- Queue: monitor failed jobs; alert jika backlog besar.
- DB: slow query log; monitor connection pool.

## Backup

- DB: backup harian (retention 7–30 hari); restore test berkala.
- File: storage (upload, export) ikut backup atau object storage (S3).
