-
Be sure you have installed docker and docker-compose
-
In backend directory exists a file called
.env.example, you need to copy it and rename the copy with.env, then fill it with the correct information, a example of this file is:MYSQL_HOST=db MYSQL_USER=root MYSQL_PASSWORD=pa55w0rd11 MYSQL_DATABASE=chatweb MYSQL_TEST_DATABASE=test MYSQL_TEST_HOST=192.168.99.100 JWT_SECRET=53cr3tAs you can see the
MYSQL_HOSTits calleddb, it means that in non test environment the backend use the network attached in docker-compose, in this case isdb.MYSQL_PASSWORDis configured indocker-compose.ymlyou can set it if you want.MYSQL_DATABASEandMYSQL_TEST_DATABASEi sugest that use the same names because the sql files are configurated with that names, or if you want to change it, you can change all the entries in files/backend/sql/db_schema.sqland/backend/sql/db_schema_test.sql.MYSQL_TEST_HOSTis a special case, becasue if you are usingdocker toolboxon windows (im not sure if works in the same way in Mac), you need to put the IP address provided withDocker quickstart terminal, generally is the same everywhere (192.168.99.100); if you are in linux (or another SO that runs docker nativelly) you can set this value withlocalhost. This is because the tests are runned on the host machine and not in the container, in the host you don't have access todbnetwork.In
JWT_SECRETyou can set it with any string. -
In the frontend directory you need to configure the host of the backend endpoint, to do it, copy the file called
/frontend/src/settings.example.jsand rename the copy with/frontend/src/settings.jsthe port8080is configured indocker-compose.yml, y ou can change it if you want, but be aware to modify it in both files. -
Networks and endpoints configured, we need to install front and backend dependencies, move to the frontend and backend, then run
npm install. After front end dependencies are installed, runnpm run buildExtra step if you are using a unix based SO: you may need to give execution permissions to a file located in
/backend/wait-for-it.shrunningchmod +x ./backend/wait-for-it.shon the root of the repository. -
Now, we have front and backend ready to start, move to the root of the repository (chat-web) and run
docker-compose up, now you can access to the frontend usingHOST:9000and backendHOST:8080
Following the same example as the docker instructions, you just replace the host and db ip adadress with localhost.
Only the backend has tests (i have no time for frontend :c). For run backend test just move to the backend directory and run npm test.
WARNING: Database must be up, if you are using docker, run docker-compose up before run tests.
