-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.yaml
More file actions
155 lines (148 loc) · 3.79 KB
/
docker-compose.yaml
File metadata and controls
155 lines (148 loc) · 3.79 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
services:
database:
image: postgres:17-alpine
container_name: database
restart: always
networks:
- backend
ports:
- 5432:5432
env_file:
- envs/prod/.env
volumes:
- data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
interval: 3s
timeout: 3s
retries: 5
app:
container_name: app
restart: unless-stopped
image: registry.digitalocean.com/meschac38000/fastapi-starter:0.0.6
pull_policy: always
healthcheck:
test: python manage.py healthcheck
interval: 5s
timeout: 5s
retries: 5
start_period: 10s
depends_on:
database:
condition: service_healthy
restart: true
redis_server:
condition: service_healthy
restart: true
networks:
- backend
volumes:
- staticfiles:/home/appuser/app/www/statics # should match settings.STATIC_ROOT (settings/constants.py)
env_file:
- envs/prod/.env
command: ["bash", "./scripts/entrypoint.sh"]
nginx:
image: meschac38000/fastapi.nginx:latest
container_name: nginx
restart: unless-stopped
depends_on:
app:
condition: service_healthy
restart: true
ports:
- "80:80"
- "81:80"
- "443:443"
- "444:443"
labels:
- "traefik.enable=true"
- "traefik.http.routers.app.rule=Host(`lab.eliam-lotonga.fr`)"
- "traefik.http.routers.app.entrypoints=web"
- "traefik.http.services.app.loadbalancer.server.port=8001"
- "traefik.docker.network=traefik"
- "traefik.http.routers.app.middlewares=retry-attempts" # optional
- "traefik.http.middlewares.retry-attempts.retry.attempts=3" # optional
networks:
- backend
- traefik
volumes:
- staticfiles:/static
environment:
- STATICFILES_DIR=/static/
- BACKEND_HOST=app
- SERVER_NAME=api.eliam-lotonga.fr
redis_server:
image: meschac38000/redis-fastapi
pull_policy: always
container_name: redis_server
restart: always
networks:
- backend
env_file:
- ./envs/dev/.env
ports:
- "6379:6379"
volumes:
- redis_data:/data
- ./redis/redis.conf.example:/usr/local/etc/redis/redis.conf
privileged: true
healthcheck:
test: [ "CMD-SHELL", "redis-cli", "--no-auth-warning", "--pass $$REDIS_PASSWORD", "--raw ping | grep PONG" ]
interval: 3s
timeout: 3s
retries: 5
command: sh -c "./entrypoint.sh"
celery_server:
image: registry.digitalocean.com/meschac38000/fastapi-starter:0.0.6
pull_policy: always
container_name: celery_server
restart: on-failure
networks:
- backend
env_file:
- ./envs/prod/.env
command: bash -c "celery -A main.celery worker -n default@%h -Q default --loglevel=INFO"
depends_on:
app:
condition: service_healthy
restart: true
celery_beat:
image: registry.digitalocean.com/meschac38000/fastapi-starter:0.0.6
pull_policy: always
container_name: celery_beat
restart: on-failure
networks:
- backend
depends_on:
app:
condition: service_healthy
restart: true
env_file:
- ./envs/prod/.env
command: bash -c "celery -A main.celery beat --loglevel=INFO"
celery_flower:
container_name: flower
restart: always
image: mher/flower:2.0
ports:
- "5556:5555"
volumes:
- flower_data:/data
env_file:
- envs/prod/.env
networks:
- backend
depends_on:
redis_server:
condition: service_healthy
restart: true
command: sh -c "celery --broker=$$CELERY_BROKER flower"
volumes:
data: {}
redis_data: {}
flower_data: {}
staticfiles: {}
networks:
traefik:
external: true
backend: {}