Getting started with Ecolyo Agent
This section will allow you to launch a proper local environment for Ecolyo-Agent
If you are a new developer tasked to work on this project, check the setup your environment.
Repositories
This project is split between a backend and frontend, each project has its own repository.
Ecolyo-Agent Client repository
Ecolyo-Agent Server repository
Local usage
Ecolyo Agent - Server
Here will be listed all steps to run Ecolyo Agent backend locally for development purposes.
Config folder
If you run the backend for the first time you need to setup some folders.
At the repository root, run mkdir -p mnt mnt/configs
The mnt/configs
folder will contain a tokenskey.json
file, generated when the server starts for the first time.
With assets imported (see this page for more information) the mnt
folder should look like this :
mnt
└───configs
│ tokenskey.json
└───image-lib
│ ...all email assets
└───ecogesture
│ ...all ecogesture images
Launch database
The backend needs a database to store data, to start it, run docker compose up -d
This will serve a mySQL database on port 3306
and a phpMyAdmin instance, accessible on http://localhost:8008 (login / password correspond to DATABASE_USER
and DATABASE_PASSWORD
variables in the .env
file) to browse data more easily.
Initialize fluid prices
The backend contains prices evolution for each fluids. These prices need to be initialized.
To do so, make sure the database container is up and running and run ./scripts/init-fluidprices.sh
Launch server
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
IMAGE_FOLDER
: this variable specify the folder where ecogestures images are located. By default, it should bemnt/image-lib
.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.USERINFO_URL
: Set this variable to configure the user rolehttp://localhost:8090/admininfo
to log in with admin rolehttp://localhost:8090/animatorinfo
to log in with animator role
Now, you can run the backend with VS Code, check Run and Debug
tab and click the Start
icon on Launch Backoffice Server
.
You can also press the F5 key as a shortcut.
The server is up, you should obtain the following messages in the Debug Console
:
--- Server is starting ---
Token signing key set
Mock OAuth2 server Listening on: http://localhost:8090
Hot reload could not be set up to work 100% correctly, but you can click the Restart icon (or press Ctrl+Shift+F5) in VS Code after you made some modifications to restart the server.
Stop backend
In VS Code, press the Stop icon (or press Shift+F5) to stop backend.
Then run docker-compose down
to stop database and phpMyAdmin containers
Ecolyo Agent - Client
Launch client
In the frontend repository, you can launch the client with :
yarn local-up
for windows users
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.
This command will launch the app from the docker-compose.local.yml
file, which will launch an Nginx server with a local configuration located in nginx/site.local.conf and start the react app with yarn start
The nginx server redirects https requests from front-end to the backend on port 1443.
It has two configuration files :
nginx/site.local.conf
, used for local developmentnginx/site.prod.conf
, used for production
The nginx server needs local ssl certificates in order to run an interact with backend, these certificates are present in the project.
Once the application is started, you can access it at https://localhost
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.
Stop client
To stop it properly use
yarn local-down