Skip to content

Commit d5abb5c

Browse files
committed
feat(notifications): switch to notella
1 parent 3229e3a commit d5abb5c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+985
-663
lines changed

.changeset/fair-coats-talk.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@churros/api': minor
3+
'@churros/app': minor
4+
'@churros/db': minor
5+
---
6+
7+
deprecate Article.notifiedAt

.changeset/purple-chefs-heal.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@churros/api': major
3+
---
4+
5+
notifications are now handled by a separate scheduler process, see git.inpt.fr/churros/notella

.changeset/tall-ads-double.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@churros/api': major
3+
---
4+
5+
default value for Mutation.acknowledgeChangelog:version and Query.combinedChangelog:to were removed

.env.example

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ REDIS_URL="redis://localhost:6379"
99
PROMETHEUS_URL="http://localhost:9090"
1010
# School
1111
PUBLIC_SCHOOL_UID="o"
12-
# Notifications
13-
PUBLIC_VAPID_KEY="BO9G7s2ya5I-tgsClQs5m618yT5uwZkuWCVY0LC1Bvg_K_RsXF6dpNtipxzmrJeXZWbkDB-NkOnR_Tp3T9sOlNg"
14-
VAPID_PRIVATE_KEY="pud3TjuDNEf3fvkZ6JzVcKsymPdLrQTOhSeovEkERWU"
1512
# Lydia
1613
PUBLIC_LYDIA_API_URL="https://lydia-app.com"
1714
LYDIA_WEBHOOK_URL="http://localhost:5173/lydia-webhook"
@@ -126,9 +123,16 @@ PUBLIC_API_ORIGIN_WEB="http://localhost:4000"
126123
# To test on a physical device, install ngrok, setup your auth token, run `yarn ngrok` and set these origins to the ngrok URLs (API and frontend ports will be exposed to the Internet via Ngrok)
127124
PUBLIC_API_ORIGIN_ANDROID="http://10.0.2.2:4000"
128125
PUBLIC_FRONTEND_ORIGIN_ANDROID="http://10.0.2.2:5173"
129-
# JSON contents of the service account key file from Firebase Console
130-
FIREBASE_ADMIN_SERVICE_ACCOUNT_KEY=""
131126
PUBLIC_APP_PACKAGE_ID="app.churros"
127+
# Notella notifications scheduler server NATS URL. See https://git.inpt.fr/churros/notella
128+
NOTELLA_NATS_URL="nats://localhost:4222"
129+
NOTELLA_HEALTHCHECK_ENDPOINT="http://localhost:8080/health"
130+
# Used by notella, see services.notella in the docker-compose.yml
131+
PUBLIC_VAPID_KEY="BO9G7s2ya5I-tgsClQs5m618yT5uwZkuWCVY0LC1Bvg_K_RsXF6dpNtipxzmrJeXZWbkDB-NkOnR_Tp3T9sOlNg"
132+
# Used by notella, see services.notella in the docker-compose.yml
133+
VAPID_PRIVATE_KEY=""
134+
# Used by notella, see services.notella in the docker-compose.yml
135+
FIREBASE_ADMIN_SERVICE_ACCOUNT_KEY=""
132136
# Token to execute Mutation.housekeep
133137
HOUSEKEEPER_TOKEN="housekeeper"
134138
# In development, to test the webhook, you can start a quick & dirty server with `python -m http.server SOME_PORT` and use `http://localhost:SOME_PORT` here

.gitlab-ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ include:
1010
- ci/volta.gitlab-ci.yml
1111
- ci/build.gitlab-ci.yml
1212
- ci/test.gitlab-ci.yml
13+
- ci/misc.gitlab-ci.yml

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Parmis d'autres choses, sont notamment lancés:
8787

8888
- <http://localhost:5173>: l'application
8989
- <http://localhost:4000>: l'API
90-
- <http://localhost:8025>: un serveur mail de test reçevant tout les mails envoyés par l'application
90+
- <http://localhost:8025>: un serveur mail de test reçevant tout les mails envoyés par l'application: démarrer le docker compose avec le profil `mails` en plus: `docker compose --profile mails up -d`
9191

9292
On peut lancer Prisma Studio pour inspecter la base de données:
9393

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ WORKDIR /app
106106

107107
ENV NODE_ENV="production"
108108

109-
RUN apk add --update --no-cache openssl
109+
RUN apk add --update --no-cache openssl git
110110

111111
# Prisma
112112
COPY --from=builder-api /app/packages/db/prisma/ /app/packages/db/prisma/

ci/misc.gitlab-ci.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
trigger-notella-update:
2+
stage: changesets
3+
allow_failure: true
4+
rules:
5+
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
6+
changes: [packages/db/prisma/schema.prisma]
7+
- when: manual
8+
variables:
9+
SCHEMA_RAW_URL: $CI_PROJECT_URL/-/raw/$CI_COMMIT_SHA/packages/db/prisma/schema.prisma
10+
trigger:
11+
project: $CI_PROJECT_NAMESPACE/notella

docker-compose.yml

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,58 @@ services:
55
- 5432:5432
66
environment:
77
- POSTGRES_PASSWORD=dev
8+
89
smtp:
10+
profiles:
11+
- mails
912
image: mailhog/mailhog
1013
ports:
1114
- 1025:1025
1215
- 8025:8025
16+
1317
redis:
1418
image: redis/redis-stack:7.2.0-v11
1519
ports:
1620
- 6379:6379
1721
- 8001:8001
1822

19-
# peut être commenté pour alléger la charge du serveur de développement, si l'on est pas en train de tester des choses qui dépendent de prometheus
23+
notella:
24+
image: registry.inpt.fr/churros/notella:v0.11.1
25+
profiles:
26+
- notella
27+
env_file:
28+
- .env
29+
ports:
30+
- 8080:8080
31+
environment:
32+
- DATABASE_URL=${DATABASE_URL}
33+
- REDIS_URL=${REDIS_URL}
34+
- NATS_URL=nats://nats:4222
35+
- PUBLIC_VAPID_KEY=${PUBLIC_VAPID_KEY}
36+
- VAPID_PRIVATE_KEY=${VAPID_PRIVATE_KEY}
37+
- CONTACT_EMAIL=${PUBLIC_CONTACT_EMAIL}
38+
- FIREBASE_SERVICE_ACCOUNT=${FIREBASE_ADMIN_SERVICE_ACCOUNT_KEY}
39+
- STARTUP_SCHEDULE_RESTORATION=enabled # enabled, disabled, eager
40+
- APP_PACKAGE_ID=${PUBLIC_APP_PACKAGE_ID}
41+
- HEALTH_CHECK_PORT=8080
42+
- DEBUG=1
43+
command: >
44+
sh -c 'export DATABASE_URL=$${DATABASE_URL/localhost/db} && export REDIS_URL=$${REDIS_URL/localhost/redis} && exec /app/notella'
45+
46+
nats:
47+
profiles:
48+
- notella
49+
image: nats:2.10.22
50+
ports:
51+
- '8222:8222'
52+
- '4222:4222'
53+
volumes:
54+
- ./nats-dev-server.conf:/nats-server.conf
55+
command: ['-c', '/nats-server.conf']
56+
2057
prometheus:
58+
profiles:
59+
- prometheus
2160
image: prom/prometheus
2261
ports:
2362
- 9090:9090

nats-dev-server.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# nats-server.conf
2+
jetstream {
3+
enabled: true
4+
}

0 commit comments

Comments
 (0)