File tree Expand file tree Collapse file tree 3 files changed +22
-5
lines changed
samples/django-channels-redis Expand file tree Collapse file tree 3 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -31,4 +31,4 @@ RUN adduser --disabled-password --gecos '' django
31
31
USER django
32
32
33
33
# Start server
34
- CMD ["sh" , "-c" , "python manage.py migrate && gunicorn django_defang.wsgi:application --bind 0.0.0.0: 8000" ]
34
+ CMD ["sh" , "-c" , "python manage.py migrate && daphne -b 0.0.0.0 -p 8000 django_defang.asgi:application " ]
Original file line number Diff line number Diff line change 15
15
import dj_database_url
16
16
import urllib .parse
17
17
18
+
19
+ # print redis and postgres urls
20
+ print ('@@@@@@@ DEBUG @@@@@@@' )
21
+ print (f'redis: { os .getenv ("REDIS_URL" , None )} ' )
22
+ print (f'postgres: { os .getenv ("POSTGRES_URL" , None )} ' )
23
+ print (f'postgres_password: { os .getenv ("POSTGRES_PASSWORD" , None )} ' )
24
+ postgres_url = os .getenv ("POSTGRES_URL" , None )
25
+ postgres_password = os .getenv ("POSTGRES_PASSWORD" , None )
26
+ fixed_postgres_url = postgres_url .replace ("password" , postgres_password ) if postgres_url and postgres_password else postgres_url
27
+ print (f'fixed_postgres_url: { fixed_postgres_url } ' )
28
+ print ('@@@@@@@ DEBUG @@@@@@@' )
29
+
30
+
18
31
# Build paths inside the project like this: BASE_DIR / 'subdir'.
19
32
BASE_DIR = Path (__file__ ).resolve ().parent .parent
20
33
82
95
# Database
83
96
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases
84
97
98
+
85
99
DATABASES = {
86
100
# default is a postrgres database load from environment variable POSTGRES_URL
87
101
"default" : dj_database_url .config (
88
- default = os . environ . get ( 'POSTGRES_URL' )
102
+ default = fixed_postgres_url
89
103
)
90
104
}
91
105
160
174
"hosts" : [(redis_host , redis_port )],
161
175
},
162
176
},
163
- }
177
+ }
Original file line number Diff line number Diff line change @@ -13,7 +13,8 @@ services:
13
13
mode : ingress
14
14
environment :
15
15
REDIS_URL : redis://redis_service:6379
16
- POSTGRES_URL : postgres://postgres:password@postgres_service:5432
16
+ POSTGRES_URL : postgres://postgres:password@postgres_service:5432/postgres
17
+ POSTGRES_PASSWORD : testtest
17
18
healthcheck :
18
19
# wget or curl required for healthchecks on services with a published port
19
20
# this gets parsed by Defang and provided to the load balancers as well
@@ -31,4 +32,6 @@ services:
31
32
x-defang-postgres : true
32
33
ports :
33
34
- mode : host
34
- target : 5432
35
+ target : 5432
36
+ environment :
37
+ POSTGRES_PASSWORD : testtest
You can’t perform that action at this time.
0 commit comments