-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-compose.yaml
More file actions
183 lines (177 loc) · 4.64 KB
/
Copy pathdocker-compose.yaml
File metadata and controls
183 lines (177 loc) · 4.64 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
services:
api:
build:
context: ./api
dockerfile: Dockerfile
args:
API_INTERNAL_PORT: ${API_INTERNAL_PORT:-3000}
PRISMA_STUDIO_PORT: ${PRISMA_STUDIO_PORT:-9081}
API_MODE: ${API_MODE:-development}
MODE: ${MODE:-api/dev/v1}
API_VERSION: ${API_VERSION:-1.0.0}
image: mrdasdeveloper/nodejs-backend-with-postgresql:base
container_name: nodejs-backend
restart: unless-stopped
env_file: .env
# volumes:
# - ./api:/api
ports:
- "${API_DEBUG_PORT:-3000}:3000"
- "${PRISMA_STUDIO_PORT:-9081}:${PRISMA_STUDIO_PORT:-9081}"
networks:
- nodejs_backend_with_postgresql_network
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
interval: 10s
timeout: 5s
retries: 10
start_period: 60s
deploy:
resources:
limits:
cpus: '4'
memory: 4G
reservations:
cpus: '1'
memory: 1G
db:
image: postgres:17-alpine
container_name: nodejs-backend-db
restart: unless-stopped
environment:
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
POSTGRES_DB: ${POSTGRES_DB:-nodejs_backend}
PGDATA: /var/lib/postgresql/data/pgdata
volumes:
- nodejs_postgres_data:/var/lib/postgresql/data
# ports:
# # - "${POSTGRES_PORT:-5432}:5432"
networks:
- nodejs_backend_with_postgresql_network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres} -d ${POSTGRES_DB:-nodejs_backend}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
deploy:
resources:
limits:
cpus: '2'
memory: 2G
reservations:
cpus: '0.5'
memory: 512M
redis:
image: redis:7.4-alpine
container_name: nodejs-backend-redis
restart: unless-stopped
command: >
sh -c "if [ -n \"$$REDIS_PASSWORD\" ]; then
redis-server --requirepass \"$$REDIS_PASSWORD\";
else
redis-server;
fi"
environment:
- REDIS_PASSWORD=${REDIS_PASSWORD:-}
networks:
- nodejs_backend_with_postgresql_network
healthcheck:
test: >
sh -c "if [ -n \"$$REDIS_PASSWORD\" ]; then
redis-cli -a \"$$REDIS_PASSWORD\" ping;
else
redis-cli ping;
fi"
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
deploy:
resources:
limits:
cpus: '1'
memory: 512M
reservations:
cpus: '0.25'
memory: 128M
nginx:
image: nginx:alpine
container_name: nodejs-backend-nginx
restart: unless-stopped
env_file:
- .env
environment:
- PROXY_PORT=${PROXY_PORT:-9080}
ports:
- "${PROXY_PORT:-9080}:80"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./nginx/proxy.conf:/etc/nginx/proxy.conf:ro
- ./nginx/security.conf:/etc/nginx/security.conf:ro
- ./nginx/conf.d:/etc/nginx/conf.d:ro
- ./nginx/log:/var/log/nginx
depends_on:
api:
condition: service_healthy
networks:
- nodejs_backend_with_postgresql_network
healthcheck:
test: ["CMD-SHELL", "test -f /var/run/nginx.pid && ps aux | grep -v grep | grep nginx || exit 1"]
interval: 30s
timeout: 10s
retries: 5
start_period: 60s
deploy:
resources:
limits:
cpus: '1'
memory: 256M
reservations:
cpus: '0.25'
memory: 64M
pgadmin:
image: dpage/pgadmin4:latest
container_name: nodejs-backend-pgadmin
restart: unless-stopped
env_file:
- .env
environment:
- PGADMIN_DEFAULT_EMAIL=${PGADMIN_EMAIL:-admin@example.com}
- PGADMIN_DEFAULT_PASSWORD=${PGADMIN_PASSWORD:-admin@123}
- PGADMIN_CONFIG_SERVER_MODE=True
- PGADMIN_CONFIG_MASTER_PASSWORD_REQUIRED=False
- PGADMIN_LISTEN_ADDRESS=0.0.0.0
- PGADMIN_LISTEN_PORT=80
ports:
- "${PGADMIN_PORT:-5050}:80"
volumes:
- nodejs_pgadmin_data:/var/lib/pgadmin
depends_on:
db:
condition: service_healthy
networks:
- nodejs_backend_with_postgresql_network
deploy:
resources:
limits:
cpus: '1'
memory: 1G
reservations:
cpus: '0.25'
memory: 256M
volumes:
nodejs_postgres_data:
driver: local
nodejs_pgadmin_data:
driver: local
networks:
nodejs_backend_with_postgresql_network:
external: true
driver: bridge