Skip to content
Snippets Groups Projects
getting_started.md 4.58 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 Client repository](https://forge.grandlyon.com/web-et-numerique/factory/llle_project/backoffice-client)
    
    [Ecolyo-Agent Server repository](https://forge.grandlyon.com/web-et-numerique/factory/llle_project/backoffice-server)
    
    !!! 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
    
        - `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.
        - `USERINFO_URL`: Set this variable to `http://localhost:8090/admininfo` to log in with admin role or to `http://localhost:8090/animatorinfo` to log in with animator role
    
    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 4 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
    
    - A mySQL database, from the DockerHub image
    - A phpMyAdmin to browse the database, from the DockerHub image
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    - The Nginx server with a local configuration located in nginx/site.conf
    
    ???note "Nginx info"
        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
    
        The nginx server needs local ssl certificates in order to run an interact with backend, these certificates are present in the project.
    
    To stop it properly use
    
    ```bash
    yarn local-down
    ```
    
    ??? 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.
    
    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>  
    
    Once the application is started, you can access it at <https://localhost>
    
    !!! 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.
    
    Once an animator/admin is connected, he must call the /whoAmI route to access his XSRF-TOKEN and add it in a header named "XSRF-TOKEN" for all requests going to the backend.
    
    
    ## Ecolyo Agent - Server
    
    - 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
    
    This backend should be deployed with the frontend using [local command](#local-usage)
    
    However this backend can be run in standalone :
    
    - 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`
    
    Once deployed, you can access to a Swagger documentation of the API on <https://${HOSTNAME}/swagger/index.html>
    
    ### Launch locally
    
    Launch all necessary services :
    
    Run `docker-compose up -d`
    
    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.
    
    All API routes are available on <https://localhost:1443>
    
    ### Build image for local
    
    `docker build . -t backoffice-server`