Git Product home page Git Product logo

flask-app's Introduction

Python Requirements Travis Coverage Code Climate Docker

flask-app

Example app for demonstrating continuos integration/continuos deployment (CI/CD) workflows -- inspired by dockercloud-quickstart-python.

The example flask app connects to a redis instance and displays a simple visit counter and the hostname of the docker container serving the app.

Getting started

Install docker and run:

docker-compose up
# docker-compose stop

Otherwise, for the standalone web service:

pip install -r requirements.txt
python app.py

Visit http://localhost:5000

Development

Create a new branch off the develop branch for features or fixes.

After making changes rebuild images and run the app:

docker-compose build
docker-compose run -p 5000:5000 web python app.py
# docker stop flaskapp_redis_1

Tests

Standalone unit tests run with:

pip install pytest pytest-cov pytest-flask
pytest --cov=web/ --ignore=tests/integration tests

Integration and unit tests run with:

docker-compose -f test.yml -p ci build
docker-compose -f test.yml -p ci run test python -m pytest --cov=web/ tests
# docker stop ci_redis_1 ci_web_1

Commits tested via travis-ci.org. Test coverage reported to codecov.io. Code quality reported via codeclimate.com. Requirements inspected with requires.io.

After testing, submit a pull request to merge changes with develop.

Automated builds and redeploys

Docker images are automatically built from changes to repo branches and tags via docker hub autobuilds.

Using a cluster provisioned on docker cloud, services are created as stacks from stack/ to nodes tagged infra or compute. Setting stack option autoredeploy: true continuously redeploys new images built from recent commits.

Image tagging and deployment scheme:

Note: To create sites at subdomains using virtual hosts as shown in stack/, assumes domain records have been configured with:

  • CNAME record * to example.com.
  • A record @ to the (floating) IP of the haproxy load balancer

Monitoring, log aggregation and scaling

Agent containers by sematext deployed to each node. Alert thresholds trigger web hooks to scale services under load.

Notifications

Updates and alerts pushed via Slack:

  • github
  • travis-ci
  • docker
  • sematext

flask-app's People

Contributors

brennv avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.