Skip to content

How to set up GreenCity project locally

greatpanda1603 edited this page Apr 21, 2020 · 15 revisions

Follow these guidelines for setting up GreenCity locally on your system. This is highly recommended if you want to contribute regularly.

For some of the contribution workflows, you need to have GreenCity running locally. For example, previewing coding challenges or debugging and fixing bugs in the codebase.

Preparing the development environment

Once you have the prerequisites installed, you need to prepare your development environment. This is common for many development workflows, and you will only need to do this once. Follow these steps to get your development environment ready:

  • Install Git or your favorite Git client, if you haven't already. Update to the latest version; the version that came bundled with your OS may be outdated.
  • Verify if you are using Java 8 (newer versions of Java might cause malfunctioning in unit tests).
  • Install Node.js https://nodejs.org/uk/download/
  • Install PostgreSQL 9.5 or higher https://www.postgresql.org/download/
  • Open SQL Shell press and in order to create new greencity database enter the command

CREATE DATABASE greencity;

N.B.! The password does not show up in the terminal when you type it, but that is for security reasons. Just try typing your password out, and hitting enter.

  • Install liquibase https://download.liquibase.org/
  • Install RabbitMQ https://www.rabbitmq.com/install-windows.html

Clone your copy of GreenCity

'Cloning' is where you download a copy of a repository from a remote location that is either owned by you or by someone else. In your case, this remote location is your fork of GreenCity's repository that should be available at https://github.com/YOUR_USER_NAME/GreenCity.

Run these commands on your local machine:

  1. Open a Terminal / Command Prompt / Shell in your projects directory i.e.: /yourprojectsdirectory/
  2. Clone your fork of GreenCity, replacing YOUR_USER_NAME with your GitHub Username

git clone --depth=1 https://github.com/YOUR_USER_NAME/ GreenCity.git

This will download the entire GreenCity repository to your projects directory.

Note: --depth=1 creates a shallow clone of your fork, with only the most recent history/commit.

Setup an upstream to the main repository

Now that you have downloaded a copy of your fork, you will need to set up an upstream.

As mentioned earlier, the main repository at https://github.com/ita-social-projects/GreenCity is often referred to as the upstream repository. Your fork at https://github.com/YOUR_USER_NAME/GreenCity is often referred to as the origin repository. You need a reference from your local clone to the upstream repository in addition to the origin repository. This is so that you can sync changes from the main repository without the requirement of forking and cloning repeatedly.

  1. Change directory to the new GreenCity directory:

cd GreenCity

  1. Add a remote reference to the main GreenCity repository:

git remote add upstream https://github.com/ita-social-projects/GreenCity

  1. Ensure the configuration looks correct:

git remote -v

The output should look something like below:

origin https://github.com/YOUR_USER_NAME/GreenCity.git (fetch) origin https://github.com/YOUR_USER_NAME/GreenCity.git (push) upstream https://github.com/ita-social-projects/GreenCity.git (fetch) upstream https://github.com/ita-social-projects/GreenCity.git (push)

Running GreenCity locally on your machine

Front-end

Clone the front-end part of the project called GreenCityClient using the following URL https://github.com/ita-social-projects/GreenCityClient.git Check if you have node, npm and Angular CLI installed: run sequentially the following commands in the terminal:

  • node -v
  • npm -v
  • ng version (if it is not installed, run npm install @angular/cli)

In order to launch the compilation and start front-end part of the project run sequentially the following commands in the terminal:

  • npm install
  • ng serve

Back-end

Configuring dependencies / setting up the environment variable file You should create environmental variables that are defined in application-dev.properties.

If you are using IntelliJ IDEA go to Run / Edit Configurations / in Spring Boot drop down list select GreenCityApplication, then press on the ‘list’ button on the right end of Environment variables field. Below is the list of environment variables you need to update (fill in the Value fields).

EditConfigurations

EnvironmentalVariables

Eventually you are ready to run the application.