Skip to content

Latest commit

 

History

History
169 lines (100 loc) · 4.65 KB

README.rst

File metadata and controls

169 lines (100 loc) · 4.65 KB

Request-Yo-Racks REST API

https://coveralls.io/repos/github/request-yo-racks/api/badge.svg?branch=master

A REST API for Request-Yo-Racks.

Attention!

Before starting, please refer to the full setup guide to ensure that your keys are configured correctly and that you have minikube setup properly. Once the external services are running on minikube you can move forward to the next steps.

Quickstart

Deploy the latest release in the minikube environment:

TAG=$(git describe --abbrev=0) make deploy-minikube-api deploy-minikube-celery-worker

After a few seconds, the latest release of the API server will be available at http://api.192.168.99.100.nip.io/.

If you want to build the master branch from source, simply run:

eval $(minikube docker-env)
make build-docker deploy-minikube-api deploy-minikube-celery-worker

make help will show you the available targets that will help you work on this project.

Build the documentation

The docs target of the Makefile helps you build the API documentation site easily:

make venv
make docs

Open it with:

open docs/build/html/index.html

Setup the project

The full setup guide provides instructions to help you set up the external services required by the project locally (postgresql, redis) and explains how to deploy this project on a local Kubernetes cluster (Minikube).

You can also refer to the kubernetes folder of the infra project for more details about the deployment implementation.

Required software

The software required to work on this project can be automatically installed (OSX only!) via the following command:

bash <(curl -fsSL https://raw.githubusercontent.com/request-yo-racks/api/master/bootstrap/bootstrap-osx.sh)

Local development setup

Virtual environment

Start by preparing the virtual environment for this project:

cd "${RYR_PROJECT_DIR}/api"
make venv

Flower

Flower is optional, but very convenient to monitor the Celery tasks and collect useful information for debugging them.

Deploy Flower on minikube:

make deploy-minikube-flower

Once started, flower is available at http://flower.192.168.99.100.nip.io.

API server

Open a terminal and start the API server:

make local-django-api

This command starts a local instance of the API server, and connects it automatically to the services deployed on minikube. The API is exposed at http://localhost:8000. The API server will pick up your changes automatically by performing a live reload of your code every time you update a file.

Celery worker

Open a terminal and start a celery worker:

make local-celery-worker

The Celery worker will NOT detect any changes automatically! Therefore you will have to restart it every time you make a change related to Celery (task, configuration, etc.)

Test your setup

Your terminal windows should be similar to this:

images/api+celery-worker_terminals.png

Your Flower interface should resemble this:

images/ryr_flower_monitoring.png

Query the local API server to ensure everything works:

# Health endpoint.
curl http://localhost:8000/health

# Places endpoint.
curl http://localhost:8000/places/30.318673580117846,-97.72446155548096

# Place endpoint.
curl http://localhost:8000/place/ChIJ1XxmFaC1RIYREMC4K9RM3zo/

Test your deployment

Once you are done with your changes, you can build a docker image and deploy the project on minikube to further test it:

eval $(minikube docker-env)
cd "${RYR_PROJECT_DIR}/api"
make build-docker deploy-minikube-api deploy-minikube-celery-worker