Skip to content

Getting started

Will Lin edited this page Sep 28, 2021 · 24 revisions

This guide helps you get started running and interacting with a local development server and tests.

See also Bloom's setup wiki.

Installing packages

Decide whether to use the Docker containers to manage postgres and redis or have those services installed directly on your machine.

Install node

NOTE: At the time of editing, this project requires Node 14.

  • Make sure you have node installed with npm -v
  • Install node if you don't have it. You may want to use nvm if you need access to multiple versions. Here is a super helpful link on installing node without sudo.

Install yarn

  • Check if you have yarn installed with yarn -v
  • If you don't have yarn, install with npm install --global yarn

Install and set up postgres

  1. Install PostgreSQL
  • On Linux, you can follow these steps.
  • If you are hoping to rely on your username with sudo -u postgres createuser your_username -s, you'll need to edit your pg_hba.conf to trust local connections to the db.
  • Otherwise, you can create a user WITH a password (like bloom-dev, password bloom1) and put that in your .env:
    sudo -u postgres psql
    CREATE USER lemmy WITH PASSWORD 'myPassword';
    
  • Restart the service afterward: sudo service postgresql restart
  1. Verify you have a postgres server running (this should happen automatically in the last step) with psql postgres. This should launch you into a psql shell, which you can exit with \quit.
  2. Create a database with a name matching your username:
$ psql postgress
postgres=# CREATE DATABASE your_username_here;
postgres=# \quit

Install redis

  1. Install Redis
  2. Open a terminal and start a redis server with redis-server.
  3. To check that the server is running, open another terminal and run redis-cli ping.

Setting up the repo and database

Cloning the repository

  1. Join GitHub.

  2. Install git on your machine.

  3. Clone the repository.

    Run this in your terminal (and/or refer to this guide):

    git clone [email protected]:CityOfDetroit/bloom.git
    
  4. In backend/core, copy .env.template into .env

  5. Edit .env to look like this:

    PORT=3100
    NODE_ENV=development
    DATABASE_URL=postgres://your_ldap_here:something@localhost:5432/bloom
    REDIS_TLS_URL=redis://127.0.0.1:6379/0
    REDIS_URL=redis://127.0.0.1:6379/0
    REDIS_USE_TLS=0
    THROTTLE_TTL=60
    THROTTLE_LIMIT=2
    EMAIL_API_KEY='SOME-LONG-SECRET-KEY'
    EMAIL_FROM_ADDRESS='Bloom Dev Housing Portal <[email protected]>'
    APP_SECRET='SOME-LONG-SECRET-KEY'
    CLOUDINARY_SECRET=CLOUDINARY_SECRET
    CLOUDINARY_KEY=CLOUDINARY_KEY
    SECRET='SOME-LONG-SECRET-KEY'
    PARTNERS_BASE_URL=http://localhost:3001
    NEW_RELIC_APP_NAME=Bloom Backend Local
    NEW_RELIC_LICENSE_KEY=
    NEW_RELIC_ENABLED=false
    NEW_RELIC_LOG_ENABLED=false
    GOOGLE_API_ID=
    GOOGLE_API_KEY=
    GOOGLE_API_EMAIL=
    PARTNERS_PORTAL_URL=http://localhost:3001
    
  6. Run yarn install:all from the main directory, which will run yarn install at both the top level and in backend/core.

  7. To seed the database, yarn db:reseed

  • psql may give you permissions issues here. Locally you can give yourself superuser permissions as a workaround.
  1. Check that you can connect to the bloom database and run a simple query:

    $ psql bloom
    bloom=# select count(*) from units;
    

Using Docker containers

  1. Install Docker

  2. Install Docker Compose

  3. Add this line to your ~/.bashrc file for authentication to the postgres container as the correct user:

    export PGUSER=postgres
    
  4. Navigate to the bloom directory that you created when you cloned the repo and run the following:

    docker-compose up redis postgres
    
    • You should see some output indicating that the containers have successfully started.

    • If you wish to stop running the services, you can Ctl-C to kill the processes.

    • If you wish to run the containers in the background and not need to keep the terminal open, kill the previous containers and run:

      docker-compose up -d redis postgres