Consolidate docs and finalize APK companion updates

This commit is contained in:
Dwindi Ramadhana
2026-03-16 01:06:41 +07:00
parent 95609dc0cf
commit 88218c7798
48 changed files with 7847 additions and 4502 deletions

View File

@@ -1,66 +1,53 @@
# Dewemoji Live Deployment Walkthrough
# Dewemoji Operations Runbook
This is the production rollout checklist for the `dewemoji` app.
This is the single operational guide for local, staging, and production workflows.
Use this in order:
1. Prepare env
2. Deploy code
3. Run post-deploy commands
4. Ensure admin access
5. Verify billing/webhooks/search/auth
## 1) Environment model
---
## 1) Pre-Deploy (Env + Infra)
Set these in live environment first:
### Local (safe default)
```env
APP_ENV=production
APP_DEBUG=false
APP_URL=https://your-live-domain.com
APP_ENV=local
APP_DEBUG=true
APP_URL=http://127.0.0.1:8000
DB_CONNECTION=sqlite
DEWEMOJI_BILLING_MODE=sandbox
DEWEMOJI_LICENSE_ACCEPT_ALL=false
DEWEMOJI_ALLOWED_ORIGINS=http://127.0.0.1:8000,http://localhost:8000
```
Core requirements:
1. Database points to live DB (`DB_*`).
2. `APP_KEY` is set and stable.
3. `SESSION_DRIVER`, `CACHE_STORE`, `QUEUE_CONNECTION` configured.
4. Billing provider secrets are set (PayPal/Pakasir).
5. Allowed origins include live domain.
### Staging / Production
Recommended billing cooldown config:
- Use `DEWEMOJI_BILLING_MODE=live`
- Configure real DB + provider credentials
- Keep `DEWEMOJI_LICENSE_ACCEPT_ALL=false`
For full production variable template, use `production-env.md`.
## 2) Live deployment sequence
### Pre-deploy
1. Confirm env values are set in server/Coolify.
2. Confirm webhook URLs are reachable:
- `https://<domain>/v1/paypal/webhook`
- `https://<domain>/webhooks/pakasir`
3. Recommended:
```env
DEWEMOJI_BILLING_PENDING_COOLDOWN_SECONDS=120
```
Webhook URLs:
1. PayPal webhook: `https://your-live-domain.com/v1/paypal/webhook`
2. Pakasir webhook: `https://your-live-domain.com/webhooks/pakasir`
---
## 2) Deploy Code
From your server app directory (example `/var/www/html`):
### Deploy code
```bash
git fetch --all
git checkout main
git pull origin main
```
Install dependencies if needed:
```bash
composer install --no-dev --optimize-autoloader
```
---
## 3) Post-Deploy Commands (Required)
Run in this exact sequence:
### Post-deploy (required order)
```bash
php artisan optimize:clear
@@ -68,38 +55,23 @@ php artisan migrate --force
php artisan config:cache
```
Optional but recommended:
Optional:
```bash
php artisan route:cache
php artisan view:cache
```
If you use queue workers:
```bash
php artisan queue:restart
```
Check migration status:
## 3) Ensure admin access
```bash
php artisan migrate:status
```
---
## 4) Ensure Admin User
Admin access is role-based (`users.role = admin`).
### Option A: Promote existing user (recommended)
Promote existing user:
```bash
php artisan tinker --execute="\App\Models\User::where('email','dewemoji@gmail.com')->update(['role'=>'admin']);"
```
### Option B: Create admin user if missing
Or create missing admin:
```bash
php artisan tinker --execute="
@@ -112,43 +84,30 @@ php artisan tinker --execute="
"
```
Verify:
## 4) Live smoke tests
### Core routes
1. `/`
2. `/emoji/grinning-face`
3. `/pricing`
4. `/api-docs`
5. `/support`
6. `/privacy`
7. `/terms`
8. `/robots.txt`
9. `/sitemap.xml`
### API checks
```bash
php artisan tinker --execute="dump(\App\Models\User::where('email','dewemoji@gmail.com')->first(['id','email','role','tier']));"
BASE=https://<domain>/v1
curl -s "$BASE/health" | jq .
curl -s "$BASE/categories" | jq 'keys | length'
curl -s "$BASE/emojis?q=love&limit=5" | jq '.items | length'
```
---
## 5) Smoke Test Checklist (Live)
### A. Core App
1. Login/register works over HTTPS with no insecure form warnings.
2. Dashboard loads.
3. Discover search returns emojis.
4. Emoji detail page loads.
### B. Skin Tone
1. Discover: change skin tone selector and verify toneable emoji changes.
2. Detail: tone chips update hero emoji and copy behavior.
3. Refresh page: tone preference persists.
### C. Account + Keywords
1. Free account can create up to active limit.
2. Active/inactive keyword behavior reflected in search.
3. Private keyword search appears in Discover after creation.
### D. Billing
1. PayPal checkout starts and returns.
2. Pakasir QRIS starts and modal polls.
3. Pending payment can be resumed.
4. Cooldown prevents immediate repeated checkout spam.
### E. Webhooks
1. PayPal event recorded and payment status updates.
2. Pakasir event recorded and payment status updates.
Useful checks:
### Billing and webhook checks
```bash
tail -n 200 storage/logs/laravel.log
@@ -156,66 +115,86 @@ php artisan tinker --execute="dump(\App\Models\WebhookEvent::latest()->take(10)-
php artisan tinker --execute="dump(\App\Models\Payment::latest()->take(10)->get(['id','provider','plan_code','status','created_at'])->toArray());"
```
---
## 5) Billing runtime validation (staging)
## 6) Optional: PayPal Plan Sync (Admin)
Verify these behaviors end-to-end:
From admin dashboard:
1. Open pricing admin page.
2. Click sync PayPal plans.
3. Confirm plan IDs are written and no 500.
1. pending cooldown lock on repeat checkout attempts (`409 pending_cooldown`)
2. resume pending payment via dashboard `Pay`
3. webhook delay handling (`pending` -> `paid` transition)
4. race/edge handling (`payment_not_pending`, `payment_expired`)
If there is failure, check:
Minimum assertions:
- cooldown response includes `retry_after`
- resume PayPal returns `mode=redirect` + `approve_url`
- resume Pakasir returns `mode=qris` with expiry data
## 6) Staging SQL sync
Set MySQL connection env, then run in container:
```bash
tail -n 300 storage/logs/laravel.log | grep -Ei "paypal|sync|webhook|error|exception"
cd /var/www/html
php artisan migrate
php artisan dewemoji:import-live-sql /var/www/html/dewemojiAPI_DB.sql --truncate
```
---
## 7) Extension Release Order
Release order:
1. Site/backend live first.
2. Verify API/auth on live domain.
3. Update extension default API base to live.
4. Publish extension update.
This avoids extension users hitting endpoints that are not ready.
---
## 8) APK Release (Direct Download)
APK release is independent from site redeploy.
Canonical URLs used by the app updater:
1. `https://dewemoji.com/downloads/version.json`
2. `https://dewemoji.com/downloads/dewemoji-latest.apk`
Set these env vars on app server:
```env
DEWEMOJI_APK_RELEASE_ENABLED=true
DEWEMOJI_APK_PUBLIC_BASE_URL=https://dewemoji.com/downloads
DEWEMOJI_R2_PUBLIC_BASE_URL=https://downloads.your-r2-domain.com
DEWEMOJI_R2_APK_VERSION_KEY=apk/version.json
DEWEMOJI_R2_APK_LATEST_KEY=apk/dewemoji-latest.apk
```
Validate redirects:
Sanity check:
```bash
curl -I https://dewemoji.com/downloads/version.json
curl -I https://dewemoji.com/downloads/dewemoji-latest.apk
php artisan tinker --execute="echo DB::table('emojis')->count().PHP_EOL;"
php artisan tinker --execute="echo DB::table('emoji_keywords')->count().PHP_EOL;"
```
---
Expected: emojis ~2131, emoji_keywords ~13420.
## 9) Rollback Strategy
## 7) MySQL GUI access via SSH tunnel
If release is broken:
1. Re-deploy previous known-good git commit.
For internal-only Coolify MySQL, tunnel to container IP.
Resolve MySQL container IP:
```bash
MYSQL_IP=$(ssh SERVER_USER@SERVER_HOST "docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' \$(docker ps --format '{{.ID}} {{.Names}}' | awk '/mysql|mariadb/{print \$1; exit}')")
echo "$MYSQL_IP"
```
Create tunnel:
```bash
ssh -N -L 3307:${MYSQL_IP}:3306 SERVER_USER@SERVER_HOST
```
Then connect in Sequel Ace/TablePlus using:
- Host `127.0.0.1`
- Port `3307`
- standard DB credentials
## 8) Local provider parity test (optional)
Switch local to live provider mode and verify with real keys.
```bash
BASE=http://127.0.0.1:8000/v1
curl -X POST "$BASE/license/verify" -H "Content-Type: application/json" -d '{"key":"<real_key>"}'
```
Also test activate/deactivate cycle, then return local env to sandbox mode.
## 9) APK release dependency note
App updater URLs used by the site:
- `https://dewemoji.com/downloads/version.json`
- `https://dewemoji.com/downloads/dewemoji-latest.apk`
For detailed APK build/release flow, use `dewemoji-apk-companion-build-walkthrough.md`.
## 10) Rollback
1. Re-deploy previous known-good commit.
2. Run:
```bash
@@ -224,4 +203,4 @@ php artisan config:cache
php artisan queue:restart
```
3. If issue is emoji dataset, use snapshot activation in admin catalog.
3. If issue is dataset-specific, switch to a known-good snapshot via admin tooling.