Skip to content

Setting up a local environment

little_pinecone edited this page Aug 20, 2021 · 16 revisions

This section contains details of setting up a working development environment.

Backend

Prerequisites

Versions and credentials

You'll find all default versions and credentials for dependencies in the backend/docker/.env file.

Required dependencies

Below you'll find all dependencies that have to be run before starting the application.

Database

To start the default database:

cd docker
docker-compose -f docker-compose-database.yml up -d 

The database will be available for the backend module under the jdbc:postgresql://localhost:5432/efficientmvpexample url.

Optional dependencies

Below you'll find all dependencies that can be run to facilitate working on the application.

Monitoring

If you want to test the monitoring services remember to run the application in docker as well:

cd docker
docker-compose -f docker-compose-database.yml -f docker-compose-app.yml -f docker-compose-monitoring.yml up -d

SonarQube

To start an automatically configured SonarQube instance:

cd docker
docker-compose -f docker-compose-sonar.yml up -d 

This command starts two services: sonarqube and sonarqube_config. It's important to start them both together the first time. sonarqube_config uses the default SonarQube credentials to import custom profiles for code analysis. Since SonarQube requires password change on the first time a user logs in there is no point in running sonarqube_config again on the same environment. Running it again when profiles has been already imported is redundant even if you adjust the credentials.

Shutting dependencies down

To stop all dependencies:

cd docker
docker-compose -f docker-compose-database.yml -f docker-compose-app.yml -f docker-compose-monitoring.yml down

You can add --volumes option if you want to remove all named volumes.

Summary

What docker services are run for each dependency category mentioned above:

Database SonarQube Monitoring
postgres sonarqube prometheus
sonarqube_config promtail
loki
grafana

Result of the docker ps command when all dependencies and the app are running as docker services:

screenshot of all docker services

Required profiles

Make sure to run the Spring Boot application with the dev and init profiles during development. Otherwise, some configuration may be incorrect (invalid database connection, not being able to populate the database with data, etc.). The monitoring services will work correctly if the application is ran in a docker container configured in the docker-compose-app.yml file.

Frontend

Prerequisites

You can use Node Verion Manager to see which version is available on your environment:

nvm ls