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.
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
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
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.
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:
flask-app:latest
follows the master branch and deploys to production at http://flask-app.example.comflask-app:develop
follows the develop branch and deploys to staging at http://staging.flask-app.example.com
Note: To create sites at subdomains using virtual hosts as shown in stack/
, assumes domain records have been configured with:
CNAME
record*
toexample.com.
A
record@
to the (floating) IP of the haproxy load balancer
Agent containers by sematext deployed to each node. Alert thresholds trigger web hooks to scale services under load.
Updates and alerts pushed via Slack:
- github
- travis-ci
- docker
- sematext