In project tech-stack:
- Python 3.6
- Django 2.0
- Postgres 9.6
- Redis
Requirements
- Docker Toolbox (for windows)
(! Important ) Any docker-compose or docker-machine should be run under Docker Quickstart Terminal
-
Start Docker Quickstart Terminal
-
Build containers:
docker-compose build
-
Run django related commands:
docker-compose run web python3 manage.py makemigrations docker-compose run web python3 manage.py migrate
-
Start services:
docker-compose up
-
In Docker Quickstart Terminal you will find the IP of the machine
- Inside project is found .env file, please find ALLOWED_HOSTS.
- Append you IP in ALLOWED_HOSTS environment variable
Docker Services may not be running when running unittest
docker-compose run web python3 manage.py test -k
This is done using Postman REST Client Please download Postman Collection from
https://www.getpostman.com/collections/67cea2d1dad0feaea246
Sample api call:
Action | Http Method | URL | REQUEST BODY DATA |
---|---|---|---|
Create | POST | http://IP:8000/restaurant/ | { "name": "Berlin 4" } |
List | GET | http://IP:8080/restaurant/ | |
Retrieve | GET | http://IP:8080/restaurant/pk/ | |
Update | PUT | http://IP:8000/restaurant/pk/ | { "name": "Berlin 333", "opens_at":"09:00:00", "closes_at": "22:00:00" } |
Delete | DELETE | http://IP:8000/restaurant/pk/ |
* Content-Type: application/json
<IP> ===> Docker machine IP
<pk> ===> Primary Key of Model Restaurant
Sample URL: http://192.168.99.100:8080/restaurant/1/ (pk=1)