Skip to content

Python Flask Api Starter Project using Docker, Swarm, SQLAlchemy, Marshmallow and Best Practices!

License

Notifications You must be signed in to change notification settings

rbarbioni/python-flask-api

Repository files navigation

py-flask-api

Standard Flask project API and Database using tools and best practices.

Github Actions Status

CI

Application Checklist

  • Python 3.6
  • Flask
  • SQLAlchemy
  • Marshmallow
  • Dynaconf
  • Blueprint
  • Gunicorn
  • Pipenv
  • Docker
  • Docker-Compose
  • Gelf Logger
  • Flake8
  • Sentry
  • Prometheus
  • Swagger
  • Unit-Tests
  • Integration-Tests

Pyenv and Pipenv

To run this project locally, you need to install pyenv and pipenv in order to create the Python virtual environments This project use Python 3.6

Pyenv

Install Pyenv

Pipenv

Install Pipenv

Before Run

If you don't have python 3.6 installed, run

pyenv install 3.6.9

Pipenv will use python 3.6.9 just instaled

make install

To activate this project's virtualenv, run pipenv shell.

make shell

How To Run

Docker-Compose

Just run the command

make run/docker-compose

Docker-Compose Only Structure

Just run the command

make run/docker-compose-structure

Local

Before, check if mysql is running correctly

docker ps

Just run the command

make run/local

Docker Only

Before, check if mysql is running correctly

docker ps

Just run the command

make run/docker

Lint

Just run the command

make lint

Unit Tests

Just run the command

make test

Unit Tests

Just run the command

make run/docker-compose-structure
make test/integration

Docker Swarm

To learn more about Docker Swarm, visit https://prometheus.io This project is configured to run with docker swarm. First configure docker swarm Create Docker Swarm node

docker swarm init --advertise-addr [your-localhost-ip-v4]

Create and initialize stack

docker stack deploy --compose-file="docker-compose.yml" py-api

Docker Swarm configuration is defined in deploy configuration in docker-compose.yml file

Replace Project Name

Just run the command

find . -type f -exec sed -i "s/py-api/yourprojectname/g" {} +

Prometheus Metrics

To learn more about Prometheus, visit https://prometheus.io To access local metrics, access: http://localhost:5000/metrics Or http://your-ipv4-ip:5000/metrics

Sentry

To learn more about Sentry, visit https://sentry.io Create a free Sentry account Passing as application arguments the Sentry DSN

export SENTRY_DSN=YOUR-SENTRY-DSN

Contributors

Just don't commit directly on master, push a branch and Pull Request.

About

Python Flask Api Starter Project using Docker, Swarm, SQLAlchemy, Marshmallow and Best Practices!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published