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", "wagtail.api.v2",
"modelcluster", "modelcluster",
"taggit", "taggit",
"storages",
"grapple",
"graphene_django",
] ]
LOCAL_APPS = [ LOCAL_APPS = [
@ -190,11 +193,22 @@ STATICFILES_FINDERS = [
"django.contrib.staticfiles.finders.AppDirectoriesFinder", "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 # MEDIA
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#media-root # https://docs.djangoproject.com/en/dev/ref/settings/#media-root
MEDIA_ROOT = str(APPS_DIR / "media") MEDIA_ROOT = str(APPS_DIR / "media")
# https://docs.djangoproject.com/en/dev/ref/settings/#media-url # https://docs.djangoproject.com/en/dev/ref/settings/#media-url
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/" MEDIA_URL = "/server/media/"
IT_SERVE_VUE = env.bool("IT_SERVE_VUE", DEBUG) IT_SERVE_VUE = env.bool("IT_SERVE_VUE", DEBUG)
@ -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": if APP_ENVIRONMENT == "development":
# http://whitenoise.evans.io/en/latest/django.html#using-whitenoise-in-development # http://whitenoise.evans.io/en/latest/django.html#using-whitenoise-in-development
INSTALLED_APPS = ["whitenoise.runserver_nostatic"] + INSTALLED_APPS # noqa F405 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 # pip-compile --output-file=requirements-dev.txt requirements-dev.in
# #
aniso8601==7.0.0
# via graphene
anyascii==0.3.1 anyascii==0.3.1
# via wagtail # via wagtail
anyio==3.5.0 anyio==3.5.0
# via watchfiles # via watchfiles
appnope==0.1.2
# via ipython
argon2-cffi==21.3.0 argon2-cffi==21.3.0
# via -r requirements.in # via -r requirements.in
argon2-cffi-bindings==21.2.0 argon2-cffi-bindings==21.2.0
@ -37,6 +37,14 @@ black==22.10.0
# via # via
# -r requirements-dev.in # -r requirements-dev.in
# ufmt # 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 build==0.8.0
# via pip-tools # via pip-tools
certifi==2021.10.8 certifi==2021.10.8
@ -97,6 +105,7 @@ django==3.2.13
# django-modelcluster # django-modelcluster
# django-permissionedforms # django-permissionedforms
# django-redis # django-redis
# django-storages
# django-stubs # django-stubs
# django-stubs-ext # django-stubs-ext
# django-taggit # django-taggit
@ -104,7 +113,9 @@ django==3.2.13
# django-watchfiles # django-watchfiles
# djangorestframework # djangorestframework
# drf-spectacular # drf-spectacular
# graphene-django
# wagtail # wagtail
# wagtail-grapple
# wagtail-localize # wagtail-localize
django-click==2.3.0 django-click==2.3.0
# via -r requirements.in # via -r requirements.in
@ -132,6 +143,8 @@ django-ratelimit==3.0.1
# via -r requirements.in # via -r requirements.in
django-redis==5.2.0 django-redis==5.2.0
# via -r requirements.in # via -r requirements.in
django-storages==1.13.1
# via -r requirements.in
django-stubs==1.10.1 django-stubs==1.10.1
# via # via
# -r requirements-dev.in # -r requirements-dev.in
@ -181,6 +194,18 @@ gitdb2==4.0.2
# via gitpython # via gitpython
gitpython==3.0.6 gitpython==3.0.6
# via trufflehog # 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 gunicorn==20.1.0
# via -r requirements.in # via -r requirements.in
h11==0.13.0 h11==0.13.0
@ -213,6 +238,10 @@ jedi==0.18.1
# via ipython # via ipython
jinja2==3.1.1 jinja2==3.1.1
# via coreschema # via coreschema
jmespath==1.0.1
# via
# boto3
# botocore
jsonschema==4.4.0 jsonschema==4.4.0
# via drf-spectacular # via drf-spectacular
l18n==2021.3 l18n==2021.3
@ -289,6 +318,11 @@ portalocker==2.4.0
# via concurrent-log-handler # via concurrent-log-handler
pre-commit==2.17.0 pre-commit==2.17.0
# via -r requirements-dev.in # via -r requirements-dev.in
promise==2.3
# via
# graphene-django
# graphql-core
# graphql-relay
prompt-toolkit==3.0.28 prompt-toolkit==3.0.28
# via ipython # via ipython
psycopg2-binary==2.9.3 psycopg2-binary==2.9.3
@ -329,7 +363,9 @@ pytest-django==4.5.2
pytest-sugar==0.9.4 pytest-sugar==0.9.4
# via -r requirements-dev.in # via -r requirements-dev.in
python-dateutil==2.8.2 python-dateutil==2.8.2
# via faker # via
# botocore
# faker
python-dotenv==0.20.0 python-dotenv==0.20.0
# via # via
# environs # environs
@ -360,15 +396,27 @@ requests==2.27.1
# coreapi # coreapi
# djangorestframework-stubs # djangorestframework-stubs
# wagtail # wagtail
rx==1.6.1
# via graphql-core
s3transfer==0.6.0
# via boto3
sentry-sdk==1.5.8 sentry-sdk==1.5.8
# via -r requirements.in # via -r requirements.in
singledispatch==3.7.0
# via graphene-django
six==1.16.0 six==1.16.0
# via # via
# asttokens # asttokens
# django-coverage-plugin # django-coverage-plugin
# graphene
# graphene-django
# graphql-core
# graphql-relay
# html5lib # html5lib
# l18n # l18n
# promise
# python-dateutil # python-dateutil
# singledispatch
# virtualenv # virtualenv
smmap==5.0.0 smmap==5.0.0
# via gitdb # via gitdb
@ -395,7 +443,9 @@ termcolor==1.1.0
testfixtures==6.18.5 testfixtures==6.18.5
# via flake8-isort # via flake8-isort
text-unidecode==1.3 text-unidecode==1.3
# via python-slugify # via
# graphene-django
# python-slugify
toml==0.10.2 toml==0.10.2
# via # via
# ipdb # ipdb
@ -448,6 +498,7 @@ uritemplate==4.1.1
# drf-spectacular # drf-spectacular
urllib3==1.26.9 urllib3==1.26.9
# via # via
# botocore
# requests # requests
# sentry-sdk # sentry-sdk
usort==1.0.5 usort==1.0.5
@ -462,9 +513,15 @@ wagtail==3.0.1
# via # via
# -r requirements.in # -r requirements.in
# wagtail-factories # wagtail-factories
# wagtail-grapple
# wagtail-headless-preview
# wagtail-localize # wagtail-localize
wagtail-factories==2.0.1 wagtail-factories==2.0.1
# via -r requirements.in # 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 wagtail-localize==1.2.1
# via -r requirements.in # via -r requirements.in
watchfiles==0.17.0 watchfiles==0.17.0
@ -479,7 +536,7 @@ websockets==10.2
# via uvicorn # via uvicorn
wheel==0.37.1 wheel==0.37.1
# via pip-tools # via pip-tools
whitenoise==6.0.0 whitenoise[brotli]==6.0.0
# via -r requirements.in # via -r requirements.in
willow==1.4.1 willow==1.4.1
# via wagtail # via wagtail

View File

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

View File

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