Add standalone artifact deploy workflow
This commit is contained in:
@ -352,6 +352,103 @@ npm run build
|
||||
sudo systemctl restart abelbirdnest-web
|
||||
```
|
||||
|
||||
## 13. Alternatif Deploy: Build di Lokal, Jalankan di Server
|
||||
|
||||
Repo ini sekarang mendukung output Next.js `standalone`, sehingga build bisa dilakukan di lingkungan Linux lokal/container lalu artifact di-upload ke server.
|
||||
|
||||
### Kapan jalur ini dipakai
|
||||
|
||||
Pakai cara ini jika:
|
||||
|
||||
- server production terlalu kecil untuk `next build`
|
||||
- build sering mati karena RAM habis
|
||||
- Anda ingin memisahkan proses build dan runtime
|
||||
|
||||
### Prasyarat
|
||||
|
||||
- build harus dilakukan di Linux, atau container Linux
|
||||
- versi Node saat build harus sama dengan server
|
||||
- database migration tetap dijalankan di server
|
||||
|
||||
### Script yang disediakan
|
||||
|
||||
Build artifact Linux:
|
||||
|
||||
```bash
|
||||
deploy/scripts/build-linux-release.sh
|
||||
```
|
||||
|
||||
Upload artifact ke server:
|
||||
|
||||
```bash
|
||||
deploy/scripts/upload-linux-release.sh
|
||||
```
|
||||
|
||||
### Contoh build artifact di lokal
|
||||
|
||||
Pastikan `.env.production` sudah ada di root repo jika ingin ikut dibawa ke artifact.
|
||||
|
||||
```bash
|
||||
./deploy/scripts/build-linux-release.sh
|
||||
```
|
||||
|
||||
Artifact default yang dihasilkan:
|
||||
|
||||
```bash
|
||||
abelbirdnest-release.tar.gz
|
||||
```
|
||||
|
||||
Isi artifact:
|
||||
|
||||
- server Next.js standalone
|
||||
- static assets `.next/static`
|
||||
- folder `public`
|
||||
- folder `prisma`
|
||||
- `.env.production` jika tersedia
|
||||
|
||||
### Contoh upload ke server
|
||||
|
||||
```bash
|
||||
./deploy/scripts/upload-linux-release.sh abelbirdnest@server /var/www/abelbirdnest-web
|
||||
```
|
||||
|
||||
Setelah upload, script akan:
|
||||
|
||||
- copy artifact ke server
|
||||
- extract ke `/var/www/abelbirdnest-web/releases/<timestamp>`
|
||||
- update symlink `/var/www/abelbirdnest-web/current`
|
||||
|
||||
### Langkah setelah upload di server
|
||||
|
||||
Masuk ke server:
|
||||
|
||||
```bash
|
||||
ssh abelbirdnest@server
|
||||
cd /var/www/abelbirdnest-web/current
|
||||
set -a
|
||||
source .env.production
|
||||
set +a
|
||||
npx prisma migrate deploy
|
||||
```
|
||||
|
||||
Untuk menjalankan standalone app secara manual:
|
||||
|
||||
```bash
|
||||
PORT=3007 node server.js
|
||||
```
|
||||
|
||||
Jika memakai `systemd`, `WorkingDirectory` service harus diarahkan ke:
|
||||
|
||||
```bash
|
||||
/var/www/abelbirdnest-web/current
|
||||
```
|
||||
|
||||
dan `ExecStart` menjadi:
|
||||
|
||||
```bash
|
||||
/usr/bin/node server.js
|
||||
```
|
||||
|
||||
Jika branch utama nanti bukan `main`, sesuaikan perintah `git pull`.
|
||||
|
||||
## 12. Checklist Go-Live
|
||||
|
||||
Reference in New Issue
Block a user