Skip to content
Snippets Groups Projects
getting_started.md 4.44 KiB
Newer Older
  • Learn to ignore specific revisions
  • # Getting started with Ecolyo Agent
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    This section will allow you to launch a proper local environment for Ecolyo-Agent
    
    !!! info ""
        If you are a new developer tasked to work on this project, check the [setup your environment](../../setup_your_environment.md).
    
    ## ![gitlab](../../img/gitlab-logo.svg) Repositories
    
    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 backend gitlab repository](https://forge.grandlyon.com/web-et-numerique/factory/llle_project/backoffice-server)
    
    ## Local usage
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    ### Installation of the project
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    To install required node modules, open a terminal on the root folder of the backoffice-client project and type the following command:
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    ```sh
    
    Rémi PAILHAREY's avatar
    Rémi PAILHAREY committed
    yarn install
    ```
    
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    Before launching the application, ensure you've properly filled the `.env` file according to the template. If needed please refer to a team member.
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    In order to launch the project in local with the backend working launch the following command
    
    Rémi PAILHAREY's avatar
    Rémi PAILHAREY committed
    
    ```bash
    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_
    
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    - The backend Go app, from the image located on its Gitlab repository
    
    Rémi PAILHAREY's avatar
    Rémi PAILHAREY committed
    - The mongo Database, from the DockerHub image
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    - The Nginx server with a local configuration located in nginx/site.conf
    
    Rémi PAILHAREY's avatar
    Rémi PAILHAREY committed
    
    To stop it properly use
    
    ```bash
    yarn local-down
    ```
    
    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.
    
    
    > :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.
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    #### Backend and Database
    
    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)
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    #### Nginx
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    The nginx server redirects https requests from front-end to the backend on port 1443.
    
    Rémi PAILHAREY's avatar
    Rémi PAILHAREY committed
    
    It has two configuration files :
    
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    - `nginx/site.conf`, used for local development
    - `nginx/site.prod.conf`, used for production
    
    Rémi PAILHAREY's avatar
    Rémi PAILHAREY committed
    
    The nginx server needs local ssl certificates in order to run an interact with backend, these certificates are present in the project.
    
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    #### Check success
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    To check if the application starts successfully, launch the command
    
    Rémi PAILHAREY's avatar
    Rémi PAILHAREY committed
    
    ```bash
    docker logs backoffice-client_backend_1
    ```
    
    You should obtain the following messages:
    
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    > --- Server is starting ---  
    
    Rémi PAILHAREY's avatar
    Rémi PAILHAREY committed
    > Token signing key set  
    > Mock OAuth2 server Listening on: http://localhost:8090  
    
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    Once the application is started, you can access it here: [localhost](https://localhost)
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    ## Alpha usage
    
    Guilhem CARRON's avatar
    Guilhem CARRON committed
    
    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
    
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    ```sh
    
    docker build . -t registry.forge.grandlyon.com/web-et-numerique/factory/llle_project/backoffice-<server/client>:your-tag
    
    Guilhem CARRON's avatar
    Guilhem CARRON committed
    ```
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    
    
    Guilhem CARRON's avatar
    Guilhem CARRON committed
    - Push the image
    
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    ```sh
    
    docker push registry.forge.grandlyon.com/web-et-numerique/factory/llle_project/backoffice-<server/client>:your-tag
    
    Guilhem CARRON's avatar
    Guilhem CARRON committed
    ```
    
    - 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
    
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    ```sh
    
    Guilhem CARRON's avatar
    Guilhem CARRON committed
    docker-compose up -d
    ```
    
    - If you have access denied issue, try to docker login
    
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    ```sh
    
    docker login registry.forge.grandlyon.com/web-et-numerique/factory/llle_project/
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    - 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
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    ```sh
    
    docker pull registry.forge.grandlyon.com/web-et-numerique/factory/llle_project/backoffice-<server/client>:your-tag
    
    Guilhem CARRON's avatar
    Guilhem CARRON committed
    
    docker-compose up -d
    ```
    
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    If you need to work with prices on alpha, you will need to init the prices database.
    
    Guilhem CARRON's avatar
    Guilhem CARRON committed
    
    - First get the mysql container id
    
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    ```sh
    
    Guilhem CARRON's avatar
    Guilhem CARRON committed
    docker ps
    ```
    
    - Then get into the container
    
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    ```sh
    
    Guilhem CARRON's avatar
    Guilhem CARRON committed
    docker exec -it <container-id> bash
    ```
    
    - Then execute the mysql script that imports all the prices in DB
    
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    ```sh
    
    Guilhem CARRON's avatar
    Guilhem CARRON committed
    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 !