-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
499 lines (449 loc) · 15.5 KB
/
Copy pathTaskfile.yml
File metadata and controls
499 lines (449 loc) · 15.5 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
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
version: "3"
silent: true
tasks:
# ─── Setup ─────────────────────────────────────────────────────────
setup:
desc: Generate certificates, build Docker images and config files for all environments
cmds:
- task: setup:certs
- task: build:images
- task: setup:lemonldap-config
- task: setup:config
setup:demo:
desc: Setup certificates, config files and Docker images for demo environment
cmds:
- task: setup:certs:demo
- task: build:images
- task: setup:lemonldap-config:demo
- task: setup:config
setup:dev:
desc: Setup certificates, config files and Docker images for dev environment
cmds:
- task: build:image:superset
- task: setup:certs:dev
- task: setup:lemonldap-config:dev
setup:e2e:
desc: Setup certificates, config files and Docker images for E2E environment
cmds:
- task: setup:certs:e2e
- task: setup:lemonldap-config:e2e
- task: setup:config
- task: build:images
setup:certs:
desc: Generate all certificates and keys for all environments
cmds:
- task: setup:certs:dev
- task: setup:certs:e2e
setup:certs:dev:
desc: Generate certificates and keys for dev environment
cmds:
- task: generate:certs
vars:
ENV: dev
TRUSTSTORE_PATH: "{{.ROOT_DIR}}/api/src/main/resources"
setup:certs:demo:
desc: Generate certificates and keys for demo environment
cmds:
- task: generate:certs
vars:
ENV: demo
ENV_FILE: .env
setup:certs:e2e:
desc: Generate certificates and keys for E2E environment
cmds:
- task: generate:certs
vars:
ENV: e2e
setup:config:
desc: Generate configuration files
cmds:
- task: generate:config
vars:
ENV: e2e
ENV_FILE: env/local.env
- task: generate:config
vars:
ENV: e2e
ENV_FILE: env/e2e.env
- task: generate:config
vars:
ENV: demo
ENV_FILE: .env
setup:lemonldap-config:
desc: Generate LemonLDAP configuration for all environment
cmds:
- task: setup:lemonldap-config:demo
- task: setup:lemonldap-config:dev
- task: setup:lemonldap-config:e2e
setup:lemonldap-config:demo:
desc: Generate LemonLDAP configuration for demo environment
cmds:
- task: generate:config:lemonldap
vars:
ENV: demo
ENV_FILE: env/demo.env
setup:lemonldap-config:dev:
desc: Generate LemonLDAP configuration for dev environment
cmds:
- task: generate:config:lemonldap
vars:
ENV: dev
ENV_FILE: env/dev.env
setup:lemonldap-config:e2e:
desc: Generate LemonLDAP configuration for E2E environment
vars:
ENV: e2e
cmds:
- task: generate:config:lemonldap
vars:
ENV: "{{.ENV}}"
ENV_FILE: env/local.env
- task: generate:config:lemonldap
vars:
ENV: "{{.ENV}}"
ENV_FILE: env/e2e.env
# ─── Demo environment ─────────────────────────────────────────────
start:demo:
desc: Start the demo of LinID
cmds:
- echo "Starting all services..."
- task: start:service
vars:
SERVICE_NAME: Docker services
CMD: cd docker/demo && docker compose -f docker-compose.yml --env-file .env up -d --quiet-pull
HEALTHCHECK: curl -sk https://linid.localtest.me:9000 >/dev/null 2>&1
TIMEOUT: 90
LOG_FILE: /tmp/linid-docker.log
- echo ""
- echo " ✔ All services ready!"
- echo " LinID → https://linid.localtest.me:9000"
- echo ""
- echo " Logs:"
- echo " Docker /tmp/linid-docker.log"
stop:demo:
desc: Stop the demo of LinID
cmds:
- echo "Stopping all services..."
- task: stop:compose
vars:
SERVICE_NAME: Docker services (DB + LemonLDAP)
DIR: docker/demo
- echo " All services stopped."
restart:demo:
desc: Restart the demo of LinID
cmds:
- task: stop:demo
- echo ""
- task: start:demo
# ─── Dev environment ─────────────────────────────────────────────
start:dev:
desc: Start the full dev environment (Docker + API + frontend modules)
cmds:
- echo "Starting all services..."
- task: start:service
vars:
SERVICE_NAME: Docker services (DB + LemonLDAP)
CMD: cd docker/dev && docker compose --env-file env/dev.env -f docker-compose.yml up -d --quiet-pull
HEALTHCHECK: curl -sk https://localhost:8080 >/dev/null 2>&1
TIMEOUT: 90
LOG_FILE: /tmp/linid-docker.log
- echo ""
- echo " ✔ All services ready!"
- echo " DB → postgresql://localhost:5432/linid"
- echo " LemonLDAP → https://localhost:8080"
- echo ""
- echo " Logs:"
- echo " Docker /tmp/linid-docker.log"
stop:dev:
desc: Stop the full dev environment
cmds:
- echo "Stopping all services..."
- task: stop:compose
vars:
SERVICE_NAME: Docker services (DB + LemonLDAP)
DIR: docker/dev
ENV_FILE: "env/dev.env"
- echo " All services stopped."
restart:dev:
desc: Restart the full local environment
cmds:
- task: stop:dev
- echo ""
- task: start:dev
# ─── E2E environment ──────────────────────────────────────────────
start:e2e:
desc: Start the full E2E environment (all-in-Docker)
vars:
ENV_FILE: '{{.ENV_FILE | default "env/local.env"}}'
cmds:
- echo "Starting all services..."
- task: start:service
vars:
SERVICE_NAME: Docker services
LOG_FILE: /tmp/linid-docker.log
CMD: cd docker/e2e && docker compose --env-file "{{.ENV_FILE}}" up -d --quiet-pull
HEALTHCHECK: curl -sk https://linid.localtest.me:9000 >/dev/null 2>&1
TIMEOUT: 120
- echo ""
- echo " ✔ E2E environment ready!"
- cmd: echo " → https://linid.localtest.me:9000"
if: '[ "{{.ENV_FILE}}" == "env/local.env" ]'
- echo ""
- echo " Logs:"
- echo " Docker /tmp/linid-docker.log"
stop:e2e:
desc: Stop the full E2E environment
vars:
ENV_FILE: '{{.ENV_FILE | default "env/local.env"}}'
cmds:
- echo "Stopping all services..."
- task: stop:compose
vars:
SERVICE_NAME: Docker services
DIR: docker/e2e
ENV_FILE: "{{.ENV_FILE}}"
- echo ""
- echo " E2E environment stopped."
restart:e2e:
desc: Restart the full E2E environment
cmds:
- task: stop:e2e
- echo ""
- task: start:e2e
# ─── Tests ─────────────────────────────────────────────────────────
setup:test:
desc: Install E2E test dependencies
dir: tests/e2e
cmd: npm install
lint:test:
desc: Lint Gherkin feature files
dir: tests/e2e
cmd: npx gherkin-lint "../features/**/*.feature"
start:test:ci:
desc: Run E2E tests in CI environment (Docker-based)
dir: docker/e2e
vars:
ENV_FILE: env/e2e.env
cmds:
- task: start:e2e
vars:
ENV_FILE: env/e2e.env
- docker compose --env-file env/e2e.env run --rm e2e-test-runner
- task: stop:e2e
vars:
ENV_FILE: env/e2e.env
start:test:
desc: Run E2E tests locally
deps: [setup:test]
dir: tests/e2e
dotenv: ["../../docker/e2e/env/local.env"]
vars:
SPEC: '{{.SPEC | default ""}}'
cmds:
- task: start:e2e
- cmd: '{{if .SPEC}}npx cypress run --spec "{{.SPEC}}"{{else}}npm run start{{end}}'
start:test:ui:
desc: Open Cypress UI for E2E testing locally
deps: [setup:test]
dir: tests/e2e
dotenv: ["../../docker/e2e/env/local.env"]
cmds:
- task: start:e2e
- npm run start:ui
# ─── Internal tasks ─────────────────────────────────────────────────────────
generate:ca:
desc: Generate the local certificate authority shared by all environments
internal: true
status:
- test -f docker/certs/ca.key
- test -f docker/certs/ca.crt
cmds:
- cmd: mkdir -p docker/certs
- cmd: |
openssl req -x509 -newkey rsa:2048 \
-keyout docker/certs/ca.key \
-out docker/certs/ca.crt \
-days 3650 -nodes \
-subj "/CN=LinID Development CA/O=LinID/C=FR" >/dev/null 2>&1
generate:certs:
desc: Generate certificates and keys for a specific environment
internal: true
dir: "docker/{{.ENV}}/resources"
dotenv: ['../{{.ENV_FILE | default "env/cert.env"}}']
vars:
TRUSTSTORE_PATH: '{{.TRUSTSTORE_PATH | default "."}}'
cmds:
- task: generate:ca
# Server certificate signed by the local CA, shared by all HTTPS services
- cmd: rm -fv server.key server.crt
- cmd: |
openssl req -x509 -newkey rsa:2048 \
-keyout server.key \
-out server.crt \
-days 3650 -nodes \
-subj "/CN=linid.localtest.me/OU=Test/O=Test/L=Test/ST=Test/C=FR" \
-addext "subjectAltName=DNS:linid.localtest.me,DNS:ui,DNS:api,DNS:auth,DNS:lemon,DNS:superset,DNS:localhost" \
-CA {{.ROOT_DIR}}/docker/certs/ca.crt \
-CAkey {{.ROOT_DIR}}/docker/certs/ca.key >/dev/null 2>&1
# OIDC signing keys
- cmd: rm -fv oidc.key oidc.pub
- cmd: |
openssl genpkey -algorithm RSA \
-out oidc.key \
-pkeyopt rsa_keygen_bits:2048 >/dev/null 2>&1 \
&& openssl pkey \
-in oidc.key \
-pubout -out oidc.pub >/dev/null 2>&1
# API truststore: trusting the CA covers every service certificate
- cmd: rm -fv {{.TRUSTSTORE_PATH}}/truststore.jks
- cmd: |
keytool -importcert -noprompt -trustcacerts \
-alias linid-ca \
-file {{.ROOT_DIR}}/docker/certs/ca.crt \
-keystore {{.TRUSTSTORE_PATH}}/truststore.jks \
-storepass "$SSL_TRUSTSTORE_PASSWORD" >/dev/null 2>&1
# API keystore built from the same server certificate
- cmd: rm -fv {{.ROOT_DIR}}/api/src/main/resources/keystore.p12 {{.ROOT_DIR}}/api/src/main/resources/keystore.jks
- cmd: |
openssl pkcs12 -export \
-in server.crt \
-inkey server.key \
-name linid \
-out {{.ROOT_DIR}}/api/src/main/resources/keystore.p12 \
-passout pass:"$SSL_KEY_PASSWORD" >/dev/null 2>&1
generate:config:
desc: Generate configuration from templates using env variables
internal: true
dir: "docker/{{.ENV}}/resources"
dotenv: ["../{{.ENV_FILE}}"]
cmds:
- rm -rf ${CONFIG_DIR}/conf
- mkdir -p ${CONFIG_DIR}/conf
- envsubst < config.template.json > ${CONFIG_DIR}/conf/config.json
generate:config:lemonldap:
desc: Generate LemonLDAP configuration from template using env variables
internal: true
dir: "docker/{{.ENV}}/resources"
dotenv: ["../{{.ENV_FILE}}"]
vars:
CONFIG_DIR: "${CONFIG_DIR:+${CONFIG_DIR}/}"
cmd: |
rm -rf {{.CONFIG_DIR}}llng
export OIDC_PRIVATE_KEY=$(awk '{printf "%s\\n", $0}' oidc.key)
export OIDC_PUBLIC_KEY=$(awk '{printf "%s\\n", $0}' oidc.pub)
mkdir -p {{.CONFIG_DIR}}llng/conf
envsubst < lmConf-1.template.json > {{.CONFIG_DIR}}llng/conf/lmConf-1.json
build:images:
desc: Build all Docker images
cmds:
- task: build:image:catalog-ui
- task: build:image:ui
- task: build:image:api
- task: build:image:superset
build:image:catalog-ui:
desc: Build catalog-ui Docker image
cmds:
- task: build:image
vars:
IMAGE_NAME: catalog-ui
DOCKERFILE: linid-im-front-community-plugins/docker/catalog-ui.Dockerfile
CONTEXT_DIR: linid-im-front-community-plugins/
build:image:ui:
desc: Build linid-identity-manager-ui Docker image
cmds:
- task: build:image
vars:
IMAGE_NAME: linid-identity-manager-ui
DOCKERFILE: ui/Dockerfile
CONTEXT_DIR: ui/
build:image:api:
desc: Build linid-identity-manager-api Docker image
cmds:
- task: build:image
vars:
IMAGE_NAME: linid-identity-manager-api
DOCKERFILE: api/Dockerfile
CONTEXT_DIR: api/
build:image:superset:
desc: Build superset Docker image
cmds:
- task: build:image
vars:
IMAGE_NAME: superset
DOCKERFILE: docker/superset/Dockerfile
CONTEXT_DIR: docker/superset
build:image:
desc: Build a specific Docker image
internal: true
vars:
LOG_FILE: "/tmp/linid-{{.IMAGE_NAME}}-image.log"
cmd: |
sh -c '
docker build --quiet -f {{.DOCKERFILE}} -t {{.IMAGE_NAME}} {{.CONTEXT_DIR}} > {{.LOG_FILE}} 2>&1 &
p=$!
while kill -0 $p 2>/dev/null; do
dots=""
for i in 1 2 3 4; do
kill -0 $p 2>/dev/null || break 2
printf "\r ⏳ Building {{.IMAGE_NAME}} image%-3s" "$dots"
dots="${dots}."
sleep 0.5
done
done
wait $p
r=$?
[ $r -eq 0 ] \
&& printf "\r ✔ {{.IMAGE_NAME}} image built \n" \
|| { printf "\r ✗ {{.IMAGE_NAME}} image build failed — see {{.LOG_FILE}}\n"; exit $r; }
'
start:service:
desc: Start a specific service locally
internal: true
cmd: |
sh -c '
{{.CMD}} > {{.LOG_FILE}} 2>&1 &
p=$!
elapsed=0
while ! {{.HEALTHCHECK}} 2>/dev/null; do
if ! kill -0 $p 2>/dev/null; then
printf "\r ✗ {{.SERVICE_NAME}} crashed — see {{.LOG_FILE}}\n"
exit 1
fi
if [ $elapsed -ge {{.TIMEOUT}} ]; then
printf "\r ✗ {{.SERVICE_NAME}} not ready after {{.TIMEOUT}}s — see {{.LOG_FILE}}\n"
exit 1
fi
dots=""
for i in 1 2 3 4; do
if {{.HEALTHCHECK}} 2>/dev/null; then break 2; fi
printf "\r ⏳ Starting {{.SERVICE_NAME}}%-3s" "$dots"
dots="${dots}."
sleep 1
elapsed=$((elapsed + 1))
done
done
printf "\r ✔ {{.SERVICE_NAME}} started \n"
'
stop:service:
desc: Stop a specific service
internal: true
cmd: |
pids=$(lsof -t -i:{{.PORT}}) \
&& /bin/kill $pids \
&& echo " ✔ {{.SERVICE_NAME}} stopped" \
|| echo " ○ {{.SERVICE_NAME}} (not running)"
stop:compose:
desc: Stop Docker Compose services
vars:
ENV_FILE: '{{.ENV_FILE | default "env/local.env"}}'
internal: true
dir: "{{.DIR}}"
cmd: |
running=$(docker compose --env-file "{{.ENV_FILE}}" ps --status running -q 2>/dev/null || true)
if [ -z "$running" ]; then
echo " ○ {{.SERVICE_NAME}} (not running)"
exit 0
fi
set -o pipefail
docker compose --env-file "{{.ENV_FILE}}" down -v --remove-orphans 2>&1 | tee /tmp/linid-docker.log
echo " ✔ {{.SERVICE_NAME}} stopped"