Skip to content
Snippets Groups Projects
Commit 03bb456e authored by Bastien DUMONT's avatar Bastien DUMONT :angel:
Browse files

Merge branch 'ecolyo-agent-documentation' into 'master'

Ecolyo agent documentation

See merge request !25
parents 93a12d32 67cd7720
No related branches found
No related tags found
1 merge request!25Ecolyo agent documentation
Pipeline #52501 passed
# Deploy Ecolyo-Agent application
# Deploy Ecolyo-Agent back-office
This app is deployed on an Openshift cluster provided by Synaaps, all instructions for authentification and deployment are given [here](https://forge.grandlyon.com/web-et-numerique/factory/llle_project/backoffice-server/-/blob/dev/k8s/README.md)
## CICD
This app has a gitlab CI/CD pipeline you can find in the .gitlab-ci.yml file.
On the dev branch and on merge requests, the pipeline will run a build stage and a quality stage.
On dev and master branches, the pipeline will run a docker image build that you can find in the GitLab container registry.
## Alpha usage
In order to test the app on alpha you can do the following steps:
- Build locally your docker image for the client and/or the server
```sh
docker build . -t registry.forge.grandlyon.com/web-et-numerique/factory/llle_project/backoffice-<server/client>:your-tag
```
- Push the image
```sh
docker push registry.forge.grandlyon.com/web-et-numerique/factory/llle_project/backoffice-<server/client>:your-tag
```
- Connect to alpha in ssh, go to ecolyo-agent > docker-compose.yml and change the image tag for client and/or server
- Then launch the app, it will pull automatically the new images
```sh
docker-compose up -d
```
- If you have access denied issue, try to docker login
```sh
docker login registry.forge.grandlyon.com/web-et-numerique/factory/llle_project/
```
- If you want to update alpha using the same image tag with edited image, just pull manually your new image and rebuild the concerned image
```sh
docker pull registry.forge.grandlyon.com/web-et-numerique/factory/llle_project/backoffice-<server/client>:your-tag
docker-compose up -d
```
If you need to work with prices on alpha, you will need to init the prices database.
- First get the mysql container id
```sh
docker ps
```
- Then get into the container
```sh
docker exec -it <container-id> bash
```
- Then execute the mysql script that imports all the prices in DB
```sh
mysql --local-infile=1 -uroot -p backoffice < /dbinit/dbinit.sql
```
You will be prompted for the admin password, use the db password set in the .env file.
Now you're ready to edit your prices on alpha !
......@@ -9,21 +9,17 @@ This section will allow you to launch a proper local environment for Ecolyo-Agen
This project is split between a backend and frontend, each project has its own repository.
[Ecolyo-Agent front-end gitlab repository](https://forge.grandlyon.com/web-et-numerique/factory/llle_project/backoffice-client)
[Ecolyo-Agent Client repository](https://forge.grandlyon.com/web-et-numerique/factory/llle_project/backoffice-client)
[Ecolyo-Agent backend gitlab repository](https://forge.grandlyon.com/web-et-numerique/factory/llle_project/backoffice-server)
[Ecolyo-Agent Server repository](https://forge.grandlyon.com/web-et-numerique/factory/llle_project/backoffice-server)
## Local usage
### Installation of the project
!!! note
Before launching the application, ensure you've properly filled the `.env` file according to the template. If needed please refer to a team member. The template contains
To install required node modules, open a terminal on the root folder of the backoffice-client project and type the following command:
```sh
yarn install
```
Before launching the application, ensure you've properly filled the `.env` file according to the template. If needed please refer to a team member.
- IMAGE_FOLDER: this variable specify the folder where ecogestures images are located. By default, you can place this folder at the same level as your project for a local usage. (not inside the project). For alpha, rec/prod environment, make sure the path indicated in docker-compose volumes correspond with the location of the image file on the server.
- MOCK_OAUTH2: Set this variable to true while in local, so the OAuth2 dance will be mocked by backend and you will be able to login to your application.
In order to launch the project in local with the backend working launch the following command
......@@ -31,40 +27,32 @@ In order to launch the project in local with the backend working launch the foll
yarn local-up
```
This command will launch the app from the _docker-compose.local.yml_ file, which will launch 3 docker images and start the react app with _yarn start_
This command will launch the app from the _docker-compose.local.yml_ file, which will launch 4 images and start the react app with _yarn start_
- The backend Go app, from the image located on its Gitlab repository
- The mongo Database, from the DockerHub image
- A mySQL database, from the DockerHub image
- A phpMyAdmin to browse the database, from the DockerHub image
- The Nginx server with a local configuration located in nginx/site.conf
To stop it properly use
```bash
yarn local-down
```
???note "Nginx info"
The nginx server redirects https requests from front-end to the backend on port 1443.
This app runs in https, such as the backend, to access it go on <https://localhost/>
Also make sure you have HTTPS env variable set to true.
Do not use the app with the port 3000, you won't be able to login.
It has two configuration files :
> :warning: **If you are launching the project from a Windows OS** : Make sure to comment the 'extra_hosts' lines in the docker-compose.local file. Otherwise, you you won't be able to access your machine's localhost from the docker container.
- `nginx/site.conf`, used for local development
- `nginx/site.prod.conf`, used for production
#### Backend and Database
The nginx server needs local ssl certificates in order to run an interact with backend, these certificates are present in the project.
In order to get Backend documentation, please refer directly to the [backend readme](https://forge.grandlyon.com/web-et-numerique/factory/llle_project/backoffice-server/-/blob/dev/README.md)
#### Nginx
The nginx server redirects https requests from front-end to the backend on port 1443.
It has two configuration files :
- `nginx/site.conf`, used for local development
- `nginx/site.prod.conf`, used for production
To stop it properly use
The nginx server needs local ssl certificates in order to run an interact with backend, these certificates are present in the project.
```bash
yarn local-down
```
#### Check success
??? note "for windows users"
:warning: **If you are launching the project from a Windows OS** : Make sure to comment the 'extra_hosts' lines in the docker-compose.local file. Otherwise, you you won't be able to access your machine's localhost from the docker container.
To check if the application starts successfully, launch the command
......@@ -80,64 +68,42 @@ You should obtain the following messages:
Once the application is started, you can access it at <https://localhost>
## Alpha usage
!!! tip
This app runs in https, such as the backend, to access it go on <https://localhost/>
Also make sure you have HTTPS env variable set to true.
**Do not** use the app with the port 3000, you won't be able to login.
In order to test the app on alpha you can do the following steps:
## Ecolyo Agent - Server
- Build locally your docker image for the client and/or the server
### Features
```sh
docker build . -t registry.forge.grandlyon.com/web-et-numerique/factory/llle_project/backoffice-<server/client>:your-tag
```
- Push the image
```sh
docker push registry.forge.grandlyon.com/web-et-numerique/factory/llle_project/backoffice-<server/client>:your-tag
```
- Authentification using OAuth2
- Connected admins can use an API to edit and save different sections of the newsletters that will be sent to Ecolyo users
- Exposes a public route to get the sections of a specific or the last newsletter
- Connect to alpha in ssh, go to ecolyo-agent > docker-compose.yml and change the image tag for client and/or server
### Setup
- Then launch the app, it will pull automatically the new images
This backend should be deployed with the frontend using [local command](#local-usage)
```sh
docker-compose up -d
```
- If you have access denied issue, try to docker login
However this backend can be run in standalone :
```sh
docker login registry.forge.grandlyon.com/web-et-numerique/factory/llle_project/
```
- Set a .env file at the root and add all variables declared in the template.env
- (Optionnal) Create new certificates by running cd dev_certificates && ./generate-certificates.sh
- Run `docker-compose up -d`
- If you want to update alpha using the same image tag with edited image, just pull manually your new image and rebuild the concerned image
Once deployed, you can access to a Swagger documentation of the API on <https://${HOSTNAME}/swagger/index.html>
```sh
docker pull registry.forge.grandlyon.com/web-et-numerique/factory/llle_project/backoffice-<server/client>:your-tag
### Launch locally
docker-compose up -d
```
Launch all necessary services :
If you need to work with prices on alpha, you will need to init the prices database.
Run `docker-compose up -d`
- First get the mysql container id
In local you can access phpmyadmin interface to manage the database : <http://localhost:8008>
Launch the server by pressing F5 on vscode, you will see the logs on the debug console.
```sh
docker ps
```
- Then get into the container
```sh
docker exec -it <container-id> bash
```
- Then execute the mysql script that imports all the prices in DB
```sh
mysql --local-infile=1 -uroot -p backoffice < /dbinit/dbinit.sql
```
All API routes are available on <https://localhost:1443>
You will be prompted for the admin password, use the db password set in the .env file.
### Build image for local
Now you're ready to edit your prices on alpha !
`docker build . -t backoffice-server`
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment