Skip to content

How to run

Daniel Sousa edited this page May 6, 2022 · 30 revisions
Split

🚀 How to run?

You can run this project in 3 different ways:

  1. Using Docker Docker
    1. Development Mode
    2. Production Mode
  2. Tradicional Way

On topics bellow you can find more details about this ways to run this project.

Using Docker

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.

Development Mode

This method it's used to run the project like you do using 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 bellow:

  1. Make sure you have Docker installed and running;
  2. Run this command on the project root folder: docker-compose --file docker-compose.dev.yaml up -d;
    • This command it will run the Docker Compose, but using the file to dev. environment.
  3. Run this command to give execution permissions: chmod +x database/rs-init.sh;
    • This file is used to init the database.
  4. After that run: docker exec mongo /scripts/rs-init.sh;
  5. Open your Docker and verify if the containers are created and running
    • You can do that using docker ps on your terminal too.

Docker Desktop with Containers created
Docker Desktop Output

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

Production Mode

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 bellow to recreate the containers.

So let's start:

  1. First, verify if you have Docker installed and running;
  2. Run this command on the project root folder: docker-compose up -d;
  3. Run this command to give execution permissions: chmod +x database/rs-init.sh;
    • This file is used to init the database.
  4. After that run: docker exec mongo /scripts/rs-init.sh;
  5. Open your Docker and verify if the containers are created and running
    • You can do that using docker ps on your terminal too.

Note: the output it's the same as before, only change the mode how this containers "works";


Note: in both ways you need make a change on your .env file (in root folder)

For that, search for DB_HOST and change the value from localhost to mongo, the result is:

#docker database container name
DB_HOST=mongo



Tradicional Way

Clone this wiki locally