4.5 KiB
HuaHin Deployment Runbook
เอกสารนี้เป็น runbook เฉพาะลูกค้า huahin โดยอิงจาก DEPLOYMENT_GUIDE.md และไฟล์ตัวอย่างใน serverinfo/ddc-*
Target
- Project name:
huahin - Website:
https://huahin.propkk.com - SPA:
https://spa.huahin.propkk.com - Admin:
https://admin.huahin.propkk.com - API:
https://api.huahin.propkk.com - Database:
huahindb - Website SSR port:
3007 - Backend API port:
3056 - Bare repo:
/home/ti/git/huahin-website.git - Backend path:
/home/ti/projects/huahin-api - Website path:
/home/ti/projects/huahin-website - SPA static path:
/home/ti/projects/MyNginxMain/nginx/html/huahin/spa - Admin static path:
/home/ti/projects/MyNginxMain/nginx/html/huahin/admin
Files Prepared In This Repo
serverinfo/huahin-post-receiveserverinfo/huahin-backend.env.exampleserverinfo/huahin-nginx/huahin.propkk.com.confserverinfo/huahin-nginx/spa.huahin.propkk.com.confserverinfo/huahin-nginx/admin.huahin.propkk.com.confserverinfo/huahin-nginx/api.huahin.propkk.com.conf
Preflight On Server
Run on kitizone.com before changing live services:
ss -ltnp | grep -E ':3007|:3056' || true
pm2 list
If ports 3007 or 3056 are already used, stop and choose new ports before applying these files.
1. Create Bare Git Repository
mkdir -p /home/ti/git/huahin-website.git
cd /home/ti/git/huahin-website.git
git init --bare
2. Create Project Directories
mkdir -p /home/ti/projects/huahin-api
mkdir -p /home/ti/projects/huahin-website
mkdir -p /home/ti/projects/MyNginxMain/nginx/html/huahin/spa
mkdir -p /home/ti/projects/MyNginxMain/nginx/html/huahin/admin
3. Create Database
docker exec -it arokro_postgres bash
psql -U postgres -c "CREATE DATABASE huahindb;"
exit
4. Open Firewall Ports
sudo ufw allow 3007/tcp
sudo ufw allow 3056/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 huahin.propkk.com \
-d spa.huahin.propkk.com \
-d admin.huahin.propkk.com \
-d api.huahin.propkk.com
6. Install Nginx Configs
Copy files from serverinfo/huahin-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/huahin-api/.env
Use serverinfo/huahin-backend.env.example as the base and replace placeholders before production use:
postgres:passwordmust match the real Postgres password.JWT_SECRETmust be a new project-specific secret.OMISE_SECRET_KEYmust be set if payments are enabled.
The deploy hook copies this file into /home/ti/projects/huahin-api/apps/backend/.env before Prisma commands.
8. Install Git Hook
Copy:
serverinfo/huahin-post-receive
To:
/home/ti/git/huahin-website.git/hooks/post-receive
Then run:
chmod +x /home/ti/git/huahin-website.git/hooks/post-receive
9. Deploy From Developer Machine
git remote add huahin-website ti@kitizone.com:/home/ti/git/huahin-website.git
git push huahin-website master
10. Seed Database
Run after the first successful deployment:
ssh ti@kitizone.com
cd /home/ti/projects/huahin-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://huahin.propkk.com
curl -I https://spa.huahin.propkk.com
curl -I https://admin.huahin.propkk.com
curl -I https://api.huahin.propkk.com
Expected PM2 processes:
huahin-backendhuahin-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/huahin-post-receiverewritesecosystem.config.jsat deploy time from the basehomaromaconfig. This follows the existingpkh/ddcpattern.- 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.