zeroed-some/bashamole / b1924bb

Browse files

prep for initial deployment

Authored by espadonne
SHA
b1924bb58413ce2b68035801ab47c905847b032c
Parents
f94d487
Tree
b2869f3

4 changed files

StatusFile+-
M backend/bashamole/settings.py 22 3
M backend/requirements.txt 4 0
A backend/runtime.txt 1 0
D frontend/src/app/favicon.ico bin
backend/bashamole/settings.pymodified
@@ -9,7 +9,8 @@ https://docs.djangoproject.com/en/5.2/topics/settings/
9
 For the full list of settings and their values, see
9
 For the full list of settings and their values, see
10
 https://docs.djangoproject.com/en/5.2/ref/settings/
10
 https://docs.djangoproject.com/en/5.2/ref/settings/
11
 """
11
 """
12
-
12
+import os
13
+import dj_database_url
13
 from pathlib import Path
14
 from pathlib import Path
14
 
15
 
15
 # Build paths inside the project like this: BASE_DIR / 'subdir'.
16
 # Build paths inside the project like this: BASE_DIR / 'subdir'.
@@ -25,8 +26,22 @@ SECRET_KEY = "django-insecure-xykf5$__a(xn*avfxs2njr#==cn7*+t8kg+4_lbi$(#+@5_j8g
25
 # SECURITY WARNING: don't run with debug turned on in production!
26
 # SECURITY WARNING: don't run with debug turned on in production!
26
 DEBUG = True
27
 DEBUG = True
27
 
28
 
28
-ALLOWED_HOSTS = []
29
+ALLOWED_HOSTS = [
30
+    'localhost',
31
+    '127.0.0.1',
32
+    '.railway.app',
33
+    '.up.railway.app',
34
+]
35
+
36
+# Database - Railway provides DATABASE_URL automatically
37
+if os.environ.get('DATABASE_URL'):
38
+    DATABASES = {
39
+        'default': dj_database_url.parse(os.environ.get('DATABASE_URL'))
40
+    }
29
 
41
 
42
+# Static files
43
+STATIC_URL = '/static/'
44
+STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
30
 
45
 
31
 # Application definition
46
 # Application definition
32
 
47
 
@@ -52,6 +67,7 @@ MIDDLEWARE = [
52
     "django.middleware.clickjacking.XFrameOptionsMiddleware",
67
     "django.middleware.clickjacking.XFrameOptionsMiddleware",
53
     'corsheaders.middleware.CorsMiddleware',
68
     'corsheaders.middleware.CorsMiddleware',
54
     'django.middleware.common.CommonMiddleware',
69
     'django.middleware.common.CommonMiddleware',
70
+    "whitenoise.middleware.WhiteNoiseMiddleware",
55
 ]
71
 ]
56
 
72
 
57
 ROOT_URLCONF = "bashamole.urls"
73
 ROOT_URLCONF = "bashamole.urls"
@@ -135,4 +151,7 @@ CORS_ALLOWED_ORIGINS = [
135
 REST_FRAMEWORK = {
151
 REST_FRAMEWORK = {
136
     'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
152
     'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
137
     'PAGE_SIZE': 100
153
     'PAGE_SIZE': 100
138
-}
154
+}
155
+
156
+if os.environ.get('FRONTEND_URL'):
157
+    CORS_ALLOWED_ORIGINS.append(os.environ.get('FRONTEND_URL'))
backend/requirements.txtmodified
@@ -3,3 +3,7 @@ Django==5.2.3
3
 django-cors-headers==4.7.0
3
 django-cors-headers==4.7.0
4
 djangorestframework==3.16.0
4
 djangorestframework==3.16.0
5
 sqlparse==0.5.3
5
 sqlparse==0.5.3
6
+gunicorn==21.2.0
7
+whitenoise==6.6.0
8
+dj-database-url==2.1.0
9
+psycopg2-binary==2.9.9
backend/runtime.txtadded
@@ -0,0 +1,1 @@
1
+3.11.x
frontend/src/app/favicon.icodeleted
Binary file changed.