Add settings for S3 storage and Grapple/GraphQL

This commit is contained in:
Ramon Wenger 2022-11-17 15:19:27 +01:00
parent 4d32e99c8c
commit 7b4860f170
4 changed files with 151 additions and 10 deletions

View File

@ -97,6 +97,9 @@ THIRD_PARTY_APPS = [
"wagtail.api.v2",
"modelcluster",
"taggit",
"storages",
"grapple",
"graphene_django",
]
LOCAL_APPS = [
@ -190,12 +193,23 @@ STATICFILES_FINDERS = [
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
]
USE_AWS = env("USE_AWS", False)
AWS_STORAGE_BUCKET_NAME = env("AWS_STORAGE_BUCKET_NAME", "")
AWS_ACCESS_KEY_ID = env("AWS_ACCESS_KEY_ID", "")
AWS_SECRET_ACCESS_KEY = env("AWS_SECRET_ACCESS_KEY", "")
AWS_S3_CUSTOM_DOMAIN = "%s.s3.amazonaws.com" % AWS_STORAGE_BUCKET_NAME
# MEDIA
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#media-root
MEDIA_ROOT = str(APPS_DIR / "media")
# https://docs.djangoproject.com/en/dev/ref/settings/#media-url
MEDIA_URL = "/server/media/"
if USE_AWS:
# https://wagtail.org/blog/amazon-s3-for-media-files/
MEDIA_URL = "https://%s/" % AWS_S3_CUSTOM_DOMAIN
DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
else:
MEDIA_URL = "/server/media/"
IT_SERVE_VUE = env.bool("IT_SERVE_VUE", DEBUG)
IT_SERVE_VUE_URL = env("IT_SERVE_VUE_URL", "http://localhost:5173")
@ -550,6 +564,13 @@ OAUTH = {
},
}
GRAPHENE = {"SCHEMA": "grapple.schema.schema", "SCHEMA_OUTPUT": "schema.graphql"}
GRAPPLE = {
"EXPOSE_GRAPHIQL": DEBUG,
"APPS": ["core", "course", "learnpath", "competence", "media_library"],
}
if APP_ENVIRONMENT == "development":
# http://whitenoise.evans.io/en/latest/django.html#using-whitenoise-in-development
INSTALLED_APPS = ["whitenoise.runserver_nostatic"] + INSTALLED_APPS # noqa F405

View File

@ -4,12 +4,12 @@
#
# pip-compile --output-file=requirements-dev.txt requirements-dev.in
#
aniso8601==7.0.0
# via graphene
anyascii==0.3.1
# via wagtail
anyio==3.5.0
# via watchfiles
appnope==0.1.2
# via ipython
argon2-cffi==21.3.0
# via -r requirements.in
argon2-cffi-bindings==21.2.0
@ -37,6 +37,14 @@ black==22.10.0
# via
# -r requirements-dev.in
# ufmt
boto3==1.26.11
# via -r requirements.in
botocore==1.29.11
# via
# boto3
# s3transfer
brotli==1.0.9
# via whitenoise
build==0.8.0
# via pip-tools
certifi==2021.10.8
@ -97,6 +105,7 @@ django==3.2.13
# django-modelcluster
# django-permissionedforms
# django-redis
# django-storages
# django-stubs
# django-stubs-ext
# django-taggit
@ -104,7 +113,9 @@ django==3.2.13
# django-watchfiles
# djangorestframework
# drf-spectacular
# graphene-django
# wagtail
# wagtail-grapple
# wagtail-localize
django-click==2.3.0
# via -r requirements.in
@ -132,6 +143,8 @@ django-ratelimit==3.0.1
# via -r requirements.in
django-redis==5.2.0
# via -r requirements.in
django-storages==1.13.1
# via -r requirements.in
django-stubs==1.10.1
# via
# -r requirements-dev.in
@ -181,6 +194,18 @@ gitdb2==4.0.2
# via gitpython
gitpython==3.0.6
# via trufflehog
graphene==2.1.9
# via graphene-django
graphene-django==2.15.0
# via wagtail-grapple
graphql-core==2.3.2
# via
# graphene
# graphene-django
# graphql-relay
# wagtail-grapple
graphql-relay==2.0.1
# via graphene
gunicorn==20.1.0
# via -r requirements.in
h11==0.13.0
@ -213,6 +238,10 @@ jedi==0.18.1
# via ipython
jinja2==3.1.1
# via coreschema
jmespath==1.0.1
# via
# boto3
# botocore
jsonschema==4.4.0
# via drf-spectacular
l18n==2021.3
@ -289,6 +318,11 @@ portalocker==2.4.0
# via concurrent-log-handler
pre-commit==2.17.0
# via -r requirements-dev.in
promise==2.3
# via
# graphene-django
# graphql-core
# graphql-relay
prompt-toolkit==3.0.28
# via ipython
psycopg2-binary==2.9.3
@ -329,7 +363,9 @@ pytest-django==4.5.2
pytest-sugar==0.9.4
# via -r requirements-dev.in
python-dateutil==2.8.2
# via faker
# via
# botocore
# faker
python-dotenv==0.20.0
# via
# environs
@ -360,15 +396,27 @@ requests==2.27.1
# coreapi
# djangorestframework-stubs
# wagtail
rx==1.6.1
# via graphql-core
s3transfer==0.6.0
# via boto3
sentry-sdk==1.5.8
# via -r requirements.in
singledispatch==3.7.0
# via graphene-django
six==1.16.0
# via
# asttokens
# django-coverage-plugin
# graphene
# graphene-django
# graphql-core
# graphql-relay
# html5lib
# l18n
# promise
# python-dateutil
# singledispatch
# virtualenv
smmap==5.0.0
# via gitdb
@ -395,7 +443,9 @@ termcolor==1.1.0
testfixtures==6.18.5
# via flake8-isort
text-unidecode==1.3
# via python-slugify
# via
# graphene-django
# python-slugify
toml==0.10.2
# via
# ipdb
@ -448,6 +498,7 @@ uritemplate==4.1.1
# drf-spectacular
urllib3==1.26.9
# via
# botocore
# requests
# sentry-sdk
usort==1.0.5
@ -462,9 +513,15 @@ wagtail==3.0.1
# via
# -r requirements.in
# wagtail-factories
# wagtail-grapple
# wagtail-headless-preview
# wagtail-localize
wagtail-factories==2.0.1
# via -r requirements.in
wagtail-grapple==0.18.0
# via -r requirements.in
wagtail-headless-preview==0.4.0
# via wagtail-grapple
wagtail-localize==1.2.1
# via -r requirements.in
watchfiles==0.17.0
@ -479,7 +536,7 @@ websockets==10.2
# via uvicorn
wheel==0.37.1
# via pip-tools
whitenoise==6.0.0
whitenoise[brotli]==6.0.0
# via -r requirements.in
willow==1.4.1
# via wagtail

View File

@ -3,7 +3,7 @@ pytz # https://github.com/stub42/pytz
python-slugify # https://github.com/un33k/python-slugify
Pillow # https://github.com/python-pillow/Pillow
argon2-cffi # https://github.com/hynek/argon2_cffi
whitenoise # https://github.com/evansd/whitenoise
whitenoise[brotli] # https://github.com/evansd/whitenoise
redis # https://github.com/redis/redis-py
uvicorn[standard] # https://github.com/encode/uvicorn
environs
@ -23,6 +23,7 @@ django-click
django-ratelimit
django-ipware
django-csp
django-storages
psycopg2-binary
gunicorn
@ -35,3 +36,6 @@ concurrent-log-handler
wagtail>=3,<4
wagtail-factories
wagtail-localize
wagtail_grapple
boto3

View File

@ -4,6 +4,8 @@
#
# pip-compile --output-file=requirements.txt requirements.in
#
aniso8601==7.0.0
# via graphene
anyascii==0.3.1
# via wagtail
anyio==3.5.0
@ -22,6 +24,14 @@ authlib==1.0.0
# via -r requirements.in
beautifulsoup4==4.9.3
# via wagtail
boto3==1.26.11
# via -r requirements.in
botocore==1.29.11
# via
# boto3
# s3transfer
brotli==1.0.9
# via whitenoise
certifi==2021.10.8
# via
# requests
@ -55,11 +65,14 @@ django==3.2.13
# django-modelcluster
# django-permissionedforms
# django-redis
# django-storages
# django-taggit
# django-treebeard
# djangorestframework
# drf-spectacular
# graphene-django
# wagtail
# wagtail-grapple
# wagtail-localize
django-click==2.3.0
# via -r requirements.in
@ -81,6 +94,8 @@ django-ratelimit==3.0.1
# via -r requirements.in
django-redis==5.2.0
# via -r requirements.in
django-storages==1.13.1
# via -r requirements.in
django-taggit==2.1.0
# via wagtail
django-treebeard==4.5.1
@ -102,6 +117,18 @@ factory-boy==3.2.1
# via wagtail-factories
faker==13.11.1
# via factory-boy
graphene==2.1.9
# via graphene-django
graphene-django==2.15.0
# via wagtail-grapple
graphql-core==2.3.2
# via
# graphene
# graphene-django
# graphql-relay
# wagtail-grapple
graphql-relay==2.0.1
# via graphene
gunicorn==20.1.0
# via -r requirements.in
h11==0.13.0
@ -116,6 +143,10 @@ idna==3.3
# requests
inflection==0.5.1
# via drf-spectacular
jmespath==1.0.1
# via
# boto3
# botocore
jsonschema==4.4.0
# via drf-spectacular
l18n==2021.3
@ -136,6 +167,11 @@ polib==1.1.1
# via wagtail-localize
portalocker==2.4.0
# via concurrent-log-handler
promise==2.3
# via
# graphene-django
# graphql-core
# graphql-relay
psycopg2-binary==2.9.3
# via -r requirements.in
pycparser==2.21
@ -145,7 +181,9 @@ pyparsing==3.0.7
pyrsistent==0.18.1
# via jsonschema
python-dateutil==2.8.2
# via faker
# via
# botocore
# faker
python-dotenv==0.20.0
# via
# environs
@ -171,13 +209,25 @@ redis==4.2.1
# django-redis
requests==2.27.1
# via wagtail
rx==1.6.1
# via graphql-core
s3transfer==0.6.0
# via boto3
sentry-sdk==1.5.8
# via -r requirements.in
singledispatch==3.7.0
# via graphene-django
six==1.16.0
# via
# graphene
# graphene-django
# graphql-core
# graphql-relay
# html5lib
# l18n
# promise
# python-dateutil
# singledispatch
sniffio==1.2.0
# via anyio
soupsieve==2.3.2.post1
@ -191,13 +241,16 @@ tablib[xls,xlsx]==3.2.1
telepath==0.2
# via wagtail
text-unidecode==1.3
# via python-slugify
# via
# graphene-django
# python-slugify
typing-extensions==4.2.0
# via wagtail-localize
uritemplate==4.1.1
# via drf-spectacular
urllib3==1.26.9
# via
# botocore
# requests
# sentry-sdk
uvicorn[standard]==0.18.3
@ -208,9 +261,15 @@ wagtail==3.0.1
# via
# -r requirements.in
# wagtail-factories
# wagtail-grapple
# wagtail-headless-preview
# wagtail-localize
wagtail-factories==2.0.1
# via -r requirements.in
wagtail-grapple==0.18.0
# via -r requirements.in
wagtail-headless-preview==0.4.0
# via wagtail-grapple
wagtail-localize==1.2.1
# via -r requirements.in
watchfiles==0.17.0
@ -219,7 +278,7 @@ webencodings==0.5.1
# via html5lib
websockets==10.2
# via uvicorn
whitenoise==6.0.0
whitenoise[brotli]==6.0.0
# via -r requirements.in
willow==1.4.1
# via wagtail