Skip to content

Commit 73dc0a1

Browse files
committed
Add docker compose profile for emulating production
1 parent a557506 commit 73dc0a1

File tree

3 files changed

+100
-0
lines changed

3 files changed

+100
-0
lines changed

backend/docker-compose.yaml

+50
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,53 @@ services:
1515
image: redis:4.0
1616
ports:
1717
- "6379:6379"
18+
proddev-backend-wsgi:
19+
depends_on:
20+
- db
21+
- redis
22+
profiles:
23+
- proddev
24+
build:
25+
context: .
26+
dockerfile: Dockerfile
27+
ports:
28+
- "8001:80"
29+
environment:
30+
- DATABASE_URL=postgres://postgres:postgres@db:5432/postgres
31+
- DJANGO_SETTINGS_MODULE=officehoursqueue.settings.proddev
32+
command: sh -c "python manage.py migrate && { DJANGO_SUPERUSER_PASSWORD=root python manage.py createsuperuser --no-input --username root --email [email protected]; /usr/local/bin/django-run; }"
33+
proddev-backend-asgi:
34+
depends_on:
35+
- db
36+
- redis
37+
profiles:
38+
- proddev
39+
build:
40+
context: .
41+
dockerfile: Dockerfile
42+
ports:
43+
- "8002:80"
44+
environment:
45+
- DATABASE_URL=postgres://postgres:postgres@db:5432/postgres
46+
- DJANGO_SETTINGS_MODULE=officehoursqueue.settings.proddev
47+
command: sh -c "python manage.py migrate && { DJANGO_SUPERUSER_PASSWORD=root python manage.py createsuperuser --no-input --username root --email [email protected]; /usr/local/bin/asgi-run; }"
48+
proddev-frontend:
49+
profiles:
50+
- proddev
51+
build:
52+
context: ../frontend
53+
dockerfile: ../frontend/Dockerfile
54+
ports:
55+
- "8003:80"
56+
nginx:
57+
image: nginx:latest
58+
depends_on:
59+
- proddev-backend-wsgi
60+
- proddev-backend-asgi
61+
- proddev-frontend
62+
profiles:
63+
- proddev
64+
ports:
65+
- "8000:80"
66+
volumes:
67+
- ./nginx-proddev.conf:/etc/nginx/nginx.conf:ro

backend/nginx-proddev.conf

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
events { }
2+
3+
http {
4+
server {
5+
listen 80;
6+
7+
location / {
8+
proxy_pass http://proddev-frontend:3000;
9+
proxy_set_header Host $host;
10+
proxy_set_header X-Real-IP $remote_addr;
11+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
12+
}
13+
14+
location ~ ^/(api|admin|assets) {
15+
proxy_pass http://proddev-backend-wsgi:80;
16+
proxy_set_header Host $host;
17+
proxy_set_header X-Real-IP $remote_addr;
18+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
19+
}
20+
21+
location /api/ws {
22+
proxy_pass http://proddev-backend-asgi:80;
23+
proxy_set_header Host $host;
24+
proxy_set_header X-Real-IP $remote_addr;
25+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
26+
27+
# For web sockets
28+
proxy_http_version 1.1;
29+
proxy_set_header Upgrade $http_upgrade;
30+
proxy_set_header Connection "Upgrade";
31+
}
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from officehoursqueue.settings.production import *
2+
3+
import officehoursqueue.settings.base as base
4+
5+
DEBUG = True
6+
7+
SECURE_PROXY_SSL_HEADER = ()
8+
9+
ALLOWED_HOSTS = ["*"]
10+
11+
PLATFORM_ACCOUNTS = base.PLATFORM_ACCOUNTS
12+
13+
# Allow http callback for DLA
14+
os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1"
15+
16+
# Use the console for email in development
17+
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"

0 commit comments

Comments
 (0)