Skip to content

Commit

Permalink
📝 Document deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
jh0ker committed Oct 29, 2018
1 parent 0f39520 commit 18520b2
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 7 deletions.
4 changes: 4 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -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
50 changes: 43 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stage>` for initial deployment and `zappa update <stage>` 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
}
```

0 comments on commit 18520b2

Please sign in to comment.