-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.yml.j2
266 lines (255 loc) · 6.41 KB
/
docker-compose.yml.j2
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
#jinja2: lstrip_blocks: True
# {{ ansible_managed }}
# Source: https://github.com/netbox-community/netbox-docker/blob/release/docker-compose.yml
services:
{% if netbox_use_caddy and (netbox_ssl_cert_bundle or netbox_caddy_letsencrypt_email) %}
# caddy container for TLS termination
tls:
image: {{netbox_caddy_image}}
restart: unless-stopped
depends_on:
netbox:
condition: service_healthy
volumes:
- type: bind
source: ./Caddyfile
target: "/etc/caddy/Caddyfile"
read_only: true
{% if netbox_ssl_cert_bundle %}
- type: bind
source: "{{netbox_ssl_cert_bundle}}"
target: "/etc/ssl/private/cert.crt"
read_only: true
- type: bind
source: "{{netbox_ssl_cert_key}}"
target: "/etc/ssl/private/key.key"
read_only: true
{% endif %}
- type: volume
source: netbox-caddy-data
target: /data
- type: volume
source: netbox-caddy-config
target: /config
ports:
- "{{netbox_caddy_http_port}}:80" # Allows for http redirection
- "{{netbox_caddy_https_port}}:443"
logging:
driver: "local"
options:
max-size: "10M"
max-file: "10"
{% endif %}
netbox: &netbox
{% if netbox_extra_packages or netbox_plugins %}
build:
context: .
image: {{netbox_netbox_image}}-custom
{% else %}
image: {{netbox_netbox_image}}
{% endif %}
depends_on:
- postgres
- valkey
- valkey-cache
env_file: env/netbox.env
user: "unit:root"
healthcheck:
test: curl -f http://localhost:8080/login/ || exit 1
start_period: 120s
timeout: 3s
interval: 15s
volumes:
{{ netbox_volumes | to_nice_yaml(indent=2) | indent(6, false) }}
- ./nginx-unit.json:/etc/unit/nginx-unit.json:ro
- ./extra.py:/etc/netbox/config/extra.py:ro
security_opt:
- seccomp:unconfined
{% if netbox_port and not netbox_use_caddy %}
ports:
- "{{ netbox_port }}:8080"
{% else %}
expose:
- "8080"
{% endif %}
restart: unless-stopped
{% if netbox_container_labels %}
labels:
{{ netbox_container_labels | to_nice_yaml | indent(6) }}
{% endif %}
networks:
- default
{% if netbox_additional_network_names %}
{% for network in netbox_additional_network_names %}- {{ network }}{% endfor %}
{% endif %}
deploy:
replicas: 1
update_config:
parallelism: 1
delay: 30s
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
window: 120s
logging:
driver: "local"
options:
max-size: "10M"
max-file: "10"
{% if netbox_secrets | length > 0 %}
secrets:
{% for secret in netbox_secrets %}
- {{secret.name}}
{% endfor %}
{% endif %}
netbox-worker: &netbox-worker
<<: *netbox
depends_on:
valkey:
condition: service_healthy
netbox:
condition: service_healthy
command:
- /opt/netbox/venv/bin/python
- /opt/netbox/netbox/manage.py
- rqworker
ports: []
expose: []
labels: []
healthcheck:
test: ps -aux | grep -v grep | grep -q rqworker || exit 1
start_period: 20s
timeout: 3s
interval: 15s
networks:
- default
restart: unless-stopped
deploy:
replicas: {{ netbox_workers }}
update_config:
parallelism: 1
delay: 30s
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
window: 120s
netbox-housekeeping:
<<: *netbox-worker
command:
- /opt/netbox/housekeeping.sh
healthcheck:
test: ps -aux | grep -v grep | grep -q housekeeping || exit 1
start_period: 20s
timeout: 3s
interval: 15s
deploy:
replicas: 1
postgres:
image: {{ netbox_postgres_image }}
env_file: env/postgres.env
volumes:
- netbox-postgres-data:/var/lib/postgresql/data
networks:
- default
restart: unless-stopped
healthcheck:
test: pg_isready -q -t 2 -d $$POSTGRES_DB -U $$POSTGRES_USER
start_period: 20s
timeout: 30s
interval: 10s
retries: 5
logging:
driver: "local"
options:
max-size: "10M"
max-file: "10"
{% if netbox_pgbackups_enabled %}
pgbackups:
image: {{ netbox_pgbackups_image }}
restart: unless-stopped
env_file: "env/pgbackups.env"
volumes:
- type: bind
source: "{{ netbox_base_path }}/backups"
target: "/backups"
links:
- postgres
depends_on:
- postgres
logging:
driver: "local"
options:
max-size: "10M"
max-file: "10"
{% endif %}
valkey:
image: {{ netbox_valkey_image }}
command:
- sh
- -c # this is to evaluate the $VALKEY_PASSWORD from the env
- valkey-server --appendonly yes --requirepass $$VALKEY_PASSWORD ## $$ because of docker-compose
env_file: env/valkey.env
volumes:
- netbox-valkey-data:/data
networks:
- default
restart: unless-stopped
healthcheck: &valkey-healthcheck
test: '[ $$(valkey-cli --pass "$${VALKEY_PASSWORD}" ping) = ''PONG'' ]'
start_period: 5s
timeout: 3s
interval: 1s
retries: 5
logging:
driver: "local"
options:
max-size: "10M"
max-file: "10"
valkey-cache:
image: {{ netbox_valkey_image }}
command:
- sh
- -c # this is to evaluate the $VALKEY_PASSWORD from the env
- valkey-server --requirepass $$VALKEY_PASSWORD ## $$ because of docker-compose
env_file: env/valkey-cache.env
volumes:
- netbox-valkey-cache-data:/data
networks:
- default
restart: unless-stopped
healthcheck: *valkey-healthcheck
logging:
driver: "local"
options:
max-size: "10M"
max-file: "10"
volumes:
netbox-media-files:
driver: local
netbox-postgres-data:
driver: local
netbox-valkey-data:
driver: local
netbox-valkey-cache-data:
driver: local
{% if netbox_use_caddy %}
netbox-caddy-data:
netbox-caddy-config:
{% endif %}
{% if netbox_additional_network_names %}
networks:
{% for network in netbox_additional_network_names %}
{{ network }}:
name: {{ network }}
external: true
{% endfor %}
{% endif %}
{% if netbox_secrets is defined and netbox_secrets | length > 0 %}
secrets:
{% for secret in netbox_secrets %}
{{secret.name}}:
file: {{secret.path}}
{% endfor %}
{% endif %}