Skip to content

Commit

Permalink
restore original structure and move cookiecutter part in cookiecutter…
Browse files Browse the repository at this point in the history
…-drf-microservice
  • Loading branch information
alainivars committed Jun 14, 2019
1 parent 742d704 commit 967af62
Show file tree
Hide file tree
Showing 48 changed files with 148 additions and 952 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ python:
sudo: false

env:
- TOX_ENV=pep8
- TOX_ENV=py36-django211
- TOX_ENV=coverage_combine
- TOX_ENV=docs

matrix:
Expand Down
142 changes: 59 additions & 83 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Build Status](https://travis-ci.org/alainivars/drf-microservice.png?branch=master)](https://travis-ci.org/alainivars/drf-microservice)
[![PyPI version](https://badge.fury.io/py/drf-microservice.svg)](https://badge.fury.io/py/drf-microservice)
[![Documentation Status](https://readthedocs.org/projects/drf-microservice/badge/?version=latest)](http://alpha-vantage.readthedocs.io/en/latest/?badge=latest)
[![Documentation Status](https://readthedocs.org/projects/drf-microservice/badge/?version=latest)](http://drf-microservice.readthedocs.io/en/latest/?badge=latest)
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/alainivars/drf-microservice.svg)](http://isitmaintained.com/project/alainivars/drf-microservice "Average time to resolve an issue")
[![Percentage of issues still open](http://isitmaintained.com/badge/open/alainivars/drf-microservice.svg)](http://isitmaintained.com/project/alainivars/drf-microservice "Percentage of issues still open")
[![Coverage Status](https://coveralls.io/repos/github/alainivars/drf-microservice/badge.svg?branch=master)](https://coveralls.io/github/alainivars/drf-microservice?branch=master)
Expand All @@ -9,85 +9,58 @@
[![PyPi wheel](https://pypip.in/wheel/drf-microservice/badge.svg)](https://pypi.python.org/pypi/drf-microservice/)


# About drf-microservice Cookiescutter
drf-microservice is a ready-to-use API skeleton, Cookiescutter generates it, add your endpoints, test it, package it, validate it on stage and deploy it.
# About drf-microservice
drf-microservice is a ready-to-use API skeleton, generated by [cookiecutter-drf-microservice](https://github.com/alainivars/cookiecutter-drf-microservice), add your endpoints, test it, package it, validate it on stage and deploy it.
It sounds simple and it is.
Something disturb you in the code? Don't hesitate to submit a pull request and contribute.

### Releases Notes
- 0.7.0: restore original struct and move cookiecutter in cookiecutter-drf-microservice
- 0.6.1: Update dependencies
- 0.6.0: total refactoring for add cookiecutter
- 0.5.2: fix depencies security alert
- 0.6.0: start to productionize and add cookiecutter
- 0.5.2: fix dendencies security alert
- 0.5.1: fix some document presentation on github and pypi
- 0.5.0: Initial publication version

### AWS secret required
```shell
APPNAME_USERNAME_PASSWD => a client API password
DRF_MiCROSERVICE_USERNAME_PASSWD => a client API password
SECRET_KEY => the secret key
```
### ENV required
```shell
AWS_REGION_NAME => default="eu-east-1"
AWS_APPNAME_SECRET_NAME =>The name of the secret bucket
AWS_DRF_MiCROSERVICE_SECRET_NAME =>The name of the secret bucket
```
## To setup

If needed install [cookiecutter](https://github.com/audreyr/cookiecutter):
```bash
pip install cookiecutter
```
Cookiescutter will generate it for you:
```
cookiecutter gh:alainivars/drf-microservice 00:31:00
github_username [my-github-user-name]: alainivars
github_repository_name [my-repository]: my-drf-microservice
app_name [my_app]: my_api
email [my-email@my-domain.my]: alainivars@gmail.com
description [The description of my drf app]: A simple demo on how to use drf-microservice generator
```
Now we just jump in the new directory and run tox to:
- be sure that everything as worked fine
- generate the documentation
```bash
cd my-drf-microservice
tox
```
An virtualenv is already ready for you at:
```shell
tox -l
py36-django222
```
or you can create your
## To install
todo
```shell
python3 -m venv /pass/to/venv
git clone xxx
cd xxx
python3 -m venv /pass_to/venv/drf-microservice
```
- for bash, zsh
```shell
source .tox/py36-django222/bin/activate
source /pass_to/venv/drf-microservice/bin/activate
```
- for fish
```shell
source .tox/py36-django222/bin/activate.fish
source /pass_to/venv/drf-microservice/bin/activate.fish
```
python setup.py test
python manage.py migrate
```
- for bash, zsh
```shell
SECRET_KEY=my_secret_key
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
SECRET_KEY=my_secret_key python manage.py test
```
- for fish
```shell
env SECRET_KEY=my_secret_key
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
/usr/bin/env SECRET_KEY=my_secret_key python manage.py createsuperuser
```
- then run it
```shell
SECRET_KEY=my_secret_key
python manage.py runserver
SECRET_KEY=my_secret_key python manage.py runserver
```
- if you have any problem or you want enable the debug mode
```shell
Expand All @@ -96,7 +69,7 @@ ENABLE_DEBUG=1


## API
To see the Dynamic documentation for the API
To see the documentation for the API
Login at
```shell
curl --request POST \
Expand Down Expand Up @@ -128,7 +101,7 @@ curl --request GET \
```
![Dynamic documentation](media/docs.png)

## Testing
## testing
You can run the tests by:
```shell
SECRET_KEY=my_secret_key python manage.py test
Expand All @@ -139,7 +112,7 @@ python setup.py test
```
or by
```shell
DJANGO_SETTINGS_MODULE={{cookiecutter.app_name}}.config.local SECRET_KEY=my_secret_key pytest
DJANGO_SETTINGS_MODULE=drf-microservice.config.local SECRET_KEY=my_secret_key pytest
```

## Security check
Expand All @@ -150,11 +123,13 @@ SECRET_KEY=my_secret_key python manage.py check --deploy
### Build and run the image with Docker

#### Build the Docker image:
# WORK IN PROGRESS
````shell
docker build -t my-drf -f Dockerfile.drf-microservice .
docker build -t my-nginx -f Dockerfile.nginx .
#docker build -t drf-microservice-db -v db_volume:/var/lib/postgresql/data postgres:9.6
docker build -t drf-microservice -f Dockerfile.drf-microservice .
docker-compose up
#docker build -t my-nginx -f Dockerfile.nginx .
````

#### Run the container:
````shell
docker network create my-network
Expand All @@ -163,47 +138,48 @@ docker run -d --name nginx --net my-network -p "5000:80" my-nginx
````
If you want to change the port binding, it's here...

#### Backup your db:
````shell
sudo docker run --rm -it \
-v pg_backups:/pg_backups \
-v /host/dir/pg_backups:/host_backups \
alpine:latest
````
Then in the container
````shell
cp /pg_backups/* /host_backups/
````

### Build and run wit docker-compose
```shell
docker-compose up
```

### Functionalities DONE
- support basic auth
### DONE

- support basic auth removed
- support token auth
- endpoint json file POST,GET
- endpoint login/logout
- endpoint get tocken
- postgreSQL support

### DevOps tools DONE
- endpoint get status Icinga2

#### Functionalities TODO
- AWS ssm secret
- endpoint json file DELETE,PUT?
### TODO
- AWS ssm secret and Kms
- add getSentry support
- endpoint json file DELETE, PUT?
- add some strong auth
- create differents version:
- Aws S3 support (in progress)
- Aws RDS support
- Aws Elastisearch support
- Redis support
- Aerospike support
- S3
- RDS
- postgreSQL
- Redis
- Aerospike
- ...

#### DevOps tools TODO
- the docker-image configuration file (in progress)
- the docker-compose configuration file (in progress)
- the Packer configuration file
- the Terraform configuration file AWS
- the Terraform configuration file GCD
- the Terraform configuration file Azure
- add getSentry support
- add Aws Cloudwatch support
- the Ansible configuration file AWS
- the Ansible configuration file GCD
- the Ansible configuration file Azure
- the Juju configuration file AWS
- the Juju configuration file GCD
- the Juju configuration file Azure
#### for different use-case
- create the docker-image file
- create the ansible file
- create the terraform file
- create the kubertes file
- create the Juju file

2 changes: 1 addition & 1 deletion conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
master_doc = 'index'
project = u'drf-microservice'
copyright = u'2017-2019'
copyright = u'2019'
version = 'latest'
release = 'latest'
exclude_patterns = ['_build']
Expand Down
7 changes: 0 additions & 7 deletions cookiecutter.json

This file was deleted.

Loading

0 comments on commit 967af62

Please sign in to comment.