chore: add documentation
parent
76d8b3868a
commit
cb4f9b2766
104
README.md
104
README.md
|
@ -1,2 +1,104 @@
|
||||||
# boussole-pluss
|
# Bousolle PLUSS
|
||||||
|
|
||||||
|
Le projet backend contient la partie backend de la Bousolle PLUSS. Le projet frontend, le fontend communiquant avec le backend.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
En utilisant docker-compose:
|
||||||
|
`docker-compose build` en modifiant au préalable l'argument BACKEND_BASE_URL du fichier
|
||||||
|
docker-compose.yml pour spécifier l'URL sur laquelle pointera le backend.
|
||||||
|
`docker-compose up` pour lancer le frontend et backend.
|
||||||
|
|
||||||
|
Exemple de configuration Nginx compatible avec le docker-compose de ce projet (URL_EXTERNE est à remplacer
|
||||||
|
par l'URL publique) :
|
||||||
|
|
||||||
|
```
|
||||||
|
upstream springboot {
|
||||||
|
server 127.0.0.1:8191;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
server_name URL_EXTERNE;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://127.0.0.1:8190;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /api {
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Host $host;
|
||||||
|
proxy_set_header X-Forwarded-Server $host;
|
||||||
|
proxy_set_header X-Forwarded-Port $server_port;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_set_header X-NginX-Proxy true;
|
||||||
|
|
||||||
|
rewrite ^/api/(.*)$ /$1 break;
|
||||||
|
proxy_pass http://springboot;
|
||||||
|
}
|
||||||
|
|
||||||
|
error_log /var/log/nginx/pluss_error.log;
|
||||||
|
|
||||||
|
listen [::]:80;
|
||||||
|
listen 80;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Ceci est un exemple à ne pas utiliser sur un environnement de production.
|
||||||
|
|
||||||
|
## Administration
|
||||||
|
|
||||||
|
Par la suite, `__URL__` est l'URL du backend, `__USER__` et `__PASSWORD__` le nom de compte et mot de passe à créer / utiliser.
|
||||||
|
### Créer un nouveau compte
|
||||||
|
```bash
|
||||||
|
curl --location --request POST '__URL__/api/auth/signup' \
|
||||||
|
--header 'Content-Type: application/json' \
|
||||||
|
--data-raw '{
|
||||||
|
"username": "__USER__",
|
||||||
|
"password": "__PASSWORD__"
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
### Se connecter
|
||||||
|
```bash
|
||||||
|
curl --location --request POST '__URL__/api/auth/signin' \
|
||||||
|
--header 'Content-Type: application/json' \
|
||||||
|
--data-raw '{
|
||||||
|
"username": "__USER__",
|
||||||
|
"password": "__PASSWORD__"
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
Cet appel renverra un token à réutiliser pour l'ensemble des requêtes. Par exemple :
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"token": "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJkZW1vIiwiaWF0IjoxNjY1NjY5NjUyLCJleHAiOjE2NjU2NzMyNTJ9.i426thZKL4-JvOt9ZeG2D1O6O-xlSiPoCMiKysHYzCkHVNrnxKetq8xKRNCTnbpLV-wagpOw2g-om34k2jtHIw",
|
||||||
|
"refreshToken": "de73adcb-a5a8-4675-8bb3-5536651be0f9",
|
||||||
|
"id": 11,
|
||||||
|
"username": "demo"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Afficher les balises (axe)
|
||||||
|
```bash
|
||||||
|
curl --location --request GET '__URL__/api/axes' \
|
||||||
|
--header 'Authorization: Bearer TOKEN'
|
||||||
|
```
|
||||||
|
Le TOKEN est à remplacer par celui reçu.
|
||||||
|
|
||||||
|
### Ajouter une question à un axe
|
||||||
|
```bash
|
||||||
|
curl --location --request POST '__URL__/api/questions' \
|
||||||
|
--header 'Authorization: Bearer TOKEN' \
|
||||||
|
--header 'Content-Type: application/json' \
|
||||||
|
--data-raw '
|
||||||
|
{
|
||||||
|
"axe": "URL_BALISE_1",
|
||||||
|
"label": "Question 1",
|
||||||
|
"description": "Description .."
|
||||||
|
}
|
||||||
|
'
|
||||||
|
```
|
||||||
|
Il faut spécifier URL_BALISE_1 comme étant l'URL de la balise 1 récupérer dans la requête précédente.
|
||||||
|
Par exemple : `__URL__/axes/1`
|
|
@ -10,16 +10,12 @@ RUN java -Djarmode=layertools -jar bousole-pluss-backend.jar extract
|
||||||
|
|
||||||
FROM eclipse-temurin:17-jre-alpine
|
FROM eclipse-temurin:17-jre-alpine
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
||||||
USER root
|
USER root
|
||||||
RUN addgroup -S pluss && adduser -S pluss -G pluss
|
|
||||||
|
|
||||||
ENV CORS_ALLOWED_ORIGINS=$CORS_ALLOWED_ORIGINS
|
|
||||||
|
|
||||||
USER pluss:pluss
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY --chown=pluss:pluss --from=builder /app/dependencies/ ./
|
COPY --from=builder /app/dependencies/ ./
|
||||||
COPY --chown=pluss:pluss --from=builder /app/snapshot-dependencies/ ./
|
COPY --from=builder /app/snapshot-dependencies/ ./
|
||||||
COPY --chown=pluss:pluss --from=builder /app/spring-boot-loader/ ./
|
COPY --from=builder /app/spring-boot-loader/ ./
|
||||||
COPY --chown=pluss:pluss --from=builder /app/application/ ./
|
COPY --from=builder /app/application/ ./
|
||||||
ENTRYPOINT java org.springframework.boot.loader.JarLauncher
|
ENTRYPOINT java org.springframework.boot.loader.JarLauncher
|
||||||
|
|
|
@ -1,29 +1,16 @@
|
||||||
|
version: '2'
|
||||||
services:
|
services:
|
||||||
frontend:
|
frontend:
|
||||||
build:
|
build:
|
||||||
context: frontend/
|
context: frontend/
|
||||||
args:
|
args:
|
||||||
BACKEND_BASE_URL: http://localhost:8080
|
BACKEND_BASE_URL: http://pluss.itsonus.fr/api
|
||||||
ports:
|
ports:
|
||||||
- "3000:80"
|
- "8190:80"
|
||||||
networks:
|
|
||||||
- front-tier
|
|
||||||
- back-tier
|
|
||||||
# configs:
|
|
||||||
# - httpd-config
|
|
||||||
|
|
||||||
backend:
|
backend:
|
||||||
build: backend/
|
build: backend/
|
||||||
ports:
|
ports:
|
||||||
- "8080:8080"
|
- "8191:8080"
|
||||||
volumes:
|
volumes:
|
||||||
- ./data:/app/data
|
- ./data:/app/data # H2 database
|
||||||
environment:
|
|
||||||
- CORS_ALLOWED_ORIGINS=http://localhost:8080
|
|
||||||
networks:
|
|
||||||
- back-tier
|
|
||||||
|
|
||||||
networks:
|
|
||||||
# The presence of these objects is sufficient to define them
|
|
||||||
front-tier: {}
|
|
||||||
back-tier: {}
|
|
||||||
|
|
Loading…
Reference in New Issue