-
Notifications
You must be signed in to change notification settings - Fork 5
Derniers correctifs avant mise en prod : retours, cache, régressions #1270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
3a42907
nginx fix
fabienheureux 19e7c29
https://www.notion.so/accelerateur-transition-ecologique-ademe/La-lou…
fabienheureux 6c8be44
fix footer embeddd
fabienheureux 1d4fb30
Revert "Simplification des dags source et ajout du contexte (#1248)"
fabienheureux 11c4b3c
wip
fabienheureux 0b4b61b
add nginx local conf
fabienheureux e9b3bbc
refine nginx config
fabienheureux c8e40a9
add nginx to e2e tests
fabienheureux 64c45dd
Comment tests for now
fabienheureux bd18728
Merge branch 'main' into assistant-v2-fixes-27-1
fabienheureux 810d0e5
Merge branch 'main' into assistant-v2-fixes-27-1
fabienheureux 7ef1d39
Merge branch 'main' into assistant-v2-fixes-27-1
fabienheureux c318e44
add docs
fabienheureux bc03787
update docs
fabienheureux 598d459
Merge branch 'main' into assistant-v2-fixes-27-1
fabienheureux 8d6887b
feedack
fabienheureux 8d09145
feedack
fabienheureux 6954175
feedbacks
fabienheureux 96ba4e2
add deployment doc
fabienheureux 8b2f778
update docs
fabienheureux 72cb583
Update docs/reference/README.md
fabienheureux File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,4 @@ airflow-pgdata/ | |
media | ||
|
||
_build | ||
.obsidian |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# 🎨 Frontend | ||
|
||
Le projet dispose de deux frontend principaux | ||
- **Longue Vie Aux Objets** : https://lvao.ademe.fr | ||
- L'**assistant** : https://quefairedemesobjets.ademe.fr | ||
|
||
Ils ont été développés en silo, et ne partagent à date qu'un minimum de code. | ||
L'objectif à terme est d'en mutualiser une majeure partie au travers de refactorisations. | ||
|
||
Longue vie aux objet est quant à lui découpé en deux briques fonctionnelles : | ||
- Le **formulaire**, aussi appelé *version épargnons* | ||
- La **carte**, intégrée au sein de l'assistant et par de nombreuses collectivités sous forme d'iframe | ||
Les différences sont [détaillées ici](https://www.notion.so/accelerateur-transition-ecologique-ademe/Sp-cifications-de-la-carte-170dcd6cdaee4a62b9f70c2040b363e2?pvs=4) | ||
|
||
Comprendre l'**historique** du projet permet de comprendre comment s'imbriquent ces différentes applications | ||
- **2023** : Longue vie aux objets : développée initialement, dans sa version *carte* | ||
- **2024** : *Formulaire* : développée dans le cadre d'une campagne de communication [Épargnons nos ressources](https://epargnonsnosressources.gouv.fr) | ||
- **2025** : *Assistant* : développé en remplacement d'un outil précédemment développé sous Gatsby | ||
|
||
**Les technologies employées dans l'assistant sont à prendre comme référence pour l'intégralité des développements futurs sur le frontend**, à savoir : | ||
- [**templating Django**](https://docs.djangoproject.com/en/5.1/topics/templates/) | ||
Jinja est encore utilisé dans la carte mais est progressivement déprévié | ||
- **Parcel** pour la compilation des fichiers JS/CSS | ||
- **Tailwind** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# 🚏 Routing, nginx et cache | ||
Le projet est actuellement déployé sur **Scalingo**, Scalingo qui impose une limite de 50 requêtes/seconde sur un worker. | ||
Nous avons décidé d'ajouter **Nginx** en janvier 2025 afin d'agir comme serveur de cache et anticiper sur l'atteinte de cette limite. | ||
# nginx | ||
Dans l'hypothèse d'un pic de charge, | ||
- Le **cache** de certaines **vues Django** (déchet / produit, page d'accueil de l'assistant...) | ||
- Le **cache** des **fichiers statiques** (CSS, JS...) | ||
|
||
Des images valant mille mots, ci-dessous un schéma résumant le parcours d'une requête lorsqu'elle atteint `lvao.ademe.fr` ou `quefairedemesdechets.ademe.fr` | ||
|
||
|
||
```mermaid | ||
sequenceDiagram | ||
|
||
participant Client | ||
participant Nginx | ||
participant Django | ||
|
||
|
||
|
||
Client->>Nginx: Request lvao.ademe.fr | ||
|
||
alt Cache Hit | ||
|
||
Nginx-->>Client: Return cached response | ||
|
||
else Cache Miss | ||
|
||
Nginx->>Django: Forward request to Django | ||
|
||
Django-->>Nginx: Generate response | ||
|
||
alt Authenticated User | ||
|
||
Django->>Nginx: Add 'logged_in' cookie | ||
|
||
end | ||
|
||
alt iframe query param present | ||
|
||
Django->>Nginx: Add iframe cookie | ||
|
||
end | ||
|
||
Nginx-->>Client: Return Django response | ||
|
||
end | ||
``` | ||
|
||
Les cookies définis expirent à la fin de la session, cela veut dire qu'ils seront re-générés si l'utilisateur ferme son navigateur. | ||
|
||
# whitenoise | ||
# middleware |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
# ❓ EXPLICATIONS | ||
|
||
```{toctree} | ||
:hidden: | ||
|
||
101-ingestion-de-source.md | ||
201-frontend.md | ||
301-routing-nginx-cache.md | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# 🚀 Mise en production | ||
|
||
1. Créer un tag depuis l'interface GitHub ou la ligne de commande | ||
``` | ||
git checkout main | ||
git reset --hard origin/main | ||
git tag v1.x.y | ||
git push --tags | ||
``` | ||
On en profite au passage pour s'assurer que notre branche main est bien iso avec celle du dépôt distant. | ||
|
||
2. Cela va déclencher une action GitHub, qui va automatiquement créer la release | ||
3. Une fois la release créée, celle-ci peut être modifiée pour adapter son contenu à la teneur des changements déployés | ||
4. L'équipe doit être prévenue sur le [canal équipe](https://mattermost.incubateur.net/betagouv/channels/longuevieauxobjets-equipe) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
# 🙌 TUTORIELS | ||
|
||
```{toctree} | ||
:hidden: | ||
|
||
101-push-to-prod | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
events {} | ||
|
||
http { | ||
include /etc/nginx/servers.conf; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
proxy_cache_path /tmp/nginx_assistant_cache levels=1:2 keys_zone=assistant:10m max_size=1g inactive=60m use_temp_path=off; | ||
# Define a variable to disable cache if the logged_in cookie is set | ||
map $http_cookie $no_cache { | ||
default 0; | ||
"~*logged_in=.*" 1; | ||
} | ||
|
||
server { | ||
listen 80; | ||
server_name _; | ||
|
||
location / { | ||
proxy_pass http://host.docker.internal:8000; | ||
|
||
proxy_cache_bypass $no_cache; | ||
proxy_no_cache $no_cache; | ||
|
||
proxy_cache assistant; | ||
proxy_set_header Host $http_host; | ||
proxy_cache_key $request_method$request_uri$is_args$args; | ||
proxy_cache_lock on; | ||
proxy_cache_lock_timeout 10s; | ||
proxy_cache_use_stale error timeout updating; | ||
proxy_cache_background_update on; | ||
add_header X-Cache-Status $upstream_cache_status; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.