forked from HackerspaceKRK/apps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
209 lines (197 loc) · 6.48 KB
/
docker-compose.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
version: '3.8'
services:
traefik:
image: traefik:v2.8
container_name: traefik
networks:
- traefik
- system_default
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./traefik.yml:/etc/traefik/traefik.yml
- ./traefik/:/traefik_files/
- traefik_certificates:/traefik/acme
- traefik_letsencrypt:/letsencrypt"
ports:
- target: 80
published: 80
protocol: tcp
mode: host
- target: 443
published: 443
protocol: tcp
mode: host
- target: 5900
published: 5900
protocol: tcp
mode: host
deploy:
labels:
- "traefik.enable=true"
- "traefik.docker.network=system_default"
- "traefik.port=80"
- "traefik.http.services.traefik.loadbalancer.server.port=8080"
- "traefik.http.routers.traefik.rule=Host(`traefik.apps.hskrk.pl`)"
- "traefik.http.routers.traefik.middlewares=authentik@docker"
- "traefik.http.routers.traefik.tls=true"
- "traefik.http.routers.traefik.tls.certresolver=myresolver"
authentik:
image: ${AUTHENTIK_IMAGE:-ghcr.io/goauthentik/server}:${AUTHENTIK_TAG:-2023.6.1}
command: server
environment:
AUTHENTIK_REDIS__HOST: redis
AUTHENTIK_SECRET_KEY: file:///run/secrets/authentik_token
AUTHENTIK_POSTGRESQL__HOST: postgresql
AUTHENTIK_POSTGRESQL__USER: ${PG_USER:-authentik}
AUTHENTIK_POSTGRESQL__NAME: ${PG_DB:-authentik}
AUTHENTIK_POSTGRESQL__PASSWORD: ${PG_PASS:-pass}
env_file:
- .env
ports:
- "9000:9000"
depends_on:
- postgresql
- redis
deploy:
labels:
- "traefik.enable=true"
- "traefik.docker.network=system_default"
- "traefik.http.services.authentik.loadbalancer.server.port=9000"
- "traefik.http.routers.authentik.rule=Host(`auth.apps.hskrk.pl`)"
- "traefik.http.routers.authentik.tls=true"
- "traefik.http.routers.authentik.tls.certresolver=myresolver"
secrets:
- authentik_token
worker:
image: ${AUTHENTIK_IMAGE:-ghcr.io/goauthentik/server}:${AUTHENTIK_TAG:-2023.6.1}
command: worker
environment:
AUTHENTIK_REDIS__HOST: redis
AUTHENTIK_POSTGRESQL__HOST: postgresql
AUTHENTIK_POSTGRESQL__USER: ${PG_USER:-authentik}
AUTHENTIK_POSTGRESQL__NAME: ${PG_DB:-authentik}
AUTHENTIK_POSTGRESQL__PASSWORD: ${PG_PASS:-pass}
AUTHENTIK_SECRET_KEY: file:///run/secrets/authentik_token
user: root
volumes:
- /var/run/docker.sock:/var/run/docker.sock
secrets:
- authentik_token
authentik-proxy:
image: ghcr.io/goauthentik/proxy:${AUTHENTIK_TAG:-2023.6.1}
ports:
- "9091:9000"
environment:
- AUTHENTIK_HOST=http://authentik:9000
- AUTHENTIK_INSECURE=true
- AUTHENTIK_TOKEN=file:///run/secrets/authentik_token
- AUTHENTIK_HOST_BROWSER=https://auth.apps.hskrk.pl
- AUTHENTIK_DEBUG=true
- AUTHENTIK_REDIS__HOST=redis
- AUTHENTIK_REDIS__PORT=6379
depends_on:
- authentik
deploy:
labels:
- "traefik.docker.network=system_default"
- "traefik.enable=true"
- "traefik.http.services.authentik-proxy.loadbalancer.server.port=9000"
- "traefik.http.routers.authentik-proxy.rule=Host(`whoami.apps.hskrk.pl`) && PathPrefix(`/outpost.goauthentik.io/`)"
- "traefik.http.middlewares.authentik.forwardauth.address=http://authentik-proxy:9000/outpost.goauthentik.io/auth/traefik"
- "traefik.http.middlewares.authentik.forwardauth.trustForwardHeader=true"
- "traefik.http.middlewares.authentik.forwardauth.authResponseHeaders=X-authentik-username,X-authentik-groups,X-authentik-email,X-authentik-name,X-authentik-uid,X-authentik-jwt,X-authentik-meta-jwks,X-authentik-meta-outpost,X-authentik-meta-provider,X-authentik-meta-app,X-authentik-meta-version"
secrets:
- authentik_token
whoami:
image: containous/whoami
depends_on:
- authentik-proxy
deploy:
labels:
- "traefik.enable=true"
- "traefik.docker.network=system_default"
- "traefik.port=80"
- "traefik.http.services.whoami.loadbalancer.server.port=80"
- "traefik.http.routers.whoami.rule=Host(`whoami.apps.hskrk.pl`)"
- "traefik.http.routers.whoami.middlewares=authentik@docker"
- "traefik.http.routers.whoami-internal.rule=Host(`whoami.apps.hskrk.pl`) && ClientIP(`10.0.0.0/8`)"
- "traefik.http.routers.whoami-internal.tls=true"
- "traefik.http.routers.whoami.tls=true"
- "traefik.http.routers.whoami.tls.certresolver=myresolver"
postgresql:
image: postgres:12-alpine
healthcheck:
test: [ "CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}" ]
start_period: 20s
interval: 30s
retries: 5
timeout: 5s
volumes:
- database:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: ${PG_PASS:-pass}
POSTGRES_USER: ${PG_USER:-authentik}
POSTGRES_DB: ${PG_DB:-authentik}
redis:
image: redis:alpine
healthcheck:
test: [ "CMD-SHELL", "redis-cli ping | grep PONG" ]
start_period: 20s
interval: 30s
retries: 5
timeout: 3s
swarm-cronjob:
image: crazymax/swarm-cronjob
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
environment:
- "TZ=Europe/Warsaw"
- "LOG_LEVEL=info"
- "LOG_JSON=false"
deploy:
placement:
constraints:
- node.role == manager
restic-backup:
image: restic/restic:latest
hostname: apps
secrets:
- restic_password
- source: backblaze_credentials
target: /root/.aws/credentials
environment:
- RESTIC_REPOSITORY=${RESTIC_REPOSITORY}
- RESTIC_PASSWORD_FILE=/run/secrets/restic_password
- HEALTHCHECKS_URL=${HEALTHCHECKS_URL}
volumes:
- /var/lib/docker/volumes/:/data
- ./backup-script.sh:/backup-script.sh
entrypoint: /backup-script.sh
deploy:
mode: replicated
replicas: 0
labels:
- "swarm.cronjob.enable=true"
- "swarm.cronjob.schedule=05 */2 * * *"
- "swarm.cronjob.skip-running=false"
restart_policy:
condition: none
volumes:
database:
traefik_certificates:
traefik_letsencrypt:
networks:
traefik:
attachable: true
system_default:
external: true
attachable: true
secrets:
pg_pass:
external: true
authentik_token:
external: true
restic_password:
external: true
backblaze_credentials:
external: true