Temple of the Moon - Deployment & Infrastructure

Production Environment

ComponentDetails
HostingHostinger VPS
Server IP76.13.115.76
Hostnamesrv1314175.hstgr.cloud
OSUbuntu (Node v24.13.0)
SSH Userroot
SSH Key~/.ssh/github_ed25519 (from pop-os)

VPS Services

PortServiceNotes
22SSH
80nginxHTTP β†’ HTTPS redirect
443nginxHTTPS proxy
3001Next.jsTOTM app (via PM2)
3002Next.jsNorthland Tech (via PM2)
5432PostgreSQLlocalhost only
9000WebhookAuto-deploy listener

Repository

PropertyValue
GitHubgit@github.com:red40mademedoit/templeofthemoonbooks.com.git
Branchmaster
Local Dev/home/shdwdev/projects/templeofthemoonbooks.com
VPS Path/opt/deploy/repos/templeofthemoonbooks.com

Deployment Workflow

Auto-Deploy (GitHub Webhook)

  1. Push to GitHub master branch
  2. GitHub sends webhook to 76.13.115.76:9000
  3. Webhook triggers /opt/deploy/scripts/deploy.sh
  4. Script pulls, installs, builds, restarts PM2

⚠️ Note: Deploy script uses git pull origin main but branch is master. May need manual deploy or fix the script.

Manual Deploy

# SSH into VPS
ssh -i ~/.ssh/github_ed25519 root@76.13.115.76
 
# Navigate to app
cd /opt/deploy/repos/templeofthemoonbooks.com
 
# Pull latest
git pull origin master
 
# Install deps (if changed)
export PATH="/root/.nvm/versions/node/v24.13.0/bin:$PATH"
npm ci --production=false
 
# Build
npm run build
 
# Restart
pm2 restart templeofthemoonbooks.com

Quick Deploy One-Liner

ssh -i ~/.ssh/github_ed25519 root@76.13.115.76 'export PATH="/root/.nvm/versions/node/v24.13.0/bin:$PATH" && cd /opt/deploy/repos/templeofthemoonbooks.com && git pull origin master && npm ci --production=false && npm run build && pm2 restart templeofthemoonbooks.com'

Process Management (PM2)

# List processes
pm2 list
 
# View logs
pm2 logs templeofthemoonbooks.com
 
# Restart
pm2 restart templeofthemoonbooks.com
 
# Stop
pm2 stop templeofthemoonbooks.com

Current PM2 Apps:

IDNamePort
0templeofthemoonbooks.com3001
1nortlandtechsolutions.com3002
2webhook9000

Database

PropertyValue
EnginePostgreSQL
Hostlocalhost (VPS only)
Port5432
Databasetotm
Usertotm
SchemaPrisma managed

Database Access

# From VPS
PGPASSWORD=*** psql -h localhost -U totm -d totm
 
# Quick query
PGPASSWORD=*** psql -h localhost -U totm -d totm -c "SELECT COUNT(*) FROM products;"

Local Development

Local .env uses placeholder β€” real creds only on VPS:

DATABASE_URL="postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public"

Environment Variables

Production (VPS .env)

VariablePurpose
DATABASE_URLPostgreSQL connection
PAYPAL_CLIENT_IDPayPal REST API
PAYPAL_CLIENT_SECRETPayPal REST API
PAYPAL_MODEsandbox or live
NEXT_PUBLIC_BASE_URLSite URL for callbacks

Domain & SSL

PropertyValue
Domaintempleofthemoonbooks.com
DNSA record β†’ 76.13.115.76
SSLnginx (likely Let’s Encrypt)
Proxynginx β†’ localhost:3001

Image Assets

Azure Green Product Images

Products reference Azure Green CDN directly:

https://www.azuregreen.net/images/{SKU}.jpg

Configured in next.config.ts:

images: {
  remotePatterns: [
    { hostname: 'www.azuregreen.net', pathname: '/images/**' },
  ],
}

Local Category Images

public/images/categories/
β”œβ”€β”€ amulet.jpg
β”œβ”€β”€ book.jpg
β”œβ”€β”€ candle.jpg
β”œβ”€β”€ statue.jpg
β”œβ”€β”€ stone.jpg
└── tool.jpg

Adding Images for New Products

Azure Green products get images auto-generated from SKU:

INSERT INTO product_images (id, product_id, url, alt_text, position)
SELECT gen_random_uuid()::text, p.id, 
       'https://www.azuregreen.net/images/' || p.sku || '.jpg',
       p.name, 0
FROM products p
LEFT JOIN product_images pi ON p.id = pi.product_id
WHERE p.source = 'AZUREGREEN' AND p.sku IS NOT NULL AND pi.id IS NULL;

Webhook Configuration

Location: /opt/deploy/webhook.js

Listens on port 9000 for GitHub push events:

const REPO_MAP = {
  'templeofthemoonbooks.com': 'templeofthemoonbooks.com',
  'nortlandtechsolutions.com': 'nortlandtechsolutions.com', 
  // ...
};

Deploy Script: /opt/deploy/scripts/deploy.sh


Troubleshooting

Build Fails with TypeScript Error

Ensure tsconfig.json excludes seed/script files:

"exclude": ["node_modules", "prisma/*.ts", "scripts/*.ts"]

PM2 Command Not Found

Need to set PATH:

export PATH="/root/.nvm/versions/node/v24.13.0/bin:$PATH"

Check if Site is Running

curl -I https://templeofthemoonbooks.com
pm2 list

Quick Reference

# SSH
ssh -i ~/.ssh/github_ed25519 root@76.13.115.76
 
# Check status
pm2 list
 
# View logs
pm2 logs templeofthemoonbooks.com --lines 50
 
# Manual deploy
cd /opt/deploy/repos/templeofthemoonbooks.com
git pull origin master && npm run build && pm2 restart templeofthemoonbooks.com
 
# Database query
PGPASSWORD=*** psql -h localhost -U totm -d totm -c "SELECT COUNT(*) FROM products;"