← back to Japan Enrich

deploy/DEPLOY.md

50 lines

# Deploy: japan/china staging viewer → Kamatera (live, authenticated)

**Scope:** deploy the internal, Basic-Auth'd viewer to Kamatera and serve it at
`japan.designerwallcoverings.com` + `china.designerwallcoverings.com`.
DNS already points both at 45.61.58.125. **This does NOT publish any product to
Shopify** — the storefront (`designerwallcoverings.com`) is untouched. Product
promotion + Shopify publish stay separately gated (settlement gate applies to Sangetsu).

Prereqs on Kamatera: node + pm2 + nginx + certbot already present (standard DW box).
Port 9931 must be free (`ss -ltnp | grep 9931`).

## 1. Push the code + staged data (run on Mac2)
```sh
rsync -avz --delete \
  --exclude node_modules --exclude .git --exclude 'out/*.log' --exclude staging/import-queue.jsonl \
  ~/Projects/japan-enrich/ root@45.61.58.125:/root/public-projects/japan-viewer/
```

## 2. Install deps + start under pm2 (run on Kamatera)
```sh
cd /root/public-projects/japan-viewer && npm i --omit=dev pg
cd viewer-local
REQUIRE_AUTH=1 BASIC_AUTH="admin:DW2024!" pm2 start server.js --name japan-viewer -- 9931
pm2 save
curl -s -u admin:DW2024! http://127.0.0.1:9931/api/scope   # expect the japan scope json
```

## 3. nginx vhost + SSL (run on Kamatera — sudo)
```sh
cp /root/public-projects/japan-viewer/deploy/japan-china.designerwallcoverings.com.nginx \
   /etc/nginx/sites-available/japan-china.designerwallcoverings.com
ln -sf /etc/nginx/sites-available/japan-china.designerwallcoverings.com \
   /etc/nginx/sites-enabled/
nginx -t && systemctl reload nginx
certbot --nginx -d japan.designerwallcoverings.com -d china.designerwallcoverings.com --non-interactive --agree-tos -m steve@designerwallcoverings.com
```

## 4. Verify (from anywhere)
```sh
curl -s -o /dev/null -w '%{http_code}\n' https://japan.designerwallcoverings.com   # 401 (auth gate = healthy)
curl -s -u admin:DW2024! https://japan.designerwallcoverings.com/api/scope         # japan scope
curl -s -u admin:DW2024! https://china.designerwallcoverings.com/api/scope         # china scope
```

## Rollback
```sh
pm2 delete japan-viewer && pm2 save
rm /etc/nginx/sites-enabled/japan-china.designerwallcoverings.com && systemctl reload nginx
```