-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
133 lines (125 loc) · 3.78 KB
/
docker-compose.yml
File metadata and controls
133 lines (125 loc) · 3.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
services:
# --- NGINX (The Gateway) ---
study_nginx:
container_name: study_nginx
image: nginx:alpine
# Expose port 8000 on localhost only, mapping to internal Nginx port 80
ports:
- "127.0.0.1:8000:80"
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
- static_volume:/app/staticfiles # Read-only access to static files
depends_on:
- study_backend_wsgi
- study_backend_asgi
networks:
- leantime-net
# --- WSGI Service (Standard HTTP requests) ---
study_backend_wsgi:
container_name: study_backend_wsgi
build: .
# Runs Migrations + Gunicorn (Stable HTTP server)
# Note: 'cert_study' must match your actual inner project folder name
command: sh -c "python manage.py migrate && python manage.py collectstatic --noinput && gunicorn cert_study.wsgi:application --bind 0.0.0.0:8000"
volumes:
- .:/app
- static_volume:/app/staticfiles # Writes static files here for Nginx to see
networks:
- leantime-net
depends_on:
- study_db
- study_redis
- study_rabbitmq
env_file:
- .env
environment:
- DB_HOST=study_db
- REDIS_HOST=study_redis
- RABBITMQ_HOST=study_rabbitmq
- CELERY_BROKER_URL=amqp://guest:guest@study_rabbitmq:5672//
- CELERY_RESULT_BACKEND=redis://study_redis:6379/0
- DJANGO_ALLOWED_HOSTS=${DJANGO_ALLOWED_HOSTS}
- CSRF_TRUSTED_ORIGINS=${CSRF_TRUSTED_ORIGINS}
# --- ASGI Service (WebSockets / Channels) ---
study_backend_asgi:
container_name: study_backend_asgi
build: .
# Runs Daphne (WebSocket server) on port 8001
command: daphne -b 0.0.0.0 -p 8001 cert_study.asgi:application
volumes:
- .:/app
networks:
- leantime-net
depends_on:
- study_db
- study_redis
- study_rabbitmq
env_file:
- .env
environment:
- DB_HOST=study_db
- REDIS_HOST=study_redis
- RABBITMQ_HOST=study_rabbitmq
- CELERY_BROKER_URL=amqp://guest:guest@study_rabbitmq:5672//
- CELERY_RESULT_BACKEND=redis://study_redis:6379/0
- DJANGO_SETTINGS_MODULE=cert_study.settings
- DJANGO_ALLOWED_HOSTS=${DJANGO_ALLOWED_HOSTS}
- CSRF_TRUSTED_ORIGINS=${CSRF_TRUSTED_ORIGINS}
# --- Celery Worker ---
study_celery:
container_name: study_celery
build: .
command: celery -A cert_study worker --loglevel=info
volumes:
- .:/app
networks:
- leantime-net
depends_on:
- study_backend_wsgi # Wait for migrations to finish in WSGI container
- study_redis
- study_rabbitmq
env_file:
- .env
environment:
- DB_HOST=study_db
- REDIS_HOST=study_redis
- RABBITMQ_HOST=study_rabbitmq
- CELERY_BROKER_URL=amqp://guest:guest@study_rabbitmq:5672//
- CELERY_RESULT_BACKEND=redis://study_redis:6379/0
- DJANGO_SETTINGS_MODULE=cert_study.settings
- DJANGO_ALLOWED_HOSTS=${DJANGO_ALLOWED_HOSTS}
- CSRF_TRUSTED_ORIGINS=${CSRF_TRUSTED_ORIGINS}
# --- Database (PostgreSQL) ---
study_db:
container_name: study_db
image: postgres:17
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- leantime-net
env_file:
- .env
environment:
- POSTGRES_DB=${DB_NAME}
- POSTGRES_USER=${DB_USER}
- POSTGRES_PASSWORD=${DB_PASSWORD}
# --- Redis ---
study_redis:
container_name: study_redis
image: redis:7-alpine
networks:
- leantime-net
# --- RabbitMQ ---
study_rabbitmq:
container_name: study_rabbitmq
image: rabbitmq:3-management
networks:
- leantime-net
volumes:
postgres_data:
static_volume: # New shared volume for static files
networks:
# Connect to the existing network where Nginx and Authelia live
leantime-net:
external: true
name: ${DOCKER_NETWORK_NAME}