← back to Dw Pairs Well

deploy/README.md

73 lines

# dw-pairs-well — Kamatera deploy (3 steps, ~3 min)

The local service runs on **`:9813`** (NOT 9799 — that's taken by a Python SimpleHTTP on Mac2). Production target: `https://pairs.designerwallcoverings.com`.

## Step 1 — Add Cloudflare A record

`designerwallcoverings.com` is on Cloudflare (`ezra.ns.cloudflare.com` / `kimora.ns.cloudflare.com`). Add one A record:

| Type | Name  | Content        | Proxy | TTL |
|------|-------|----------------|-------|-----|
| A    | pairs | 45.61.58.125   | ON    | Auto |

**Via the Cloudflare dashboard:** designerwallcoverings.com → DNS → Records → Add record.

**Or via `flarectl` / curl** (if `CLOUDFLARE_API_TOKEN` and the zone ID are in your env):

```bash
# replace ZONE_ID with the designerwallcoverings.com zone id
curl -sX POST "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records" \
  -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  -H "Content-Type: application/json" \
  --data '{"type":"A","name":"pairs","content":"45.61.58.125","ttl":1,"proxied":true}'
```

## Step 2 — rsync code to Kamatera

From your Mac:

```bash
rsync -avz --delete \
  --exclude node_modules --exclude .git --exclude .env \
  ~/Projects/dw-pairs-well/ \
  root@45.61.58.125:/root/Projects/dw-pairs-well/

# Copy your .env separately (NOT the example), one-time:
scp ~/Projects/dw-pairs-well/.env root@45.61.58.125:/root/Projects/dw-pairs-well/.env
```

The `.env` on Kamatera must have its own `DATABASE_URL` pointing at the **local** PG on Kamatera (e.g. `postgresql://dw_admin:DW2024SecurePass@127.0.0.1:5432/dw_unified`) — NOT the Mac→Kamatera tunnel port 15432.

## Step 3 — Run the bootstrap

```bash
ssh root@45.61.58.125 'bash /root/Projects/dw-pairs-well/deploy/kamatera-bootstrap.sh'
```

The script is **idempotent** — re-running it is safe. It will:

1. Verify node / pm2 / certbot are installed (installs certbot if missing)
2. `npm install --omit=dev` in `/root/Projects/dw-pairs-well`
3. Write `/etc/nginx/sites-available/pairs.designerwallcoverings.com` (HTTP block first, certbot adds the TLS block)
4. DNS sanity check against `1.1.1.1`
5. `certbot --nginx -d pairs.designerwallcoverings.com --redirect` (skipped if cert already exists)
6. `pm2 start server.js --name dw-pairs-well` (or `pm2 reload` if it already exists), `pm2 save`
7. Smoke test `https://pairs.designerwallcoverings.com/healthz` and a sample `/api/pairs?dw_sku=DWRW-74991`

When you see `✅ done`, the storefront snippet in `DesignerWallcoverings-product.liquid` will start serving live pairings on the next page render. No theme push required — the snippet already hardcodes the production URL.

## Rollback

```bash
ssh root@45.61.58.125 '
  pm2 delete dw-pairs-well
  rm -f /etc/nginx/sites-enabled/pairs.designerwallcoverings.com
  rm -f /etc/nginx/sites-available/pairs.designerwallcoverings.com
  systemctl reload nginx
  certbot delete --cert-name pairs.designerwallcoverings.com -n
'
# Then remove the CF DNS record in the dashboard.
```

The Liquid block will then soft-fail-to-hidden (fetch fails → `root.hidden = true`).