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.
Deploy the latest release in the minikube environment:
TAG=$(git describe --abbrev=0) make deploy-minikube-api deploy-minikube-celery-workerAfter 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-workermake help will show you the available targets that will help you work on this project.
The docs target of the Makefile helps you build the API documentation site easily:
make venv
make docsOpen it with:
open docs/build/html/index.htmlThe 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.
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)Start by preparing the virtual environment for this project:
cd "${RYR_PROJECT_DIR}/api"
make venvFlower is optional, but very convenient to monitor the Celery tasks and collect useful information for debugging them.
Deploy Flower on minikube:
make deploy-minikube-flowerOnce started, flower is available at http://flower.192.168.99.100.nip.io.
Open a terminal and start the API server:
make local-django-apiThis 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.
Open a terminal and start a celery worker:
make local-celery-workerThe 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.)
Your terminal windows should be similar to this:
Your Flower interface should resemble this:
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/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
