# CPANEL_DEPLOYMENT_PLAN — BANDUNGCRAFT.COM

## Kebutuhan hosting
- cPanel shared/hosting dengan MySQL 8.0, PHP 8.2+ (8.3 disarankan), Composer 2, Node 20 untuk build frontend.
- Disk: Laravel 10MB + upload 2GB privat + backup. Tidak perlu akses root.

## Versi & ekstensi PHP
- PHP: `8.2/8.3`, ekstensi: `pdo_mysql, mbstring, openssl, tokenizer, xml, ctype, json, bcmath, fileinfo, zip`.
- Laravel versi yang akan dipilih di Phase 4; versi spesifik dicantumkan di `composer.json`, jangan `composer update` tanpa lock review.

## Composer & build
```bash
composer install --no-dev --optimize-autoloader
npm ci && npm run build
php artisan migrate --force
php artisan db:seed --class=RolePermissionSeeder
php artisan storage:link (jika ada public assets)  # jangan link folder privat
php artisan config:cache && php artisan route:cache  # opsional di shared hosting
```

## MySQL
- Buat DB/user via cPanel, charset `utf8mb4_unicode_ci`, engine InnoDB (default Laravel).
- Kredensial hanya di `.env` di server (chmod 640), tidak di git.

## Storage & permission
- `storage/` dan `bootstrap/cache/` dapat ditulis user PHP (`chmod 775`), bukan root. Jalankan `php artisan storage:fix-permissions` bila tersedia.
- File referensi pelanggan di `storage/app/private/custom_orders` (bukan `public/`).

## Public directory
- `DocumentRoot` diarahkan ke `/home/USER/public_html` yang **isinya `public/` Laravel**, bukan root repo. Frontend build (`dist/`) disalin ke `public_html/` atau dibangun langsung di sana.

## Environment variables
- `APP_ENV=production, APP_DEBUG=false, DB_*, SESSION_DRIVER=database, CACHE_DRIVER=file, FILESYSTEM_DISK=local, MAIL_*`.
- Rotasi `APP_KEY` setelah deploy pertama; jangan commit `.env`.

## Cron job
- Scheduler: `* * * * * php /home/USER/public_html/artisan schedule:run >> /dev/null 2>&1` (untuk notifikasi/status timeout, kirim email quotation).
- Backup: `0 2 * * * mysqldump ... | gzip > /home/USER/backups/db-YYYYMMDD.sql.gz`.

## SSL
- Let's Encrypt via cPanel (Force HTTPS), mail domain + webmail ikut terenkripsi. Cron renew otomatis cPanel.

## Backup
- MySQL nightly 7 hari, file privat mingguan, plus snapshot manual pre-migrasi. Test restore di staging.

## Checklist deploy
1. Merge tag Phase 4 ke `main`, freeze.
2. Backup DB + file server lama.
3. `git pull`, `composer install --no-dev`, `npm ci && npm run build`.
4. `php artisan migrate --force`, seed bila perlu.
5. `php artisan optimize:clear` → `cache/route/view`.
6. Set izin storage, cek `php artisan doctor` / health route.
7. Smoke test: login, tambah produk, custom→quotation→order→DP→produksi, POS tutup kasir, laporan.
8. Aktifkan SSL, verify HSTS, cek audit log tercatat.
