Skip to content

Commit 1cde6e7

Browse files
committed
serverless deployment OK; hit sqlite verson issue;
1 parent d8839e0 commit 1cde6e7

File tree

8 files changed

+9373
-12
lines changed

8 files changed

+9373
-12
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,24 @@ poetry run python manage.py graph_models -o nshm_model.png nshm pipeline
2424
```
2525
poetry run python manage.py dumpdata nshm.OpenquakeHazardTask -o pipeline/fixtures/oht.json --indent=2
2626
poetry run python manage.py loaddata pipeline/fixtures/oht.json
27+
```
28+
29+
### update static files
30+
31+
These are just the static components for admin and graphiql
32+
33+
```
34+
poetry run python manage.py collectstatic -c
35+
```
36+
37+
### run server options
38+
39+
```
40+
poetry run python manage.py runserver
41+
poetry run python manage.py runserver_plus
42+
```
43+
44+
```
45+
poetry shell
46+
npx sls wsgi serve
2747
```

nzshm_model_graphql_api/settings.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
# Build paths inside the project like this: BASE_DIR / 'subdir'.
1616
BASE_DIR = Path(__file__).resolve().parent.parent
1717

18-
1918
# Quick-start development settings - unsuitable for production
2019
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
2120

@@ -25,7 +24,7 @@
2524
# SECURITY WARNING: don't run with debug turned on in production!
2625
DEBUG = True
2726

28-
ALLOWED_HOSTS = []
27+
ALLOWED_HOSTS = ["5qwlrdxd4a.execute-api.ap-southeast-2.amazonaws.com", "localhost"]
2928

3029

3130
# Application definition
@@ -45,6 +44,7 @@
4544

4645
MIDDLEWARE = [
4746
'django.middleware.security.SecurityMiddleware',
47+
'whitenoise.middleware.WhiteNoiseMiddleware',
4848
'django.contrib.sessions.middleware.SessionMiddleware',
4949
'django.middleware.common.CommonMiddleware',
5050
'django.middleware.csrf.CsrfViewMiddleware',
@@ -116,10 +116,6 @@
116116
USE_TZ = True
117117

118118

119-
# Static files (CSS, JavaScript, Images)
120-
# https://docs.djangoproject.com/en/4.2/howto/static-files/
121-
122-
STATIC_URL = 'static/'
123119

124120
# Default primary key field type
125121
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
@@ -130,4 +126,23 @@
130126
GRAPH_MODELS = {
131127
'all_applications': False,
132128
'group_models': True,
133-
}
129+
}
130+
131+
# Static files (CSS, JavaScript, Images)
132+
# https://docs.djangoproject.com/en/4.2/howto/static-files/
133+
134+
STATIC_URL = 'static/'
135+
STATIC_ROOT = str(BASE_DIR / 'staticfiles')
136+
137+
# using whitenoise to simplify static resources
138+
# ref https://whitenoise.readthedocs.io/en/latest/#quickstart-for-django-apps
139+
STORAGES = {
140+
# ...
141+
"staticfiles": {
142+
"BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage",
143+
},
144+
}
145+
146+
SECURE_REFERRER_POLICY = "origin"
147+
SECURE_CONTENT_TYPE_NOSNIFF = False
148+
WHITENOISE_STATIC_PREFIX = "static/"

0 commit comments

Comments
 (0)