DocHub
Separate deploy scripts for staging and production environments

Independent Staging/Production Deploys

Problem

Previously both staging (/opt/ricoya) and production (/opt/ricoya-live) were deployed simultaneously via two rsync commands. No way to test on staging before pushing to production.

Solution

Two shell scripts in the SeawichesApp root:

deploy-staging.sh

  • Rsyncs to /opt/ricoya only
  • Runs npm install --legacy-peer-deps && npm run build && pm2 restart ricoya
  • Accessible via staging.ricoya.net

deploy-prod.sh

  • Rsyncs to /opt/ricoya-live only
  • Runs npm install --legacy-peer-deps && npm run build && pm2 restart ricoya-live
  • Accessible via ricoya.net

Both scripts exclude node_modules, .next, .git, .env.local.

Workflow

  1. Make changes locally
  2. Run ./deploy-staging.sh → test on staging.ricoya.net
  3. When satisfied, run ./deploy-prod.sh → goes live on ricoya.net

Important Notes

  • .env.local is never synced — each server copy has its own environment config
  • The APNS_KEY_P8 in .env.local must not be edited with sed — multi-line P8 content gets corrupted. Use echo >> append instead.
  • Cloudflare proxy must stay ON — SSL uses Origin cert which only works behind the Cloudflare proxy