-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
346 lines (267 loc) · 9.28 KB
/
docker-compose.yml
File metadata and controls
346 lines (267 loc) · 9.28 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
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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
volumes:
ffun_postgresql_data_18: {}
ffun_caddy_data: {}
ffun_caddy_markers: {}
ffun_filebrowser_database: {}
networks:
ffun_network:
driver: bridge
ipam:
config:
- subnet: 172.22.0.0/16
x-backend-api-environment: &backend-api-environment
FFUN_ENABLE_API_SPA: "${FFUN_ENABLE_API_SPA:-True}"
FFUN_ENABLE_API_ROOT: "${FFUN_ENABLE_API_ROOT:-True}"
FFUN_ENABLE_SENTRY: "${FFUN_ENABLE_SENTRY:-False}"
FFUN_SENTRY__DSN: "${FFUN_SENTRY__DSN:-not-specified}"
# set to /repository/feeds_collections/collections in case you want to use the default collection
FFUN_FEEDS_COLLECTIONS_COLLECTION_CONFIGS: "${FFUN_FEEDS_COLLECTIONS_COLLECTION_CONFIGS-}"
x-backend-api: &backend-api
image: ffun-backend-dev
depends_on:
postgresql:
condition: service_healthy
command:
- /bin/bash
- -c
- |
poetry run ffun migrate
echo "migrations successed"
poetry run uvicorn ffun.application.application:app --host 0.0.0.0 --port 8000 --workers 1 --reload
volumes:
- ${PWD}/ffun:/repository
- ${PWD}/.env:/repository/.env
- ${PWD}/.configs:/repository/.configs
- ${PWD}/.shared:/repository/.shared
- ${PWD}/feeds_collections:/repository/feeds_collections
environment:
<<: *backend-api-environment
networks:
ffun_network:
aliases:
- backend
services:
postgresql:
image: postgres:18.3-trixie
volumes:
- type: tmpfs
target: /var/lib/postgresql/18/docker
tmpfs:
size: 2g
- ./docker/dev/postgresql/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
- ./docker/dev/postgresql/healthcheck.sh:/healthcheck.sh
environment:
POSTGRES_MULTIPLE_DATABASES: ffun,keycloak
# set to root because of the bug in pg_isready (?) it
# it looks like it expect the DB name be the same as the POSTGRES_USER
POSTGRES_DB: root
POSTGRES_USER: root
POSTGRES_PASSWORD: root
ports:
- "5432:5432"
networks:
ffun_network: {}
healthcheck:
test: "/healthcheck.sh"
interval: 1s
timeout: 5s
retries: 10
idp:
image: tiendil/keycloak-simple:latest
profiles: ["multi-user"]
depends_on:
postgresql:
condition: service_healthy
volumes:
- ./docker/dev/keycloak/import:/opt/keycloak/data/import:ro
environment:
KC_BOOTSTRAP_ADMIN_USERNAME: admin
KC_BOOTSTRAP_ADMIN_PASSWORD: admin
KC_DB: postgres
KC_DB_URL_HOST: postgresql
KC_DB_URL_PORT: "5432"
KC_DB_URL_DATABASE: keycloak
KC_DB_USERNAME: keycloak
KC_DB_PASSWORD: keycloak
KC_HTTP_ENABLED: "true"
KC_PROXY_HEADERS: xforwarded
KC_HOSTNAME_STRICT: "false"
KC_HEALTH_ENABLED: "true"
KC_MANAGEMENT_ENABLED: "true"
command: start --optimized --import-realm
networks:
ffun_network: {}
healthcheck:
test: >
bash -c "exec 3<>/dev/tcp/127.0.0.1/9000 &&
printf 'HEAD /health/ready HTTP/1.1\r\nHost: localhost:9000\r\nConnection: close\r\n\r\n' >&3 &&
grep -q 'HTTP/1.1 200 OK' <&3"
interval: 1s
timeout: 5s
retries: 10
start_period: 60s
auth-proxy-multi-user:
profiles: ["multi-user"]
depends_on:
backend-multi-user:
condition: service_started
idp:
condition: service_healthy
networks:
ffun_network:
aliases:
- auth-proxy
#############################################################
# OAuth2 Proxy is now recomened proxy for OIDC authentication
#############################################################
image: quay.io/oauth2-proxy/oauth2-proxy:v7.13.0-alpine
volumes:
- ./docker/dev/oauth2-proxy/config.cfg:/etc/oauth2-proxy/config.cfg:ro
- ./docker/dev/oauth2-proxy/config-alpha.yaml:/etc/oauth2-proxy/config-alpha.yaml:ro
- ./docker/dev/oauth2-proxy/templates:/etc/oauth2-proxy/templates:ro
- ffun_caddy_data:/caddy-data:ro
command: --config /etc/oauth2-proxy/config.cfg --alpha-config /etc/oauth2-proxy/config-alpha.yaml
########
# APISIX
########
# image: apache/apisix:3.14.1-ubuntu
# volumes:
# - ./docker/dev/apisix/apisix.yaml:/usr/local/apisix/conf/apisix.yaml:ro
# - ./docker/dev/apisix/config.yaml:/usr/local/apisix/conf/config.yaml:ro
# environment:
# APISIX_STAND_ALONE: "true"
####################################################
# Pomerium for testing aduptability of OIDC setup
# How to turn on:
# - frontend (spa) should be placed behind Pomerium auth-proxy (Caddyfile)
# - add auth.feeds.fun.local domain pointing to he Pomerium auth-proxy (/etc/hosts, Caddyfile, Keycloak client)
# - remove "pkce.code.challenge.method" from the Keycloak auth-proxy-client settings
# Known problems:
# - Can not smartly redirect user to login/registration page.
# - Makes +1 redirect on the root of the SPA with custom URL query (that's why we need to place SPA behind Pomerium)
# - Uses hardcoded technical URLs, lile /.pomerium/*
####################################################
# image: pomerium/pomerium:v0.31
# volumes:
# - ./docker/dev/pomerium/config.yaml:/pomerium/config.yaml:ro
# - ffun_caddy_data:/caddy-data:ro
# environment:
# POMERIUM_DEBUG: "true"
auth-proxy-single-user:
image: inanimate/echo-server
profiles: ["single-user"]
environment:
PORT: "8000"
ADD_HEADERS: '{"X-FFun-User-Id":"dev-user","X-FFun-Identity-Provider-Id":"single_user"}'
networks:
ffun_network:
aliases:
- auth-proxy
backend-build:
image: ffun-backend-dev
build:
context: ./
dockerfile: ./docker/dev/backend/Dockerfile
command: /bin/true
profiles:
- dev-build
backend-multi-user:
<<: *backend-api
profiles: ["multi-user"]
backend-single-user:
<<: *backend-api
profiles: ["single-user"]
environment:
<<: *backend-api-environment
FFUN_AUTH_FORCE_EXTERNAL_USER_ID: "dev-user"
FFUN_AUTH_FORCE_EXTERNAL_IDENTITY_PROVIDER_ID: "single_user"
backend-utils:
image: ffun-backend-dev
depends_on:
postgresql:
condition: service_started
volumes:
- ${PWD}/ffun:/repository
- ${PWD}/.env:/repository/.env
- ${PWD}/.configs:/repository/.configs
- ${PWD}/.shared:/repository/.shared
- ${PWD}/tags_quality_base:/repository/tags_quality_base
- ${PWD}/feeds_collections:/repository/feeds_collections
- ${PWD}/changes:/repository/changes
- ${PWD}/CHANGELOG.md:/repository/CHANGELOG.md
environment:
FFUN_ENABLE_SENTRY: "${FFUN_ENABLE_SENTRY:-False}"
FFUN_SENTRY__DSN: "${FFUN_SENTRY__DSN:-not-specified}"
# set to /repository/feeds_collections/collections in case you want to use the default collection
FFUN_FEEDS_COLLECTIONS_COLLECTION_CONFIGS: "${FFUN_FEEDS_COLLECTIONS_COLLECTION_CONFIGS-}"
networks:
ffun_network: {}
extra_hosts:
# required to test with local LLM services like LMStudio
- "host.docker.internal:host-gateway"
profiles:
- dev
frontend-build:
image: ffun-frontend-dev
build:
context: ./
dockerfile: ./docker/dev/frontend/Dockerfile
command: /bin/true
profiles:
- dev-build
frontend:
image: ffun-frontend-dev
command: "npm run dev -- --host 0.0.0.0 --port 8000"
volumes:
- ${PWD}/site/src:/repository/src
environment:
VITE_FFUN_ENABLE_SENTRY: "${FFUN_ENABLE_SENTRY:-False}"
VITE_FFUN_SENTRY_DSN: "${FFUN_SENTRY__DSN:-not-specified}"
VITE_FFUN_PLAUSIBLE_ENABLED: "${FFUN_PLAUSIBLE_ENABLED:-False}"
VITE_FFUN_PLAUSIBLE_DOMAIN: "${FFUN_PLAUSIBLE_DOMAIN:-localhost}"
VITE_FFUN_PLAUSIBLE_SCRIPT: "${FFUN_PLAUSIBLE_SCRIPT:-not-specified}"
VITE_FFUN_TRACK_EVENTS: "true"
VITE_FFUN_CRM_TERMS: "${FFUN_CRM_TERMS:-not-specified}"
VITE_FFUN_CRM_PRIVACY: "${FFUN_CRM_PRIVACY:-not-specified}"
VITE_FFUN_CRM_IMPRESSUM: "${FFUN_CRM_IMPRESSUM:-not-specified}"
VITE_FFUN_HAS_COLLECTIONS: "true"
networks:
ffun_network: {}
frontend-utils:
image: ffun-frontend-dev
volumes:
- ${PWD}/site/src:/repository/src
- ${PWD}/site/codespell.toml:/repository/codespell.toml
networks:
ffun_network: {}
# We use Caddy in dev environment for the next reasons:
# - OIDC protocol assumes communication over HTTPS
# and not all proxies and related tools support communication over HTTP
# that complicates development, testing and experimentation.
# - SPA's Vite backend recently got too complex proxy behavior because of OIDC
edge-proxy:
image: caddy:2.10-alpine
volumes:
- ./docker/dev/caddy:/etc/caddy:ro
- ffun_caddy_data:/data
- ffun_caddy_markers:/markers
ports:
- "80:80"
- "443:443"
networks:
ffun_network:
aliases:
- feeds.fun.local
- idp.feeds.fun.local
- auth.feeds.fun.local # is required by Pomerium
- filebrowser.feeds.fun.local
filebrowser:
image: filebrowser/filebrowser:v2.61.1
profiles: ["filebrowser"]
command: "--noauth"
user: "0:0" # need to have ./markers writable
volumes:
- ffun_filebrowser_database:/database
- ffun_caddy_markers:/srv/markers
networks:
ffun_network: {}