Skip to content

Commit 6308d1b

Browse files
authored
Merge pull request #144 from Kitware/add-aws-deployment-config
Add config class for using AWS
2 parents 1c7b513 + 270672a commit 6308d1b

5 files changed

Lines changed: 39 additions & 0 deletions

File tree

.markdownlint.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
MD013:
2+
line_length: 120

DEPLOYMENT.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,21 @@ django-admin interface and make sure you have the trailing '/' on the URL.
106106

107107
There is no email server connected up so users need to be
108108
individually approved and their email verified by an admin
109+
110+
## Using AWS S3
111+
112+
In order to use AWS S3 as your storage service, you'll need
113+
to make sure to start the Django application with the correct configuration.
114+
115+
As a starting point for configuring your environment, see [dev/.env.prod.s3.template](dev/.env.prod.s3/template)
116+
for a list of environment variables that you'll need to populate for your deployment.
117+
118+
- `DJANGO_CONFIGURATION` this is used by
119+
[django_configurations](https://django-configurations.readthedocs.io/en/stable/)
120+
to read in the correct set of environment variables. The value `AwsProductionConfiguation`
121+
should be used when using S3 as storage
122+
- `DJANGO_DATABASE_*` these variables tell django how to connect to your postgres database.
123+
The `_URL` should be a postgres connection string, e.g. `postgres://user:password@postgres:5432/django`
124+
- `DJANGO_CELERY_BROKER_URL` is used to make sure django can send tasks to the `celery` service.
125+
For example, if using [RabbitMQ](https://www.rabbitmq.com/), it might look like this: `amqp://rabbitmq:5672`
126+
- `AWS_*` and `DJANGO_STORAGE_BUCKET_NAME` are used to make sure the application can connect to your S3 bucket

bats_ai/settings.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
DevelopmentBaseConfiguration,
1010
HerokuProductionBaseConfiguration,
1111
ProductionBaseConfiguration,
12+
S3StorageMixin,
1213
TestingBaseConfiguration,
1314
)
1415
from composed_configuration._configuration import _BaseConfiguration
@@ -115,3 +116,7 @@ class ProductionConfiguration(BatsAiMixin, ProductionBaseConfiguration):
115116

116117
class HerokuProductionConfiguration(BatsAiMixin, HerokuProductionBaseConfiguration):
117118
pass
119+
120+
121+
class AwsProductionConfiguration(BatsAiMixin, S3StorageMixin):
122+
pass

dev/.env.prod.s3.template

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
DJANGO_CONFIGURATION=AwsProductionConfiguration
2+
DJANGO_DATABASE_NAME=django
3+
DJANGO_DATABASE_PASSWORD=
4+
DJANGO_DATABASE_URL=
5+
DJANGO_CELERY_BROKER_URL=
6+
DJANGO_MINIO_STORAGE_ENDPOINT=
7+
SERVERHOSTNAME=
8+
DJANGO_SECRET_KEY=
9+
DOCKER_POSTGRES_PORT=
10+
AWS_DEFAULT_REGION=
11+
AWS_ACCESS_KEY_ID=
12+
AWS_SECRET_ACCESS_KEY=
13+
DJANGO_STORAGE_BUCKET_NAME=

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
'djangorestframework',
5050
'drf-yasg',
5151
'django-click',
52+
'django-storages[s3]',
5253
# Production-only
5354
'django-composed-configuration[prod]>=0.20',
5455
'django-s3-file-field[boto3]<1',

0 commit comments

Comments
 (0)