Skip to content

Commit aa6aa4b

Browse files
authored
Merge pull request #4030 from airqo-platform/staging
Move to production
2 parents d862897 + 8fda031 commit aa6aa4b

File tree

9 files changed

+88
-17
lines changed

9 files changed

+88
-17
lines changed

k8s/auth-service/values-prod.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ app:
66
replicaCount: 3
77
image:
88
repository: eu.gcr.io/airqo-250220/airqo-auth-api
9-
tag: prod-e6ae0ed1-1733589497
9+
tag: prod-d862897c-1733743392
1010
nameOverride: ''
1111
fullnameOverride: ''
1212
podAnnotations: {}

k8s/exceedance/values-prod-airqo.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ app:
44
configmap: env-exceedance-production
55
image:
66
repository: eu.gcr.io/airqo-250220/airqo-exceedance-job
7-
tag: prod-e6ae0ed1-1733589497
7+
tag: prod-d862897c-1733743392
88
nameOverride: ''
99
fullnameOverride: ''

k8s/exceedance/values-prod-kcca.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ app:
44
configmap: env-exceedance-production
55
image:
66
repository: eu.gcr.io/airqo-250220/kcca-exceedance-job
7-
tag: prod-e6ae0ed1-1733589497
7+
tag: prod-d862897c-1733743392
88
nameOverride: ''
99
fullnameOverride: ''

k8s/predict/values-prod.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ images:
77
predictJob: eu.gcr.io/airqo-250220/airqo-predict-job
88
trainJob: eu.gcr.io/airqo-250220/airqo-train-job
99
predictPlaces: eu.gcr.io/airqo-250220/airqo-predict-places-air-quality
10-
tag: prod-e6ae0ed1-1733589497
10+
tag: prod-d862897c-1733743392
1111
api:
1212
name: airqo-prediction-api
1313
label: prediction-api

k8s/spatial/values-prod.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ app:
66
replicaCount: 3
77
image:
88
repository: eu.gcr.io/airqo-250220/airqo-spatial-api
9-
tag: prod-e6ae0ed1-1733589497
9+
tag: prod-d862897c-1733743392
1010
nameOverride: ''
1111
fullnameOverride: ''
1212
podAnnotations: {}

k8s/website/values-prod.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ app:
66
replicaCount: 3
77
image:
88
repository: eu.gcr.io/airqo-250220/airqo-website-api
9-
tag: prod-e6ae0ed1-1733589497
9+
tag: prod-d862897c-1733743392
1010
nameOverride: ''
1111
fullnameOverride: ''
1212
podAnnotations: {}

k8s/workflows/values-prod.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ images:
1010
initContainer: eu.gcr.io/airqo-250220/airqo-workflows-xcom
1111
redisContainer: eu.gcr.io/airqo-250220/airqo-redis
1212
containers: eu.gcr.io/airqo-250220/airqo-workflows
13-
tag: prod-e6ae0ed1-1733589497
13+
tag: prod-d862897c-1733743392
1414
nameOverride: ''
1515
fullnameOverride: ''
1616
podAnnotations: {}

src/website/core/settings.py

+80-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import os
32
import sys
43
from pathlib import Path
@@ -55,7 +54,8 @@ def require_env_var(env_var: str) -> str:
5554
SECRET_KEY = require_env_var('SECRET_KEY')
5655
DEBUG = get_env_bool('DEBUG', default=False)
5756

58-
ALLOWED_HOSTS = parse_env_list("ALLOWED_HOSTS")
57+
# ALLOWED_HOSTS = parse_env_list("ALLOWED_HOSTS")
58+
ALLOWED_HOSTS = ['*']
5959

6060
# ---------------------------------------------------------
6161
# Application Definitions
@@ -100,7 +100,7 @@ def require_env_var(env_var: str) -> str:
100100
# Middleware
101101
# ---------------------------------------------------------
102102
MIDDLEWARE = [
103-
'corsheaders.middleware.CorsMiddleware',
103+
'corsheaders.middleware.CorsMiddleware', # Must be first
104104
'django.middleware.security.SecurityMiddleware',
105105
'whitenoise.middleware.WhiteNoiseMiddleware',
106106
'django.contrib.sessions.middleware.SessionMiddleware',
@@ -114,11 +114,75 @@ def require_env_var(env_var: str) -> str:
114114
# ---------------------------------------------------------
115115
# CORS and CSRF Configuration
116116
# ---------------------------------------------------------
117-
CORS_ORIGIN_ALLOW_ALL = False
118-
CORS_ALLOWED_ORIGINS = parse_env_list("CORS_ALLOWED_ORIGINS")
119-
CORS_ORIGIN_REGEX_WHITELIST = parse_env_list("CORS_ORIGIN_REGEX_WHITELIST")
120-
CSRF_TRUSTED_ORIGINS = parse_env_list("CSRF_TRUSTED_ORIGINS")
121-
117+
if DEBUG:
118+
# Allow all CORS origins during development
119+
CORS_ORIGIN_ALLOW_ALL = True
120+
CORS_ALLOWED_ORIGINS = []
121+
CORS_ORIGIN_REGEX_WHITELIST = []
122+
123+
# Allow all CSRF origins during development
124+
CSRF_TRUSTED_ORIGINS = [
125+
"https://website-trigger-3-website-preview-w7kzhvlewq-ew.a.run.app",
126+
]
127+
128+
# Optionally, you can add more relaxed settings
129+
# For example, allow specific subdomains or ports if needed
130+
else:
131+
# Restrict CORS origins in production
132+
CORS_ORIGIN_ALLOW_ALL = False
133+
CORS_ALLOWED_ORIGINS = [
134+
"https://staging-dot-airqo-frontend.appspot.com",
135+
"https://staging.airqo.net",
136+
"https://airqo.net",
137+
"https://airqo.africa",
138+
"https://airqo.org",
139+
"https://airqo.mak.ac.ug",
140+
"http://127.0.0.1:8000",
141+
"http://localhost:3000",
142+
"https://staging-platform.airqo.net",
143+
"https://staging-analytics.airqo.net",
144+
"https://analytics.airqo.net",
145+
"https://platform.airqo.net",
146+
]
147+
CORS_ORIGIN_REGEX_WHITELIST = [
148+
# Matches subdomains under airqo.net, airqo.africa, airqo.org, airqo.io
149+
r"^https://[a-zA-Z0-9_\-]+\.airqo\.(net|africa|org|io)$",
150+
# Matches airqo.africa, airqo.org, and airqo.mak.ac.ug
151+
r"^https://airqo\.(africa|org|mak\.ac\.ug)$",
152+
# Matches staging-dot-airqo-frontend.appspot.com
153+
r"^https://staging-dot-airqo-frontend\.appspot\.com$",
154+
r"^https://staging-platform\.airqo\.net$", # Matches staging-platform.airqo.net
155+
# Matches staging-analytics.airqo.net
156+
r"^https://staging-analytics\.airqo\.net$",
157+
r"^https://analytics\.airqo\.net$", # Matches analytics.airqo.net
158+
r"^https://platform\.airqo\.net$", # Matches platform.airqo.net
159+
# Matches any subpath under https://platform.airqo.net/website/admin
160+
r"^https://platform\.airqo\.net/website/admin.*$",
161+
# Matches any subpath under https://staging-platform.airqo.net/website/admin
162+
r"^https://staging-platform\.airqo\.net/website/admin.*$",
163+
]
164+
165+
# Trust specific origins for CSRF protection in production
166+
# CSRF_TRUSTED_ORIGINS = parse_env_list("CSRF_TRUSTED_ORIGINS")
167+
CSRF_TRUSTED_ORIGINS = [
168+
"https://staging-dot-airqo-frontend.appspot.com",
169+
"https://staging.airqo.net",
170+
"https://airqo.net",
171+
"https://airqo.africa",
172+
"https://airqo.org",
173+
"https://airqo.mak.ac.ug",
174+
"http://127.0.0.1:8000",
175+
"http://localhost:3000",
176+
"https://*.cloudshell.dev",
177+
"https://staging-platform.airqo.net",
178+
"https://staging-analytics.airqo.net",
179+
"https://analytics.airqo.net",
180+
"https://platform.airqo.net",
181+
"https://website-trigger-3-website-preview-w7kzhvlewq-ew.a.run.app",
182+
]
183+
184+
185+
# Security settings
122186
CSRF_COOKIE_SECURE = not DEBUG
123187
SESSION_COOKIE_SECURE = not DEBUG
124188

@@ -190,7 +254,6 @@ def require_env_var(env_var: str) -> str:
190254
STATICFILES_DIRS = [BASE_DIR / 'static']
191255
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
192256

193-
194257
if DEBUG:
195258
# Local file storage for development
196259
MEDIA_URL = '/media/'
@@ -231,7 +294,11 @@ def require_env_var(env_var: str) -> str:
231294
# ---------------------------------------------------------
232295
# File Upload Limits
233296
# ---------------------------------------------------------
234-
MAX_UPLOAD_SIZE = 10 * 1024 * 1024 # 10MB
297+
# Define a constant for maximum upload size
298+
MAX_UPLOAD_SIZE_MB = 10 # Maximum upload size in MB
299+
MAX_UPLOAD_SIZE = MAX_UPLOAD_SIZE_MB * 1024 * 1024 # Convert to bytes
300+
301+
# Apply the maximum upload size to Django settings
235302
DATA_UPLOAD_MAX_MEMORY_SIZE = MAX_UPLOAD_SIZE
236303
FILE_UPLOAD_MAX_MEMORY_SIZE = MAX_UPLOAD_SIZE
237304

@@ -254,6 +321,9 @@ def require_env_var(env_var: str) -> str:
254321
},
255322
}
256323

324+
# ---------------------------------------------------------
325+
# Quill Editor Configuration
326+
# ---------------------------------------------------------
257327
QUILL_CONFIGS = {
258328
'default': {
259329
'theme': 'snow',

src/website/entrypoint.sh

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ python manage.py collectstatic --noinput
1414
# Start Gunicorn server to serve the Django application
1515
echo "Starting Gunicorn server..."
1616
exec gunicorn core.wsgi:application --bind 0.0.0.0:8000 --timeout 600 --log-level info
17+
# exec gunicorn core.wsgi:application --bind 0.0.0.0:8000 --timeout 600 --workers ${GUNICORN_WORKERS:-3} --log-level info

0 commit comments

Comments
 (0)