-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yaml
134 lines (124 loc) · 2.93 KB
/
docker-compose.yaml
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
#version: '3'
networks:
api_net:
driver: bridge
services:
nginx:
image: nginx:latest
container_name: nginx
ports:
- ${NGINX_PORT}:80
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
- socket_volume:/tmp
- nginx_logs:/var/log/nginx
- ./static:/usr/share/nginx/html
- ./media:/usr/share/nginx/media
depends_on:
- micro_blog
networks:
- api_net
stop_grace_period: 5s
db:
image: postgres:16.3
container_name: api_db
restart: always
ports:
- ${POSTGRES_PORT}:5432
volumes:
- postgres_storage:/var/lib/postgresql/data
- postgres_logs:/logs_postgres
shm_size: 256mb
environment:
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${POSTGRES_DB}
- POSTGRES_MAX_CONNECTIONS=200
command:
- --log_destination=stderr
- --logging_collector=on
- --log_directory=./logs_postgres/
- --max_connections=200
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}" ]
interval: 10s
timeout: 5s
retries: 5
networks:
- api_net
adminer:
container_name: adminer
image: adminer:4.8.1
restart: always
ports:
- ${ADMINER_PORT}:8080
networks:
- api_net
environment:
- ADMINER_DESIGN=${ADMINER_DESIGN}
- ADMINER_DEFAULT_SERVER=${ADMINER_DEFAULT_SERVER}
depends_on:
- db
micro_blog:
build:
dockerfile: Dockerfile
context: ./
container_name: micro_blog
image: micro_blog:${VERSION_API}
environment:
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_HOST=${POSTGRES_HOST}
- POSTGRES_DB=${POSTGRES_DB}
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PORT=${POSTGRES_PORT}
- JWT_PRIVATE_KEY=${JWT_PRIVATE}
- JWT_PUBLIC_KEY=${JWT_PUBLIC}
command:
- /app/start.sh
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
networks:
- api_net
volumes:
- socket_volume:/tmp
- api_logs:/var/log/nginx
env_file:
- .env
stop_grace_period: 10s
redis:
image: redis:7.4-alpine
container_name: redis_server
restart: always
command: >
redis-server
--requirepass ${REDIS_PASSWORD}
healthcheck:
test: [ "CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "ping" ]
interval: 10s
timeout: 5s
retries: 5
environment:
- REDIS_TIMEOUT=${REDIS_TIMEOUT}
- REDIS_LOGLEVEL=${REDIS_LOGLEVEL}
- REDIS_PASSWORD=${REDIS_PASSWORD}
ports:
- ${REDIS_PORT}:6379
networks:
- api_net
deploy:
resources:
limits:
cpus: 0.5
memory: 256M
reservations:
cpus: 0.25
memory: 256M
volumes:
postgres_storage: { }
socket_volume: { }
nginx_logs: { }
postgres_logs: { }
api_logs: { }