Skip to content

Commit

Permalink
feat(simulateurV2): effectifs page (#1673)
Browse files Browse the repository at this point in the history
  • Loading branch information
lsagetlethias authored and jonat75 committed Dec 12, 2023
1 parent 99c9906 commit 704a087
Show file tree
Hide file tree
Showing 108 changed files with 2,203 additions and 9,794 deletions.
5 changes: 0 additions & 5 deletions .env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,3 @@ APIV2_POSTGRES_PORT=5438
APIV2_PGADMIN_PORT=5050
APIV2_PGADMIN_DEFAULT_EMAIL=
APIV2_PGADMIN_DEFAULT_PASSWORD=

# declaration container
BASE_URL=""
EGAPRO_API_URL=
EGAPRO_SIMU_URL=
16 changes: 0 additions & 16 deletions .github/actions/setup-node/action.yml

This file was deleted.

6 changes: 4 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ jobs:
- name: Checkout Commit
uses: actions/checkout@v2

- name: Setup Node
uses: ./.github/actions/setup-node
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'

- name: Setup Python
uses: actions/setup-python@v4
Expand Down
16 changes: 3 additions & 13 deletions .kontinuous/env/prod/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ app:
enabled: true
resources:
requests:
cpu: 50m
memory: 512M
cpu: 20m
memory: 256M
limits:
cpu: 1
memory: 1G
Expand All @@ -52,14 +52,4 @@ jobs:
build-app:
with:
buildArgs:
REACT_APP_SENTRY_DSN: "{{ .Values.global.sentryFront }}"

build-declaration:
with:
buildArgs:
EGAPRO_SENTRY_DSN: "{{ .Values.global.sentryFront }}"

build-simulateur:
with:
buildArgs:
REACT_APP_SENTRY_DSN: "{{ .Values.global.sentryFront }}"
REACT_APP_SENTRY_DSN: "{{ .Values.global.sentryFront }}"
64 changes: 1 addition & 63 deletions .kontinuous/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,34 +61,6 @@ app:
EGAPRO_ENV: "{{ .Values.global.env }}"
NEXTAUTH_URL: "https://{{ .Values.global.host }}/api/auth"

declaration:
~chart: app
~needs: [build-declaration]
imagePackage: declaration
probesPath: /index.html
containerPort: 8080
host: "{{ .Values.global.host }}"
ingress:
path: /index-egapro/declaration(/|$)(.*)
rewriteTarget: /$2
annotations:
~tpl~nginx.ingress.kubernetes.io/configuration-snippet: *headers
certSecretName: api-crt

simulateur:
~chart: app
~needs: [build-simulateur]
imagePackage: simulateur
probesPath: /index.html
containerPort: 8080
host: "{{ .Values.global.host }}"
ingress:
path: /index-egapro(/|$)(.*)
rewriteTarget: /$2
annotations:
~tpl~nginx.ingress.kubernetes.io/configuration-snippet: *headers
certSecretName: api-crt

api:
~chart: app
~needs: [build-api]
Expand All @@ -114,9 +86,6 @@ api:
EGAPRO_DBPASS: "$(PGPASSWORD)"
EGAPRO_DBSSL: "$(PGSSLMODE)"
EGAPRO_SENTRY_DSN: "https://[email protected]/22"
EGAPRO_DOMAIN: "https://{{ .Values.global.host }}"
# addVolumes:
# - files

files:
~chart: app
Expand Down Expand Up @@ -153,14 +122,8 @@ project:
# DigDash prod 1 and 2
- "37.187.27.197"
- "37.187.137.149"
# DigDash new (12/10/2023)
- "217.182.225.112"
- "217.182.225.29"
- "217.182.225.113"
- "217.182.225.117"
# Invenis prod old
# Invenis prod old and new
- "217.182.142.112"
# Invenis prod new (09/10/2023)
- "51.38.59.32"
files:
public:
Expand Down Expand Up @@ -195,31 +158,6 @@ jobs:
imagePackage: api
context: packages/api

build-declaration:
use: build
with:
imagePackage: declaration
context: packages/declaration
buildArgs:
BASE_URL: "https://{{ .Values.global.host }}/index-egapro/declaration"
EGAPRO_API_URL: "https://{{ .Values.global.host }}/api"
EGAPRO_SIMU_URL: "https://{{ .Values.global.host }}/index-egapro"
GITHUB_SHA: "{{ $.Values.global.shortSha }}"

build-simulateur:
use: build
memoryLimit: 10Gi
memoryRequest: 2Gi
with:
imagePackage: simulateur
dockerfile: packages/simulateur/Dockerfile
buildArgs:
REACT_APP_EGAPRO_API_URL: "https://{{ .Values.global.host }}/api"
REACT_APP_DECLARATION_URL: "https://{{ .Values.global.host }}/index-egapro/declaration"
REACT_APP_GITHUB_SHA: "{{ $.Values.global.shortSha }}"
PUBLIC_URL: "/index-egapro"
INLINE_RUNTIME_CHUNK: false

deactivate:
jobs-deactivate:
runs:
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16
20
59 changes: 2 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,12 @@ Un composant à la fois :
```bash
yarn dev:api
yarn dev:app
yarn dev:simulateur
yarn dev:declaration
yarn dev:maildev
```

- [api -> http://localhost:2626](http://localhost:2626)
- la configuration vers la DB se fait dans le fichier .env de la racine du monorepo
- [app -> http://localhost:3000](http://localhost:3000)
- `simulateur` a besoin de `api` en local ou de `REACT_APP_EGAPRO_API_URL` d'être renseigné dans le fichier `packages/simulateur/.env` :
- [simulateur -> http://localhost:3001/simulateur/nouvelle-simulation](http://localhost:3001/simulateur/nouvelle-simulation)
- [declaration -> http://localhost:4000/index-egapro/declaration](http://localhost:4000/index-egapro/declaration)
- [maildev -> http://localhost:1080](http://localhost:1080)

Tout en un :
Expand All @@ -44,42 +39,6 @@ Tout en un :
yarn dev
```

## Reverse proxy iso prod

Il est possible de configurer son environnement local sans renseigner les ports, en utilisant un reverse proxy.

Toutes les applications seront sous le même domaine et les URL seront celles de la production.

L'api peut être soit distante (e.g. api de preprod), soit locale (mais elle restera derrière son port d'origine `2626`)

Le reverse proxy est configuré à travers un NGINX, mais a besoin que les composants voulus soient configurés en conséquence :

- `app` => `packages/app/.env.development.local`
- `NEXT_PUBLIC_API_URL=http://localhost:2626` (si api locale)
- apiv2 non supportée pour l'instant (si besoin de dev sur apiv2, passer directement par l'url classique http://localhost:3000)
- `declaration` => copier `.env.dist` vers `.env` (racine) si besoin.
- `BASE_URL="/index-egapro/declaration"`
- `EGAPRO_API_URL="http://localhost:2626"` (si api locale)
- `EGAPRO_SIMU_URL="http://localhost/index-egapro"` (si besoin du simulateur)
- `simulateur` => copier `packages/simulateur/.env.dist` vers `packages/simulateur/.env` si besoin.
- `PUBLIC_URL="/index-egapro"`
- `REACT_APP_DECLARATION_URL="http://localhost/index-egapro/declaration"` (si besoin de la déclaration)
- `REACT_APP_EGAPRO_API_URL="http://localhost:2626"` (si api locale)

Enfin, il suffit de lancer dans une fenêtre le serveur NGINX prévu :

```bash
yarn reverse-proxy
```

Remarque : api, maildev et la base de données ne sont pas affectés par le reverse proxy.

Les adresses deviennent alors :

- [app -> http://localhost](http://localhost)
- [simulateur -> http://localhost/index-egapro/simulateur/nouvelle-simulation](http://localhost/index-egapro/simulateur/nouvelle-simulation)
- [declaration -> http://localhost/index-egapro/declaration](http://localhost/index-egapro/declaration)

## Pour tout arrêter

Faire `Ctl-C` sur tous les terminaux
Expand All @@ -106,35 +65,21 @@ yarn workspace app run tsc
### Comment ajouter une librairie dans un workspace ?

````bash
yarn workspace simulateur add moment
yarn workspace app add moment
````

### Comment lancer un script dans un package ?

````bash
yarn workspace simulateur run test
yarn workspace app run test
````

### Comment lancer la déclaration en local ?

```bash
yarn dev:api
yarn dev:maildev
yarn dev:declaration
```

### Comment lancer un script dans tous les workspaces ?

````bash
yarn workspaces run lint
````

### Comment ajouter un membre dans le groupe Staff en développement ?

Pour l'API v1, aller dans `.env` à la racine et renseigner la variable `EGAPRO_STAFF` (emails séparés par des virgules sans espace).

Pour l'API v2, aller dans `packages/app/.env.development` et renseigner la variable `EGAPRO_STAFF` (emails séparés par des virgules sans espace).

### Quel est le maildev pour un environnement de recette ?

Ajouter le préfixe `maildev-` devant l'URL.
Expand Down
28 changes: 0 additions & 28 deletions docker-compose.build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,6 @@ services:
- test_db
restart: "no"

declaration:
image: egapro_declaration
build:
context: ./packages/declaration
dockerfile: Dockerfile
args:
EGAPRO_API_URL: ${EGAPRO_API_URL:-http://localhost:2626}
EGAPRO_SENTRY_DSN: ${EGAPRO_SENTRY_DSN:-https://[email protected]/48}
BASE_URL: "/index-egapro/declaration"
ports:
- 4000:8080
depends_on:
- api
restart: always

db:
restart: always
image: postgres
Expand Down Expand Up @@ -83,19 +68,6 @@ services:
- 3000:3000
restart: "no"

simulateur:
image: egapro_simulateur
build:
context: .
dockerfile: ./packages/simulateur/Dockerfile
args:
REACT_APP_EGAPRO_API_URL: ${EGAPRO_API_URL:-http://localhost:2626}
REACT_APP_DECLARATION_URL: ${REACT_APP_DECLARATION_URL:-http://localhost:4000/}
REACT_APP_SENTRY_DSN: ${EGAPRO_SENTRY_DSN:-https://[email protected]/48}
ports:
- 3001:8080
restart: "no"

volumes:
pgdata:
api_egginfos:
25 changes: 0 additions & 25 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,6 @@ services:
- test_db
restart: always

declaration:
image: egapro_declaration
build:
context: ./packages/declaration
dockerfile: Dockerfile.dev
args:
EGAPRO_API_URL: ${EGAPRO_API_URL:-http://localhost:2626}
EGAPRO_SIMU_URL: ${EGAPRO_SIMU_URL:-http://localhost:3001}
GITHUB_SHA: "<dev>"
BASE_URL: ${BASE_URL-""}
volumes:
- ./packages/declaration/_doc:/srv/jekyll/_doc
- ./packages/declaration/src:/srv/jekyll/src
- ./packages/declaration/favicon.ico:/srv/jekyll/_site/favicon.ico
ports:
- 4000:4000
restart: always

db:
restart: always
image: postgres
Expand Down Expand Up @@ -100,13 +82,6 @@ services:
volumes:
- pgadmin:/var/lib/pgadmin

reverse_proxy:
image: nginx:alpine
volumes:
- ./reverse-proxy.conf:/etc/nginx/nginx.conf
ports:
- 80:80

#docker run -p 8080:8080 -e KEYCLOAK_ADMIN=admin -e KEYCLOAK_ADMIN_PASSWORD=admin quay.io/keycloak/keycloak:21.1.1 start-dev
# keycloak:
# image: quay.io/keycloak/keycloak
Expand Down
13 changes: 5 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@
"private": true,
"workspaces": {
"packages": [
"packages/*"
"packages/app"
]
},
"engines": {
"node": "16"
"node": "20"
},
"scripts": {
"dev": "scripts/dev",
"pgadmin": "docker-compose up --build --force-recreate --remove-orphans pgadmin",
"dev:app": "yarn workspace app run dev",
"dev:api": "docker-compose up --build api",
"dev:declaration": "docker-compose up --build --renew-anon-volumes --force-recreate --remove-orphans declaration",
"dev:simulateur": "yarn workspace simulateur run dev",
"dev:maildev": "docker-compose up --build maildev",
"docker:prod": "docker-compose -f docker-compose.build.yml up --build",
"egapro": "docker exec -it $(basename $PWD)_api_1 egapro",
Expand All @@ -26,14 +24,13 @@
"check-all": "scripts/check-all",
"setup-python": "scripts/postinstall",
"test:api:docker": "docker exec -it $(basename $PWD)_api_1 py.test -vv --cov",
"test:api": "cd packages/api && EGAPRO_DBPORT=5436 EGAPRO_DBNAME=test_egapro ./venv/bin/py.test -vv --cov",
"reverse-proxy": "docker-compose up --build --force-recreate --remove-orphans reverse_proxy"
"test:api": "cd packages/api && EGAPRO_DBPORT=5436 EGAPRO_DBNAME=test_egapro ./venv/bin/py.test -vv --cov"
},
"devDependencies": {
"@semantic-release/changelog": "^6.0.2",
"@semantic-release/git": "^10.0.1",
"@socialgouv/releaserc": "^1.1.1",
"concurrently": "^7.2.2",
"concurrently": "^8.2.0",
"semantic-release": "^19"
}
}
}
Loading

0 comments on commit 704a087

Please sign in to comment.