diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000..d54b275 --- /dev/null +++ b/.env.sample @@ -0,0 +1,4 @@ +DEBUG=True +AWS_REGION=eu-central-1 +ENV_BUCKET_NAME=newsforyou-cms-config-jhoeke +BOT_SERVICE_ENDPOINT=127.0.0.0 diff --git a/README.md b/README.md index cbe814e..8b32310 100644 --- a/README.md +++ b/README.md @@ -7,26 +7,62 @@ It provides a REST-API for [wdrforyou-bot](https://github.com/wdr-data/wdrforyou ## Local development -We don't advise to deploy to AWS for local development, as it is quite time consuming to set up. Test locally using: +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: -``` +```bash $ pipenv shell ``` -To run local development server: +### Initial setup +```bash +$ app/manage.py migrate +$ app/manage.py createsuperuser ``` + +### Development +To run local development server: +```bash $ app/manage.py runserver ``` For database migrations use: -``` +```bash $ 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``` +```bash +$ 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](https://edgarroman.github.io/zappa-django-guide/walk_database/) to set up an SQL database (Postgres) +- Follow [this guide](https://aws.amazon.com/premiumsupport/knowledge-center/internet-access-lambda-function/) 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 ` for initial deployment and `zappa update ` for updating -## Deployment -TBD +### 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: + +```json +{ + "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 +} +```