-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b2227e0
Showing
111 changed files
with
11,886 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,3 @@ | ||
.github | ||
.husky | ||
infra |
This file contains 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,20 @@ | ||
# NumEcoEval | ||
REGISTRY_URL=registry.gitlab-forge.din.developpement-durable.gouv.fr/pub/numeco/m4g/numecoeval | ||
PORT_PREFIX=1 | ||
TAG=1-3-0 | ||
POSTGRES_USER=postgres | ||
POSTGRES_PASSWORD=postgres | ||
LOGGING_LEVEL_ROOT=ERROR | ||
LOGGING_LEVEL_ORG_SPRINGFRAMEWORK=ERROR | ||
|
||
# EvalCarboneSIH | ||
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres | ||
EXPOSITION_DONNEES_ENTREES_URL=http://localhost:18081 | ||
# Debug de prisma | ||
# DEBUG=* | ||
NEXTAUTH_URL=http://localhost:3000/ | ||
# Lancer la commande `openssl rand -base64 32` | ||
NEXTAUTH_SECRET=A_REMPLIR | ||
# Demander les accès à Plage | ||
PROVIDER_CLIENT_ID=A_REMPLIR | ||
PROVIDER_CLIENT_SECRET=A_REMPLIR |
This file contains 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,108 @@ | ||
{ | ||
"extends": [ | ||
"next/core-web-vitals", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:@typescript-eslint/recommended-requiring-type-checking", | ||
"plugin:react/all", | ||
"plugin:import/recommended", | ||
"plugin:import/typescript", | ||
"plugin:jsx-a11y/recommended", | ||
"plugin:deprecation/recommended" | ||
], | ||
"parserOptions": { | ||
"project": ["./tsconfig.json"] | ||
}, | ||
"env": { | ||
"browser": true, | ||
"es2021": true, | ||
"node": true | ||
}, | ||
"settings": { | ||
"react": { | ||
"version": "detect" | ||
} | ||
}, | ||
"ignorePatterns": [ | ||
"public", | ||
"next.config.js" | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"plugins": ["sort-keys-fix", "unused-imports"], | ||
"rules": { | ||
"array-bracket-newline": "error", | ||
"array-bracket-spacing": "error", | ||
"array-element-newline": ["error", "consistent"], | ||
"arrow-parens": "error", | ||
"arrow-spacing": "error", | ||
"brace-style": "error", | ||
"comma-dangle": [ | ||
"error", | ||
{ | ||
"arrays": "always-multiline", | ||
"imports": "always-multiline", | ||
"objects": "always-multiline" | ||
} | ||
], | ||
"comma-spacing": "error", | ||
"default-case": "error", | ||
"eol-last": "error", | ||
"eqeqeq": "error", | ||
"function-paren-newline": ["error", "consistent"], | ||
"id-match": "error", | ||
"indent": ["error", 2, { "SwitchCase": 1 }], | ||
"jsx-quotes": "error", | ||
"keyword-spacing": "error", | ||
"max-len": [ | ||
"error", | ||
{ | ||
"code": 160, | ||
"ignoreUrls": true, | ||
"ignoreStrings": true, | ||
"ignoreTemplateLiterals": true, | ||
"ignoreRegExpLiterals": true | ||
} | ||
], | ||
"no-console": "error", | ||
"no-multiple-empty-lines": "error", | ||
"no-multi-spaces": "error", | ||
"no-param-reassign": "error", | ||
"no-tabs": "error", | ||
"no-trailing-spaces": "error", | ||
"no-whitespace-before-property": "error", | ||
"object-curly-spacing": ["error", "always"], | ||
"object-curly-newline": "error", | ||
"object-property-newline": ["error", { "allowAllPropertiesOnSameLine": true }], | ||
"prefer-const": "error", | ||
"quote-props": ["error", "as-needed"], | ||
"quotes": ["error", "single", { "avoidEscape": true }], | ||
"semi": ["error", "never"], | ||
"space-before-blocks": "error", | ||
"space-infix-ops": "error", | ||
"yoda": "error", | ||
"import/newline-after-import": "error", | ||
"import/no-anonymous-default-export": "off", | ||
"import/no-extraneous-dependencies": "error", | ||
"import/no-mutable-exports": "error", | ||
"import/order": [ | ||
"warn", | ||
{ | ||
"groups": [["builtin", "external"], ["internal", "parent", "sibling", "index", "object", "type"]], | ||
"newlines-between": "always", | ||
"alphabetize": { "order": "asc", "caseInsensitive": true } | ||
} | ||
], | ||
"react/forbid-component-props": "off", | ||
"react/jsx-curly-brace-presence": "off", | ||
"react/jsx-filename-extension": [1, { "extensions": [".tsx"] }], | ||
"react/jsx-indent": [2, 2], | ||
"react/jsx-indent-props": [2, 2], | ||
"react/jsx-max-depth": "off", | ||
"react/jsx-newline": "off", | ||
"react/jsx-no-bind": "off", | ||
"react/jsx-no-literals": "off", | ||
"react/react-in-jsx-scope": "off", | ||
"sort-keys-fix/sort-keys-fix": "error", | ||
"@typescript-eslint/ban-ts-comment": "off", | ||
"unused-imports/no-unused-imports": "error" | ||
} | ||
} |
This file contains 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,67 @@ | ||
name: Continuous deployment | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
env: | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
cache: yarn | ||
node-version-file: package.json | ||
|
||
- uses: docker/login-action@v3.1.0 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- uses: docker/metadata-action@v5.5.1 | ||
id: meta | ||
with: | ||
images: ghcr.io/${{ env.IMAGE_NAME }} | ||
tags: type=sha,format=short,prefix= | ||
|
||
- uses: docker/setup-buildx-action@v3 | ||
|
||
- uses: actions/cache@v4 | ||
id: cache | ||
with: | ||
path: yarn-cache | ||
key: cache-${{ hashFiles('.yarnrc.yml') }} | ||
|
||
- uses: reproducible-containers/buildkit-cache-dance@v3.1.0 | ||
with: | ||
cache-map: | | ||
{ | ||
"yarn-cache": "/cache/yarn" | ||
} | ||
skip-extraction: ${{ steps.cache.outputs.cache-hit }} | ||
|
||
- uses: docker/build-push-action@v5.3.0 | ||
with: | ||
context: . | ||
push: true | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
- uses: webfactory/ssh-agent@v0.9.0 | ||
with: | ||
ssh-private-key: ${{ secrets.PRIVATE_SSH_KEY }} | ||
|
||
- name: Deploy frontend | ||
run: ansible-playbook -i infra/inventories/ovh.yml infra/playbook-frontend.yml -e IMAGE_NAME=ghcr.io/${IMAGE_NAME,,} -e IMAGE_TAG=${GITHUB_SHA::7} |
This file contains 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,15 @@ | ||
.next | ||
node_modules | ||
tsconfig.tsbuildinfo | ||
.env.local | ||
.env.prod | ||
infra/roles/referential/files/input_ref* | ||
|
||
# yarn | ||
**/.yarn/* | ||
!**/.yarn/patches | ||
!**/.yarn/releases | ||
!**/.yarn/plugins | ||
!**/.yarn/sdks | ||
!**/.yarn/versions | ||
**/.pnp.* |
This file contains 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,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
yarn amibroken |
This file contains 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,20 @@ | ||
{ | ||
"extends": [ | ||
"stylelint-config-standard" | ||
], | ||
"plugins": [ | ||
"stylelint-order" | ||
], | ||
"rules": { | ||
"property-disallowed-list": ["margin-block", "margin-inline", "padding-block", "padding-inline"], | ||
"selector-class-pattern": null, | ||
"selector-id-pattern": null, | ||
"order/properties-alphabetical-order": true, | ||
"selector-pseudo-class-no-unknown": [ | ||
true, | ||
{ | ||
"ignorePseudoClasses": ["global"] | ||
} | ||
] | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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,3 @@ | ||
nodeLinker: node-modules | ||
|
||
yarnPath: .yarn/releases/yarn-4.1.1.cjs |
This file contains 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 @@ | ||
# Ca doit être la même version qu'il y a dans package.json | ||
FROM node:20.12.2-alpine | ||
|
||
# RUN groupadd -r user | ||
|
||
# RUN useradd -r -g user user | ||
|
||
WORKDIR /usr/src/app | ||
|
||
ENV YARN_CACHE_FOLDER=/cache/yarn | ||
COPY .yarn/releases/yarn-4.1.1.cjs ./.yarn/releases/yarn-4.1.1.cjs | ||
COPY yarn.lock package.json .yarnrc.yml ./ | ||
RUN --mount=type=cache,target=/cache/yarn \ | ||
corepack enable && corepack prepare yarn@stable --activate && yarn install | ||
|
||
COPY . . | ||
|
||
RUN yarn build | ||
|
||
# RUN chown -R user:user /usr/src/app | ||
|
||
# USER user | ||
|
||
CMD ["yarn", "start"] |
This file contains 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,100 @@ | ||
# EvalCarboneSIH | ||
|
||
## Prérequis | ||
|
||
- Ansible | ||
- Docker CE | ||
- NodeJs | ||
|
||
## Installation locale | ||
|
||
- `yarn` | ||
- `npx husky init` | ||
- `cp .env .env.local` (Remplir les variables affectées par "A_REMPLIR") | ||
- `yarn start:db` (il se peut que le container Kafka ne se lance pas du premier coup, relancer une seconde fois) | ||
- Ajouter les différents référentiels dans `infra/roles/referential/files/input_ref`, il faut les demander à Nathalie Baudiniere | ||
- `yarn load_ref` | ||
- `yarn dev` | ||
|
||
## NumEcoEval | ||
|
||
- [Le code source](https://gitlab-forge.din.developpement-durable.gouv.fr/pub/numeco/m4g/numecoeval) | ||
- [Swagger api-rest-referentiels](http://localhost:18080/swagger-ui/index.html) | ||
- [Swagger api-rest-expositiondonneesentrees](http://localhost:18081/swagger-ui/index.html) | ||
- [Swagger api-event-calculs](http://localhost:18085/swagger-ui/index.html) | ||
|
||
## Installation OVH | ||
|
||
>Demander à Nathalie Baudiniere pour avoir accès à la VM OVH, il faudra donner une clé SSH publique. | ||
Pour se connecter sur la VM OVH : | ||
|
||
- `ssh ubuntu@eval-carbone-sih.esante.gouv.fr` | ||
|
||
Tout se fait avec les recettes Ansible se trouvant dans `/infra`.\ | ||
Récupérer le fichier `.env.prod` sur la machine en question. | ||
Puis : | ||
|
||
- `ansible-galaxy collection install community.docker` | ||
- `yarn deploy:backend` (joué la première fois ou lors d'une mise à jour) | ||
- `yarn deploy:reverse-proxy` (joué la première fois ou lors d'une mise à jour) | ||
- `yarn deploy:referential` (joué la première fois ou lors d'une mise à jour) | ||
|
||
### Schéma de la production | ||
|
||
```mermaid | ||
C4Context | ||
title EvalCarboneSIH | ||
Person(dsi, "DSI hospitalier") | ||
Boundary(ovh, "VM OVH") { | ||
Boundary(reverse-proxy, "Reverse proxy") { | ||
Container(reverse-proxy, "Reverse proxy", "Nginx") | ||
} | ||
Boundary(eval-carbone-sih, "EvalCarboneSIH") { | ||
Container(front, "Frontend", "NextJs") | ||
} | ||
Boundary(num-eco-eval, "NumEcoEval") { | ||
ContainerDb(db, "Database", "PostgreSQL") | ||
Container(expositiondonneesentrees, "api-rest-expositiondonneesentrees", "Java") | ||
Container(referentiels, "api-rest-referentiels", "Java") | ||
Container(donneesentrees, "api-event-donneesentrees", "Java") | ||
Container(calculs, "api-event-calculs", "Java") | ||
Container(kafka, "Kafka", "kafka") | ||
Container(zookeeper, "Zookeeper", "zookeeper") | ||
} | ||
} | ||
BiRel(dsi, reverse-proxy, "") | ||
BiRel(kafka, zookeeper, "") | ||
Rel(expositiondonneesentrees, db, "write") | ||
BiRel(front, db, "write and read") | ||
BiRel(reverse-proxy, front, "") | ||
Rel(front, expositiondonneesentrees, "use", "Lancer le calcul et ajouter les équipements physiques") | ||
``` | ||
|
||
## Configuration GitHub | ||
|
||
La clé SSH privée (créée plus haut) doit être mise sur GitHub dans les [settings](https://github.com/ansforge/Eval-Carbone-SIH/settings/secrets/actions). | ||
|
||
## Configuration Plage | ||
|
||
Plage est le service d'authentification. | ||
|
||
- [Documentation pour créer un compte de test](https://atih.atlassian.net/wiki/spaces/PUBLIC/pages/2979692685/Plage) | ||
- [Documentation technique](https://atih.atlassian.net/wiki/external/YjE4MTQzOGU0YTNmNDFjNDg3MDcxMjY4NThkMzYzNGE) | ||
|
||
## Points d'attention | ||
|
||
- La mise à jour de NumEcoEval peut être douloureuse parce que | ||
- la plupart des appels se font directement sur la base de données (suppression, modification...) car les routes n'existent pas | ||
- il se peut que la base de données aura changé donc il faudra réécrire le front | ||
- Idéalement, il faudrait utiliser le SaaS du Ministère de la Transition Ecologique (qui n'est pas encore en ligne à ce jour) et retirer la brique NumEcoEval mais voir le point numéro 1 | ||
- Avoir un système de monitoring de la base de données pour pouvoir la mettre à l'échelle s'il y a trop de données et pourrait faire ralentir l'application à long terme | ||
- La base de données doit avoir un système de sauvegarde régulier au cas où la VM d'OVH doit être reconstruite |
This file contains 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,3 @@ | ||
[defaults] | ||
host_key_checking = False | ||
stdout_callback = unixy |
Oops, something went wrong.