-
Notifications
You must be signed in to change notification settings - Fork 11
How to run
You can run this project in 3 different ways:
On the topics below you can find more details about the ways to run this project.
Docker is a powerful tool and in some cases very useful. In this section, you can find how to run this project fully in Docker.
You can also use Colima instead of docker desktop. Follow the instructions on its readme page to install it.
This method it's used to run the project like you do use a terminal, create the containers and run development commands, like yarn dev
/npm run dev
and, the most important thing, have hot reload! 😉
If you want do that, please follow the steps below:
- Make sure you have Docker installed and running;
- Duplicate the
.env.example
file, remove.example
prefix and change this variable:BACKEND_URL=http://dev-backend:3200
DB_HOST=mongo
- Run this command on the project root folder:
docker-compose --file docker-compose.dev.yaml up -d
;- This command will run the Docker Compose, but using the file to dev. environment.
- Run this command to give execution permissions:
chmod +x database/rs-init.sh
;- This file is used to init the database.
- After that run:
docker exec mongo /scripts/rs-init.sh
to create an admin user and the replica set; - Open your Docker and verify if the containers are created and running
- You can do that using
docker ps
on your terminal too.
- You can do that using
→ Docker Desktop Containers
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b20a0a82aa3f dc-frontend "…" 32 minutes ago Up 31 minutes 0.0.0.0:3000->3000/tcp frontend
eff53cef6ba5 dc-backend "…" 32 minutes ago Up 31 minutes 0.0.0.0:3200->3200/tcp, 0.0.0.0:9229->9229/tcp backend
20300f0aff1e mongo "…" 6 hours ago Up 34 minutes 0.0.0.0:27017->27017/tcp mongo
7188192e1d6f mongo "…" 6 hours ago Up 34 minutes 0.0.0.0:27018->27017/tcp mongo2
→ docker ps
Output
This method runs all the project as production mode, so, build the code and "deploy" to a new container the builded folder (like dist/
, ...).
On this way you don't have hot reload as on previous method, only use this method if have no need to change code.
- Remember: if you need to change the code using this method, is necessary follow all the process below to recreate the containers.
So let's start:
- First, verify if you have Docker installed and running;
- Duplicate the
.env.example
file, remove.example
prefix and change this variables:BACKEND_URL=http://backend:3200
DB_HOST=mongo
- Run this command on the project root folder:
docker-compose up -d
; - Run this command to give execution permissions:
chmod +x database/rs-init.sh
;- This file is used to init the database.
- After that run:
docker exec mongo /scripts/rs-init.sh
; - Open your Docker and verify if the containers are created and running
- You can do that using
docker ps
on your terminal too.
- You can do that using
Note: the output it's the same as before, only change the mode how this containers "works";
The "traditional" way it's run the project using your terminal, opening 2 terminals and run with yarn dev
/npm run dev
, but for this you need do some things first:
-
Verify if you follow the requirements to run this project;
-
Duplicate the
.env.example
file and remove.example
prefix; -
Verify if you have Docker installed and running;
-
Create a database container using the commands below:
docker-compose mongo mongo2 redis up -d
- Run this command to give execution permissions:
chmod +x database/rs-init.sh
;- This file is used to init the database.
- After that run:
docker exec mongo /scripts/rs-init.sh
.
-
Now you need to install all the dependencies, for that run on project root folder the command:
-
yarn
: if you use Yarn; -
npm i
/npm install
: if you use NPM
-
-
Now please verify if you have 2 Docker containers:
Mongo
andMongo2
; -
if you have the containers you only need to run (for each folder):
-
On Backend (
backend/
):-
yarn start:dev
(using Yarn); -
npm run start:dev
(using NPM).
-
-
On Frontend (
frontend/
):-
yarn dev
(using Yarn); -
npm run dev
(using NPM).
-
-
On Backend (