-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.stack.yml.dist
More file actions
91 lines (85 loc) · 3.39 KB
/
docker-compose.stack.yml.dist
File metadata and controls
91 lines (85 loc) · 3.39 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
# This file is part of the ReactPHP Foundation <https://github.com/itnelo/reactphp-foundation>.
#
# (c) 2020 Pavel Petrov <itnelo@gmail.com>.
#
# For the full copyright and license information, please view the LICENSE
# file that was distributed with this source code.
#
# @license https://opensource.org/licenses/mit MIT
version: '3.8'
services:
app:
image: '${APP_STACK_IMAGE_NAME}:${APP_STACK_IMAGE_VERSION}'
networks:
- back_overlay
deploy:
mode: replicated
replicas: 3
# for cases when we place multiple replicas to a single node; provides all IP addresses to the haproxy
endpoint_mode: dnsrr
placement:
constraints:
- "node.role == worker"
# distribute containers evenly between all available nodes in the swarm by configured geography
preferences:
- spread: node.labels.provider_location_machine
restart_policy:
condition: on-failure
delay: 3s
max_attempts: 3
# time to ensure container is properly restarted
window: 30s
update_config:
parallelism: 1
# restarting containers one by one with some time intervals to prevent complete service denial
# in case when all containers are down simultaneously
delay: 30s
resources:
limits:
cpus: '0.5'
memory: 512M
reservations:
cpus: '0.25'
memory: 256M
haproxy:
image: 'haproxy:${HAPROXY_VERSION}-alpine'
networks:
- back_overlay
ports:
- published: ${HAPROXY_PORT_EXPOSE}
target: 80
protocol: tcp
# to bypass the ingress routing mesh and route requests directly to the local container
mode: host
dns:
# docker dns service at :53; will be polled by the haproxy, according to "resolvers" directive
- 127.0.0.11
# optionally, if we want to preserve access to the worldwide network from the container
- 8.8.8.8
volumes:
- ./docker/dev/haproxy/haproxy.stack.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
deploy:
mode: replicated
replicas: 1
placement:
# fixed place, on the specified swarm node; single instance
constraints:
- "node.role == manager"
restart_policy:
condition: any
delay: 5s
max_attempts: 5
window: 60s
# suggestion: swarmpit (https://github.com/swarmpit/swarmpit)
# use a separate scope for all monitoring/analysis/other tools to keep projects clean and highly cohesive
# you can find an example of compose project configuration for such services here:
# https://github.com/symfony-doge/management-kit
networks:
back_overlay:
driver: overlay
driver_opts:
# to encrypt data transfer between nodes; whenever swarm nodes are in different data centers and no other
# security measures applied
encrypted: ''
# to ensure an external service can access this network
attachable: true