Skip to content

Building the application

Dawid Niezgódka edited this page Dec 7, 2022 · 8 revisions

This page presents two ways to build the application.

Option 1: Docker Compose

The preferred way to run the application is to use Docker Compose. This option lets you quickly and seamlessly start the application using a single command.

Requirements: Git, Docker, and Docker Compose must be installed on your machine.

Carry out the following steps to run the application:

  1. Open the folder of choice and run: git clone https://github.com/amosproj/amos2022ws04-specitem-database.git.
  2. Change the directory to the project's root: cd amos2022ws04-specitem-database.
  3. Run the following command: docker-compose up.
  4. You can now visit localhost:3000 and start interacting with the app.

Trouble-shooting

If you're encountering any problems running the app using docker, please check on the following points.

  1. Make sure that these properties are set as follows:
spring.datasource.url=jdbc:postgresql://db:5432/specitems
spring.datasource.username=postgres
spring.datasource.password=password123
  1. Run docker ps and make sure that no other containers are running that have the same name and/or use the ports: 5432, 8080, 3000.

Option 2: Starting components manually

Requirements: Git, Maven, npm, and postgres should be installed on your machine.

If you can't run the docker or option 1 fails to run the app (for whatever reason), you can set up each component of the app manually. Please note that you must adjust the configuration file for this option to function correctly. To edit the properties, you can run: vim amos2022ws04-specitem-database/code/src/main/resources/application.properties. Adjust the file as follows:

spring.datasource.url=jdbc:postgresql://localhost:5432/specitems
spring.datasource.username=dbuser
spring.datasource.password=user123

To run the app, follow these steps:

  1. Open the psql console (psql postgres). Create the specitems database and the user for interacting with it:
CREATE DATABASE specitems;
CREATE ROLE dbuser WITH LOGIN PASSWORD 'user123';
  1. Create the folder for the project, open it and run: git clone https://github.com/amosproj/amos2022ws04-specitem-database.git.
  2. To run the backend execute these commands (test is optional):
cd amos2022ws04-specitem-database/code
mvn test
mvn package
java -jar target/specitem-database-0.0.1-SNAPSHOT.jar 

You should see a message that the backend listens on :8080.

  1. To run the frontend, go back to the root of the project, then change to the frontend folder: cd frontend/specitem and run: npm install && npm start
  2. You can now visit localhost:3000 and start interacting with the app.
Clone this wiki locally