Skip to content

Latest commit

 

History

History
175 lines (111 loc) · 4.62 KB

how_to_run.md

File metadata and controls

175 lines (111 loc) · 4.62 KB

How to run?

The application can be run in development or production mode by applying the following steps.

Prerequisites

The following apps should be installed before running the application:

  • A command line app
  • Docker Desktop

Note
For more information regarding the system requirements, etc. refer to the following pages:
Install on Mac
Install on Windows
Install on Linux


Running app in Development mode

In order to run the application in development mode, apply the following steps:

  1. Run Docker desktop.

  1. Open command prompt window and clone the project from GitHub using the following command:
git clone https://github.com/yildizmy/pet-clinic.git

  1. Change the current directory to the project directory where the docker-compose.yml file is in:
cd pet-clinic

  1. Run the following command (by running this command, the database container is built and starts up):
docker compose up --build

  1. Open backend project using IntelliJ IDEA and then select Run > Edit Configurations and add the following values to the Environment variables field.
DB_NAME=pet_clinic;DB_USERNAME=postgres;DB_PASSWORD=pass;JWT_SECRET=appSecretKey

Note
If the Environment variables field is not available, it can be added via Modify options menu on the Rub/Debug Configurations dialog (Alt+E).


Then close the dialog and run the application.

Note
If Lombok requires enabled annotation processing dialog appears at this stage, click Enable annotation processing button.


  1. Open another command prompt window/tab and change the current directory to the frontend project:
cd pet-clinic/frontend

  1. Run the following commands respectively:
npm install
npm start

Then the application starts on http://localhost:3000/ and will be opened on your default browser. At this step, the following accounts can be used for logging in to the application. Alternatively, API requests can be sent to the endpoints using Postman, etc. For this purpose, see the details on How to test? section.

User Accounts

username: johndoe
password: johnd@e
role: admin

username: lindacalvin
password: lindac@lvin
role: admin

username: jeffreytaylor
password: jeffreyt@ylor
role: user

Running app in Production mode

In order to run the application in production mode, apply the following steps:

  1. Run Docker desktop.

  1. Open command prompt window and clone the project from GitHub using the following command:
git clone https://github.com/yildizmy/pet-clinic.git

  1. Change the current directory to the project directory where the docker-compose.yml file is in:
cd pet-clinic

  1. Run the following command:

Warning
Before running this command, if exists, delete previously composed containers (db, backend, frontend), images (pet-clinic-backend, pet-clinic-frontend) and volumes (pet-clinic_db-data) belonging to the application. On the other hand, if the app is running on IntelliJ IDEA, stop it to prevent a possible port error.

docker compose -f docker-compose.yml -f docker-compose.prod.yml up --build

By running this command, the app and database containers are built and start up. After this step is completed, the application will be available on http://localhost:3000 and the accounts given in the "User Accounts" section can be used for logging in to the application. Alternatively, API requests can be sent to the endpoints using Postman, etc. For this purpose, see the details on How to test? section.

For connecting to the application database, the following url and credentials given in the .env file can be used.

url: jdbc:postgresql://localhost:5432/<${DB_NAME}>

Troubleshooting

If there is any process using the same port of the application, "ports are not available" or "port is already in use" errors might be encountered. In this situation, terminating that process and restarting the related containers will fix the problem. If the problem continues, delete the containers (db, backend and frontend) and re-run the docker compose command in the previous step.


Documentation

docker compose up