Closed
Description
EPIC: #7
As a system owner I can deploy and re-deploy the system with MVP functionality so that the site operates as expected with MVP functionality
Assumptions or Pre-Requisites:
- Basic site setup is in place EPIC: Project, workspace and core site setup #1
- Debug mode set to FALSE (note that this is now set using an environment variable so longer-term solution)
- First Deploy has been performed and any lessons learned incorporated
- Possibly some additional configuration settings needed in Heroku for MVP deploy (vs first deploy)
Acceptance Criteria: (Must be completed before task is moved to 'Done')
- Must be able to build app inHeroku
- Must be able to run app once built
Tasks - Build ElephantSQL Database
- Start with ElephantSQL and verify database in place... YIKES not there (first deployment took different approach)
- Install psycopg2, dj_database_url - and freeze requirements
- Export data from existing database: python3 manage.py dumpdata products > products.json
- Settings.py: import dj_database_url. Commment out existing DATABASES = and replace with DATABASES= { default: dj_database_url(<my_database_url_from_elephant>)}
- python3 manage.py showmigrations - should see a list of migrations to be applied to the database I am now connected to (the elephantsql database)
- python3 manage.py migrate - to apply all the database structures to the new database
- IF USING FIXTURES to load JSON data: python3 manage.py loaddata categories; python3 manage.py loaddata products;
- create database superuser(s)
- revert database settings in settings.py, remove URL to new ElephantSQL database and save/commit
Tasks - load Data into ElephantSQL database
- Check migrations in ElephantSQL - open up the ElephantSQL console
- Browser - table queries - auth user - execute - should see superuser(s) setup in previous task
- OOPs - just realised - becuase I'm not using JSON I will need to manually key the data into my Production database
Tasks - Prepare to Deploy
- setup secret_key and retrieve it from the environment (refer to 'Deploying to Heroku')
- Add Stripe fields to config variables in Heroku
- If not already done, add a conditional statement into settings.py to link to appropriate database depending on env settings
- Ensure gunicorn is installed to act as web server & freeze
- set Heroku config DISABLE_COLLECTSTATIC to 1 to prevent Heroku from trying to collect static files when we deploy
- create Procfile in root directory to tell Heroku to treat this as a python app/ create a web dyno: web: gunicorn jeweller.wsgi --log-file -
- settings.py ALLOWED_HOSTS = ... Heroku_deployment_name
- commit changes and attempt to build from Heroku
Tasks - Build & Test (without static)
- BUILD IN HEROKU:
- Usual craic with deploy - build
Tasks - Configure AWS for Static files
- CONFIGURE AWS FOR STATIC FILES
- Create bucket,set to public access
- Properties tab - scroll to bottom - static - enable, set default index.html error.html, Save Changes (This gives a new endpoint accessible from internet)
- Permissions tab - scroll to CORS , set to below, then Save Changes
[{"AllowedHeaders": ["Authorization"],
"AllowedMethods": ["GET"],
"AllowedOrigins": ["*"],
"ExposeHeaders": []}] - Permissions tab - Bucket Policy - Edit - Policy generator: type S3 Bucket policy; Allow all Principals *; Action: GetObject; ARN: (paste from other tab); AddStatement button; SaveChanges button; GeneratePolicy button; (copy to other tab); insert */ at end of Resource string; SaveChanges button.
- Permissions tab - ACL - Edit - Grant Public: ListAccess; override message; SaveChanges
Tasks - SET AWS IAM (Identity and Access Management)
- Create Group
- Create Access Policy, attach policy to Group,
- Create user, attach user to Group
- Generate keys
Tasks - TRANSFER STATIC FILES FROM DEV TO PROD
- Install boto and django-storages, freeze and add 'storages' to installed apps
- Configure settings.py to use AWS for static and media storage
- Create file custom_storages.py and add some content...
- Commit, build deployment
- Test app
Metadata
Metadata
Assignees
Projects
Status
Done