forked from benavlabs/FastAPI-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
141 lines (131 loc) · 3.17 KB
/
docker-compose.yml
File metadata and controls
141 lines (131 loc) · 3.17 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
version: '3.8'
services:
web:
build:
context: .
dockerfile: Dockerfile
# -------- replace with comment to run with gunicorn --------
command: uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
# command: gunicorn app.main:app -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:8000
env_file:
- ./src/.env
# -------- replace with comment if you are using nginx --------
ports:
- "8000:8000"
# expose:
# - "8000"
depends_on:
db:
condition: service_healthy
redis:
condition: service_started
volumes:
- ./src/app:/code/app
- ./src/.env:/code/.env
- ./src/alembic.ini:/code/alembic.ini
- ./src/migrations:/code/migrations
worker:
build:
context: .
dockerfile: Dockerfile.worker # Sử dụng Dockerfile riêng cho worker
command: arq app.core.worker.settings.WorkerSettings
env_file:
- ./src/.env
depends_on:
web:
condition: service_started # Đợi web service (và migrations) hoàn thành
redis:
condition: service_started
volumes:
- ./src/app:/code/app
- ./src/.env:/code/.env
db:
image: postgres:13
env_file:
- ./src/.env
volumes:
- postgres-data:/var/lib/postgresql/data
# -------- replace with comment to run migrations with docker --------
expose:
- "5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 5s
retries: 5
redis:
image: redis:alpine
volumes:
- redis-data:/data
expose:
- "6379"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 5s
retries: 5
#-------- uncomment to run with pgadmin --------
# pgadmin:
# container_name: pgadmin4
# image: dpage/pgadmin4:latest
# restart: always
# ports:
# - "5050:80"
# volumes:
# - pgadmin-data:/var/lib/pgadmin
# env_file:
# - ./src/.env
# depends_on:
# - db
#-------- uncomment to run with nginx --------
# nginx:
# image: nginx:latest
# ports:
# - "80:80"
# volumes:
# - ./default.conf:/etc/nginx/conf.d/default.conf
# depends_on:
# - web
#-------- uncomment to create first superuser --------
# create_superuser:
# build:
# context: .
# dockerfile: Dockerfile
# env_file:
# - ./src/.env
# depends_on:
# - db
# - web
# command: python -m src.scripts.create_first_superuser
# volumes:
# - ./src:/code/src
#-------- uncomment to run tests --------
# pytest:
# build:
# context: .
# dockerfile: Dockerfile
# env_file:
# - ./src/.env
# depends_on:
# - db
# - redis
# command: python -m pytest ./tests
# volumes:
# - .:/code
#-------- uncomment to create first tier --------
# create_tier:
# build:
# context: .
# dockerfile: Dockerfile
# env_file:
# - ./src/.env
# depends_on:
# - db
# - web
# command: python -m src.scripts.create_first_tier
# volumes:
# - ./src:/code/src
volumes:
postgres-data:
redis-data:
#pgadmin-data: