Skip to content

Latest commit

 

History

History
74 lines (60 loc) · 2.36 KB

README.md

File metadata and controls

74 lines (60 loc) · 2.36 KB

wdrforyou-cms

CMS for the WDRforyou bot

Django on AWS using Zappa

Our CMS is based on Django and hosted on AWS Lambda using Zappa. It provides a REST-API for wdrforyou-bot.

Local development

We don't advise you to deploy to AWS for local development, as it is quite time consuming to set up.

Copy .env.sample to .env and make adjustments if necessary.

Enable pipenv shell:

$ pipenv sync --dev
$ pipenv shell

Initial setup

$ app/manage.py migrate
$ app/manage.py createsuperuser

Development

To run local development server:

$ app/manage.py runserver

For database migrations use:

$ app/manage.py makemigrations
$ app/manage.py migrate

Alternatively you can run commands without enabling pipenv shell, for example:

$ pipenv run app/manage.py runserver

AWS Deployment

  • Set up an S3 bucket for static files and an IAM user with access to that bucket
  • Create Zappa deployment bucket and update the s3_bucket key in zappa_settings.json
  • Follow this guide to set up an SQL database (Postgres)
  • Follow this guide to give your Lambda functions general internet access
  • Optional: Create an S3 endpoint in your VPC to specifically set up S3 connectivity for your Lambda functions
  • Run zappa deploy <stage>, zappa manage <stage> migrate and ./manage.py collectstatic for initial deployment and zappa update <stage> for updating

Slack Integration

Environment Configuration

You can use the s3-env-config npm package to configure the environment variables in an S3 bucket.

The following environment variables are required:

{
    "DEBUG": "",  // Can be True or False
    "SECRET_KEY": "",  // If DEBUG=False
    "S3_BUCKET_NAME": "",  // S3 bucket for static files
    "AWS_ACCESS_KEY_ID": "",  // Credentials for the bucket
    "AWS_SECRET_ACCESS_KEY": "",
    "DB_NAME": "",
    "DB_USER": "",
    "DB_PASSWORD": "",
    "DB_HOST": "",
    "BOT_SERVICE_ENDPOINT": "", // With trailing slash
    "SLACK_BOT_TOKEN": "", 
    "SLACK_CHANNEL": ""
}