-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
confluence-traefik-letsencrypt-docker-swarm.yml
223 lines (202 loc) · 8.17 KB
/
confluence-traefik-letsencrypt-docker-swarm.yml
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
# Confluence with Let's Encrypt in a Docker Swarm
# Detailed installation guide can be found on my website: https://www.heyvaldemar.com/install-rocket-chat-with-docker-compose/
# Configure Traefik and create secrets for storing the passwords on the Docker Swarm manager node before applying the configuration.
# Traefik configuration: https://github.com/heyValdemar/traefik-letsencrypt-docker-swarm
# Create a secret for storing the password for Confluence database using the command:
# printf "YourPassword" | docker secret create confluence-postgres-password -
# Clear passwords from bash history using the command:
# history -c && history -w
# Run confluence-restore-application-data.sh on the Docker Swarm worker node where the container for backups is running to restore application data if needed.
# Run confluence-restore-database.sh on the Docker Swarm node where the container for backups is running to restore database if needed.
# Run docker stack ps confluence | grep confluence_backups | awk 'NR > 0 {print $4}' on the Docker Swarm manager node to find on which node container for backups is running.
# Deploy Confluence in a Docker Swarm using the command:
# docker stack deploy -c confluence-traefik-letsencrypt-docker-swarm.yml confluence
# Author
# I’m Vladimir Mikhalev, the Docker Captain, but my friends can call me Valdemar.
# https://www.docker.com/captains/vladimir-mikhalev/
# My website with detailed IT guides: https://www.heyvaldemar.com/
# Follow me on YouTube: https://www.youtube.com/channel/UCf85kQ0u1sYTTTyKVpxrlyQ?sub_confirmation=1
# Follow me on Twitter: https://twitter.com/heyValdemar
# Follow me on Instagram: https://www.instagram.com/heyvaldemar/
# Follow me on Threads: https://www.threads.net/@heyvaldemar
# Follow me on Mastodon: https://mastodon.social/@heyvaldemar
# Follow me on Bluesky: https://bsky.app/profile/heyvaldemar.bsky.social
# Follow me on Facebook: https://www.facebook.com/heyValdemarFB/
# Follow me on TikTok: https://www.tiktok.com/@heyvaldemar
# Follow me on LinkedIn: https://www.linkedin.com/in/heyvaldemar/
# Follow me on GitHub: https://github.com/heyvaldemar
# Communication
# Chat with IT pros on Discord: https://discord.gg/AJQGCCBcqf
# Reach me at ask@sre.gg
# Give Thanks
# Support on GitHub: https://github.com/sponsors/heyValdemar
# Support on Patreon: https://www.patreon.com/heyValdemar
# Support on BuyMeaCoffee: https://www.buymeacoffee.com/heyValdemar
# Support on Ko-fi: https://ko-fi.com/heyValdemar
# Support on PayPal: https://www.paypal.com/paypalme/heyValdemarCOM
version: '3.8'
x-default-opts:
&default-opts
logging:
options:
max-size: "10m"
networks:
confluence-network:
driver: overlay
traefik-network:
external: true
volumes:
confluence-data:
confluence-postgres:
confluence-data-backups:
confluence-postgres-backups:
secrets:
confluence-postgres-password:
external: true
services:
postgres:
<<: *default-opts
# Image tag (replace with yours)
image: postgres:14
volumes:
- confluence-postgres:/var/lib/postgresql/data
environment:
# Database name (replace with yours)
POSTGRES_DB: confluencedb
# Database user (replace with yours)
POSTGRES_USER: confluencedbuser
POSTGRES_PASSWORD_FILE: /run/secrets/confluence-postgres-password
networks:
- confluence-network
secrets:
- confluence-postgres-password
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres -h 127.0.0.1"]
interval: 10s
timeout: 5s
retries: 3
start_period: 60s
deploy:
mode: replicated
replicas: 1
placement:
constraints:
- node.role == worker
# Container resources (replace with yours)
resources:
limits:
cpus: '0.55'
memory: 1G
reservations:
cpus: '0.35'
memory: 512M
confluence:
<<: *default-opts
# Image tag (replace with yours)
image: atlassian/confluence-server:7.19
volumes:
- confluence-data:/var/atlassian/application-data/confluence
environment:
# Application memory (replace with yours)
JVM_MINIMUM_MEMORY: 8G
JVM_MAXIMUM_MEMORY: 8G
# Confluence URL (replace with yours)
ATL_PROXY_NAME: confluence.heyvaldemar.net
ATL_PROXY_PORT: 443
ATL_TOMCAT_SCHEME: https
ATL_TOMCAT_SECURE: 'true'
networks:
- confluence-network
- traefik-network
secrets:
- confluence-postgres-password
ports:
- "8091:8091"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8090/"]
interval: 10s
timeout: 5s
retries: 3
start_period: 90s
deploy:
mode: replicated
replicas: 1
placement:
constraints:
- node.role == worker
# Container resources (replace with yours)
resources:
limits:
cpus: '1.55'
memory: 10G
reservations:
cpus: '0.35'
memory: 512M
labels:
- "traefik.enable=true"
# Confluence URL (replace with yours)
- "traefik.http.routers.confluence.rule=Host(`confluence.heyvaldemar.net`)"
- "traefik.http.routers.confluence.service=confluence"
- "traefik.http.routers.confluence.entrypoints=websecure"
- "traefik.http.services.confluence.loadbalancer.server.port=8090"
- "traefik.http.routers.confluence.tls=true"
- "traefik.http.routers.confluence.tls.certresolver=letsencrypt"
- "traefik.http.services.confluence.loadbalancer.passhostheader=true"
- "traefik.http.routers.confluence.middlewares=compresstraefik"
- "traefik.http.middlewares.compresstraefik.compress=true"
depends_on:
- postgres
backups:
<<: *default-opts
# Image tag (replace with yours)
image: postgres:14
# Database backups prune interval (replace with yours). Default is 7 days.
# find /srv/confluence-postgres/backups -type f -mtime +7 | xargs rm -f
# Application data backups prune interval (replace with yours). Default is 7 days.
# find /srv/confluence-application-data/backups -type f -mtime +7 | xargs rm -f
# Confluence backups interval (replace with yours). Default is 1 day.
# sleep 24h
# Run confluence-restore-application-data.sh on the Docker Swarm worker node where the container for backups is running to restore application data if needed.
# Run confluence-restore-database.sh on the Docker Swarm node where the container for backups is running to restore database if needed.
# Run docker stack ps confluence | grep confluence_backups | awk 'NR > 0 {print $4}' on the Docker Swarm manager node to find on which node container for backups is running.
command: sh -c 'sleep 30m
&& while true; do
PGPASSWORD="$$(cat $$POSTGRES_PASSWORD_FILE)"
pg_dump
-h postgres
-p 5432
-d confluencedb
-U confluencedbuser | gzip > /srv/confluence-postgres/backups/confluence-postgres-backup-$$(date "+%Y-%m-%d_%H-%M").gz
&& tar -zcpf /srv/confluence-application-data/backups/confluence-application-data-backup-$$(date "+%Y-%m-%d_%H-%M").tar.gz /var/atlassian/application-data/confluence
&& find /srv/confluence-postgres/backups -type f -mtime +7 | xargs rm -f
&& find /srv/confluence-application-data/backups -type f -mtime +7 | xargs rm -f;
sleep 24h; done'
volumes:
- confluence-data:/var/atlassian/application-data/confluence
# Application data backups location
- confluence-data-backups:/srv/confluence-application-data/backups
# Database backups location
- confluence-postgres-backups:/srv/confluence-postgres/backups
environment:
POSTGRES_PASSWORD_FILE: /run/secrets/confluence-postgres-password
networks:
- confluence-network
secrets:
- confluence-postgres-password
deploy:
mode: replicated
replicas: 1
placement:
constraints:
- node.role == worker
# Container resources (replace with yours)
resources:
limits:
cpus: '0.55'
memory: 1G
reservations:
cpus: '0.35'
memory: 512M
depends_on:
- postgres
- confluence