Prepare Alpine artifact deploy workflow
This commit is contained in:
@ -112,6 +112,7 @@ Dokumen ini menyimpan konteks kerja terbaru setelah rangkaian patch mobile, logi
|
||||
- `native`
|
||||
- `darwin-arm64`
|
||||
- `debian-openssl-3.0.x`
|
||||
- `linux-musl-openssl-3.0.x`
|
||||
- File:
|
||||
- [prisma/schema.prisma](/Users/wirabasalamah/Documents/Codex/abelbirdnest-web/prisma/schema.prisma)
|
||||
|
||||
@ -122,26 +123,71 @@ Dokumen ini menyimpan konteks kerja terbaru setelah rangkaian patch mobile, logi
|
||||
- Script:
|
||||
- [deploy/scripts/build-linux-release.sh](/Users/wirabasalamah/Documents/Codex/abelbirdnest-web/deploy/scripts/build-linux-release.sh)
|
||||
- Karakteristik workflow ini:
|
||||
- build di Docker `linux/amd64`
|
||||
- build di Docker Alpine Linux agar cocok dengan server Alpine
|
||||
- install `openssl` di container
|
||||
- pakai `NODE_OPTIONS=--max-old-space-size=4096`
|
||||
- copy source ke `/work` agar tidak menimpa `node_modules` lokal Mac
|
||||
- artifact final:
|
||||
`abelbirdnest-release.tar.gz`
|
||||
- artifact final memakai timestamp:
|
||||
`abelbirdnest-release-YYYYMMDD-HHMMSS.tar.gz`
|
||||
- Artifact final tidak membawa `.env.production` lokal.
|
||||
|
||||
### Catatan Tambahan 2026-05-26
|
||||
|
||||
- Server production memakai Alpine Linux dengan RAM sekitar 1 GB.
|
||||
- Jangan compile/build di server.
|
||||
- Artifact harus dibuat dari container Alpine, default script sekarang memakai `node:20-alpine`.
|
||||
- Runtime server Alpine perlu `nodejs` dan `openssl`.
|
||||
- Ukuran artifact runtime-only yang normal sekitar `43 MB`.
|
||||
- Jika artifact membengkak sekitar `120 MB+`, kemungkinan Prisma CLI atau `node_modules` lengkap ikut terbawa. Jangan pakai varian besar itu untuk server 1 GB kecuali memang sengaja.
|
||||
- Artifact runtime-only tidak dipakai untuk menjalankan `prisma migrate deploy` di server. Untuk update UI/app tanpa perubahan schema DB, cukup extract release baru lalu restart service.
|
||||
- Jika nanti ada migration database, jalankan migration dari mesin build/admin yang punya dependency lengkap dan akses DB production, bukan dari server kecil.
|
||||
|
||||
## Catatan Deploy Server Saat Ini
|
||||
|
||||
- Path app di server:
|
||||
`/var/www/abelbirdnest-web/AbelBirdNest-Stock`
|
||||
- Path app aktif di server production saat ini:
|
||||
`/opt/abelbirdnest-web`
|
||||
- Struktur release yang dipakai sekarang diasumsikan:
|
||||
- upload artifact ke root repo server
|
||||
- upload artifact ke root app server:
|
||||
`/opt/abelbirdnest-web`
|
||||
- extract ke `releases/<timestamp>`
|
||||
- symlink `current` diarahkan ke release aktif
|
||||
- `systemd` yang benar untuk mode artifact:
|
||||
- `WorkingDirectory=/var/www/abelbirdnest-web/AbelBirdNest-Stock/current`
|
||||
- `EnvironmentFile=/var/www/abelbirdnest-web/AbelBirdNest-Stock/.env.production`
|
||||
- `ExecStart=/usr/bin/node server.js`
|
||||
- Folder aktif runtime:
|
||||
`/opt/abelbirdnest-web/current`
|
||||
- Service server memakai OpenRC, bukan systemd.
|
||||
- Service OpenRC production yang ditemukan:
|
||||
- `directory="/opt/abelbirdnest-web/current"`
|
||||
- `command="/usr/bin/node"`
|
||||
- `command_args="/opt/abelbirdnest-web/current/server.js"`
|
||||
- env yang dicek service:
|
||||
`/opt/abelbirdnest-web/current/.env`
|
||||
- Karena service mencari `.env` di folder `current`, setiap release baru perlu copy `.env` dari release/current lama ke folder release baru sebelum `current` diarahkan ke release baru.
|
||||
- Jangan gunakan path lama `/var/www/abelbirdnest-web/AbelBirdNest-Stock` untuk server ini kecuali service production memang sudah diubah.
|
||||
|
||||
### Command Manual Deploy Yang Dipakai
|
||||
|
||||
Di lokal:
|
||||
|
||||
```bash
|
||||
scp abelbirdnest-release-YYYYMMDD-HHMMSS.tar.gz abelbirdnest@SERVER_IP:/opt/abelbirdnest-web/
|
||||
```
|
||||
|
||||
Di server:
|
||||
|
||||
```bash
|
||||
cd /opt/abelbirdnest-web
|
||||
RELEASE_NAME=YYYYMMDD-HHMMSS
|
||||
mkdir -p /opt/abelbirdnest-web/releases/$RELEASE_NAME
|
||||
tar -xzf /opt/abelbirdnest-web/abelbirdnest-release-$RELEASE_NAME.tar.gz -C /opt/abelbirdnest-web/releases/$RELEASE_NAME
|
||||
cp /opt/abelbirdnest-web/current/.env /opt/abelbirdnest-web/releases/$RELEASE_NAME/.env
|
||||
mv /opt/abelbirdnest-web/current /opt/abelbirdnest-web/current-backup-$(date +%Y%m%d-%H%M%S) 2>/dev/null || true
|
||||
ln -sfn /opt/abelbirdnest-web/releases/$RELEASE_NAME /opt/abelbirdnest-web/current
|
||||
sudo chown -R abelbirdnest:abelbirdnest /opt/abelbirdnest-web
|
||||
sudo rc-service abelbirdnest-web restart
|
||||
sudo rc-service abelbirdnest-web status
|
||||
curl -I http://127.0.0.1:3007/login
|
||||
```
|
||||
|
||||
Jika `ln -sfn ... current` gagal dengan pesan `File exists`, berarti `current` masih folder biasa. Backup/rename folder itu dulu, lalu ulangi `ln -sfn`.
|
||||
|
||||
## Verifikasi yang Sudah Dilakukan
|
||||
|
||||
|
||||
Reference in New Issue
Block a user