Files
homaroma/KITTISAK_DEPLOYMENT_RUNBOOK.md
T

4.5 KiB

Kittisak Deployment Runbook

เอกสารนี้เป็น runbook เฉพาะลูกค้า kittisak โดยอิงจาก DEPLOYMENT_GUIDE.md และไฟล์ตัวอย่างใน serverinfo/ddc-* / serverinfo/huahin-*

Target

  • Project name: kittisak
  • Website: https://kittisak.com
  • SPA: https://spa.kittisak.com
  • Admin: https://admin.kittisak.com
  • API: https://api.kittisak.com
  • Database: kittisakdb
  • Website SSR port: 3005
  • Backend API port: 3054
  • Bare repo: /home/ti/git/kittisak.com.git
  • Backend path: /home/ti/projects/kittisak-api
  • Website path: /home/ti/projects/kittisak-website
  • SPA static path: /home/ti/projects/MyNginxMain/nginx/html/kittisak/spa
  • Admin static path: /home/ti/projects/MyNginxMain/nginx/html/kittisak/admin

Files Prepared In This Repo

  • serverinfo/kittisak-post-receive
  • serverinfo/kittisak-backend.env.example
  • serverinfo/kittisak-nginx/kittisak.com.conf
  • serverinfo/kittisak-nginx/spa.kittisak.com.conf
  • serverinfo/kittisak-nginx/admin.kittisak.com.conf
  • serverinfo/kittisak-nginx/api.kittisak.com.conf

Preflight On Server

Run on kitizone.com before changing live services:

ss -ltnp | grep -E ':3005|:3054' || true
pm2 list

If ports 3005 or 3054 are already used, stop and choose new ports before applying these files.

1. Create Bare Git Repository

mkdir -p /home/ti/git/kittisak.com.git
cd /home/ti/git/kittisak.com.git
git init --bare

2. Create Project Directories

mkdir -p /home/ti/projects/kittisak-api
mkdir -p /home/ti/projects/kittisak-website
mkdir -p /home/ti/projects/MyNginxMain/nginx/html/kittisak/spa
mkdir -p /home/ti/projects/MyNginxMain/nginx/html/kittisak/admin

3. Create Database

docker exec -it arokro_postgres psql -U postgres -c "CREATE DATABASE kittisakdb;"

4. Open Firewall Ports

sudo ufw allow 3005/tcp
sudo ufw allow 3054/tcp
sudo ufw reload

5. Request SSL Certificates

cd /home/ti/projects/MyNginxMain
docker compose stop nginx

docker compose run --rm certbot certonly --standalone \
  -d kittisak.com \
  -d spa.kittisak.com \
  -d admin.kittisak.com \
  -d api.kittisak.com

6. Install Nginx Configs

Copy files from serverinfo/kittisak-nginx/ to:

/home/ti/projects/MyNginxMain/nginx/conf.d/

Then validate and restart nginx:

cd /home/ti/projects/MyNginxMain
docker compose run --rm nginx nginx -t
docker compose up -d nginx

7. Install Backend Environment File

Create this server file:

/home/ti/projects/kittisak-api/.env

Use serverinfo/kittisak-backend.env.example as the base and replace placeholders before production use:

  • postgres:password must match the real Postgres password.
  • JWT_SECRET must be a new project-specific secret.
  • OMISE_SECRET_KEY must be set if payments are enabled.

The deploy hook copies this file into /home/ti/projects/kittisak-api/apps/backend/.env before Prisma commands.

8. Install Git Hook

Copy:

serverinfo/kittisak-post-receive

To:

/home/ti/git/kittisak.com.git/hooks/post-receive

Then run:

chmod +x /home/ti/git/kittisak.com.git/hooks/post-receive

9. Deploy From Developer Machine

git remote add kittisak-website ti@kitizone.com:/home/ti/git/kittisak.com.git
git push kittisak-website master

10. Seed Database

Run after the first successful deployment:

ssh ti@kitizone.com
cd /home/ti/projects/kittisak-api/apps/backend
export PATH=$PATH:/home/ti/.bun/bin:/home/ti/.nvm/versions/node/v22.17.1/bin
bun run prisma/seed.cjs

Default seeded admin account is currently admin / homaroma123. Change it before handing production access to the customer.

Verification

pm2 list
curl -I https://kittisak.com
curl -I https://spa.kittisak.com
curl -I https://admin.kittisak.com
curl -I https://api.kittisak.com

Expected PM2 processes:

  • kittisak-backend
  • kittisak-website

Check browser console for:

  • CORS errors on admin and SPA
  • missing static assets
  • API 504 from website SSR build or runtime fetches

Known Risks

  • serverinfo/kittisak-post-receive rewrites ecosystem.config.js at deploy time from the base homaroma config. This follows the existing pkh/ddc pattern.
  • The codebase still contains some hardcoded HomAroma URLs and storage keys in app code. This runbook only prepares infrastructure deployment, not full white-label branding cleanup.
  • Payments and LINE LIFF need customer-specific production keys before launch.