Skip to content

jmpainter/askdarcel-api

 
 

Repository files navigation

askdarcel-api Build Status

This project exposes the API endpoints for supporting the askdarcel-web project, which is built using a Ruby on Rails API Server

Onboarding information

https://sheltertech.quip.com/oSdpAVfvDbPq/ShelterTech-AskDarcel-Developer-Engineer

Docker-based Development Environment (Recommended)

Requirements

Docker Community Edition (CE) >= 17.06 Docker Compose >= 1.18

Download and install the version of Docker for your OS.

Creating the .env file

The .env file is a de facto file format that allows you to specify environment variables that can be read by an application. It makes it easier to pass environment variables to an application without manually having to set them in the environment. It is supported by:

In the root of the repo cloned to your local machine, create a file named .env with the credentials listed in this document.

Set up the project

This is not a full guide to Docker and Docker Compose, so please consult other guides to learn more about those tools.

# Build (or rebuild) Docker images
$ docker-compose build

# Start the database container (in the background with -d)
$ docker-compose up -d db

# (Optional) start the background worker container (in the background with -d)
$ docker-compose up -d worker

# Generate random database fixtures
$ docker-compose run --rm api rake db:setup db:populate

# Start the Rails development server in the api container (in the foreground)
$ docker-compose up api

# Stop all containers, including background ones
$ docker-compose stop

Running Postman tests from the command line

# Reset DB with initial database fixtures
$ docker-compose run --rm api rake db:setup db:populate

# Run Docker container that executes Postman CLI tool named newman
$ docker-compose run --rm postman

Alternative database setup

# Populate the database with an old dump of the database (circa mid-2017)
$ docker-compose run --rm api rake db:create db:schema:load linksf:import

# Populate the database with a direct copy of the live staging database.
# - Ask technical team for the staging database password.
$ docker-compose run -e STAGING_DB_PASSWORD=<...> --rm api rake db:setup db:import_staging

macOS-based Development Environment Not Using Docker

Install Dependencies

  1. Install Homebrew.
  2. Install rbenv and ruby-build.
  • brew install rbenv
    • Follow further setup instructions (including updating your bash profile) from the link above.
    • Add the following lines to your ~/.bash_profile
    export PATH="$HOME/.rbenv/bin:$PATH"
    eval "$(rbenv init -)"
    
  • brew install ruby-build
  1. Install postgres.
  • brew install postgresql
    • Follow further setup instructions displayed after installation.
  • brew services start postgres

Set up the project

After cloning the repository and cding into the workspace:

  1. Install the required ruby version.
  • rbenv install
  1. Install the bundle gem if it isn't yet installed.
    • which bundle || gem install bundle
  2. Install the required gems.
  • bundle install If encounter "command not found" error, run -source ~/.bash_profile
  1. Set up the Algolia credentials

    • Create a .env file in the root of your askdarcel-api directory
    • Populate that file with the backend environment variables found here
  2. Set up the development database and load dummy data.

  • rake db:create:all
  • rake db:migrate
  • rake linksf:import

Alternatively, you can generate random fixtures:

  • rake db:setup db:populate
  1. (Optional) Run the background job worker.
  • To run a worker to continuously process background jobs:
    • rake jobs:work
  • To run a worker to process all existing background jobs and exit:
    • rake jobs:workoff
  1. Run the development server.
  • rails s -b 0.0.0.0
  1. Do NOT do sudo install -rails

About

Backend of the "Ask Darcel" app.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 96.6%
  • HTML 2.4%
  • Other 1.0%