Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create new production environment #324

Closed
50 tasks done
bfirsh opened this issue Dec 14, 2018 · 4 comments
Closed
50 tasks done

Create new production environment #324

bfirsh opened this issue Dec 14, 2018 · 4 comments
Assignees

Comments

@bfirsh
Copy link
Member

bfirsh commented Dec 14, 2018

Deploy a new production environment, probably on Heroku.

Blockers

Pre-migration tasks

  • Move embassynetwork.com DNS to Cloudflare (just for DNS - Cloudflare stuff can be disabled)
    • This can be done ahead of time, which will make the final migration much less scary.
  • Backups Offsite backups #435
  • Configure Cloudflare to use a canonical domain
  • Fix scheduled tasks (as per Should we replace Celery with Heroku scheduler? #326)
  • Tests for key workflows (headless as per Headless browser tests for key workflows #339 or otherwise)
  • Run migration of database on staging to ensure the migration works
  • Enable force HTTPS on Cloudflare
  • Test generating thumbnails on staging once Fix thumbnails on S3 #474 has been merged
    • heroku run -a embassynetwork-staging ./manage.py generateimages
  • Create production Heroku app (clone staging app), app name "embassynetwork-production" http://embassynetwork-production.herokuapp.com/
    • Create new clone of production database, recording commands executed in ... sections below
    • Migrate database to check migration works
    • Generate new secret key
    • Copy over production API keys (pending mailgun)
    • Upgrade to full dynos
    • Upgrade to standard database plan
    • Enable Heroku DB backups
    • heroku pg:backups:schedule -a embassynetwork-production DATABASE_URL --at '02:00 America/Los_Angeles'
    • Set up off-site backups
    • Do initial move of static files
      • s3cmd sync --region us-east-1 -rv webapp/media/* s3://media.embassynetwork.com/public/
    • Do initial generation of thumbnails
      • heroku run -a embassynetwork-production ./manage.py generateimages
    • Set up media.embassynetwork.com
      • Cloudflare
      • heroku config:set -a embassynetwork-production MEDIA_URL=https://media.embassynetwork.com/public/
    • Test new production app works (click around!)
    • Restore and verify backup is intact. (Actually restore database locally.)
  • Finalize workflow to deploy to production
  • 2FA all the things moved to Post Production Migration Tasks #483

Migration steps

  • Notify folks on Slack that site will be down for 30 mins, and emails might not work over next few days
  • Turn off Celery on old site
  • Take down current site somehow
  • Dump database (as per)
    • PGPASSWORD=XXXX pg_dump -Fc --no-acl --no-owner -h localhost -U postgres modernomadb > modernomadb.dump
  • scp db dump to local machine and then upload to S3
    • aws s3 cp modernomadb.dump s3://jessykate-scratch
  • Import database dump on heroku
  • Run migrations on database
    • heroku run -a embassynetwork-production ./manage.py migrate
  • Do final move of static files
    • s3cmd sync --region us-east-1 -rv webapp/media/* s3://media.embassynetwork.com/public/
  • Do final generation of thumbnails
  • heroku run -a embassynetwork-production ./manage.py generateimages
  • Click around and check everything works on https://embassynetwork-production.herokuapp.com/
  • Swap embassynetwork.com and www.embassynetwork.com on Cloudflare to CNAME embassynetwork-production.herokuapp.com, and switch on Cloudflare
  • Click around and check everything works on https://embassynetwork.com
  • Roll Stripe keys (done after migration so it doesn't break existing environment)
  • Roll Mailgun keys
  • Create scheduled task in Heroku scheduler app
    • 11:00 UTC daily: ./manage.py run_daily_tasks
  • Enable email sending
  • Remove .herokuapp.com from ALLOWED_HOSTS
    • heroku config:set -a embassynetwork-production ALLOWED_HOSTS=embassynetwork.com
  • 🎉
@bfirsh
Copy link
Member Author

bfirsh commented Feb 20, 2019

@jessykate @jonathan-s Filled out everything in the checklist I could think of off the top of my head. Can you think of anything else?

@jonathan-s
Copy link
Collaborator

@bfirsh Can't really think of anything else.

@bfirsh
Copy link
Member Author

bfirsh commented Mar 7, 2019

@jonathan-s

untitled

@bfirsh bfirsh closed this as completed Mar 7, 2019
@jonathan-s
Copy link
Collaborator

jonathan-s commented Mar 7, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants