Deployment
Alur CI/CD GitLab dan langkah rilis ke development, staging, dan production
Alur pipeline
Deploy memakai GitLab CI (.gitlab-ci.yml). Cabang menentukan target server.
Superadmin (ESCHOOL_INDUK)
| Branch | Environment | Cara deploy | Domain |
|---|---|---|---|
develop | Development | Otomatis | dev-superadmin.eschool.ac.id |
staging | Staging | Manual | test-superadmin.eschool.ac.id |
main | Production | Manual | superadmin.eschool.ac.id |
Runner memakai tag laravel dengan PHP 8.3.
API-Sekolah
| Branch | Environment | Cara deploy | Domain |
|---|---|---|---|
development | Development | Otomatis | devapisekolah.eschool.ac.id |
staging | Staging | Manual | testapisekolah.eschool.ac.id |
main | Production | Manual | apisekolah.eschool.ac.id |
Urutan job deploy production
Alur antar branch:
Aturan .env
- File
.envtidak ikut ter-rsync dan tidak di-track git. - Setiap server (dev, staging, production) punya
.envsendiri dan dibuat manual. - Setiap server punya database central sendiri.
- Jangan tinggalkan file seperti
.env.productiondi folder deploy.
Insiden nyata: .env.production yang tertinggal membuat config:cache di production memuat nilai milik devinduk, sehingga production redirect ke devinduk/login. Pastikan hanya .env yang ada di folder deploy.
Perbaikan jika itu terjadi:
php artisan optimize:clear
php artisan config:cache
php artisan route:cache
php artisan view:cacheStruktur folder di server
/www/wwwroot/<domain>/
├── Eschool-Superadmin/ # kode aplikasi (hasil deploy)
└── storage/ # storage permanen, di-symlink ke aplikasiHealth check
API-Sekolah menyediakan endpoint:
GET /api/health/dbKoneksi mysql_test hanya dicek di luar staging dan production. Jika has_errors muncul karena mysql_test di staging atau production, itu wajar.
Checklist sebelum deploy
- Test lulus
- Migration dicek (tidak merusak data)
-
.envdi server sudah benar - Backup database sudah dibuat
Cron dan queue
* * * * * cd /www/wwwroot/<domain>/Eschool-Superadmin && php artisan schedule:run >> /dev/null 2>&1Untuk API-Sekolah, cache dan queue memakai Redis (CACHE_DRIVER=redis, QUEUE_CONNECTION=redis) sedangkan SESSION_DRIVER=file. Setelah deploy, restart worker:
php artisan queue:restartRollback
git checkout <commit-sebelumnya>
php artisan migrate:rollback --step=1
php artisan config:cacheRollback migration bisa menghapus data. Backup dulu sebelum menjalankannya.