Code Monkey home page Code Monkey logo

docker-continuous-deployment's Introduction

Continuous Deployment with Docker

Description

This project shows a web application built using a microservices architecture.

There are two microservices:

  • rest-count implemented in Python (Flask microframework) using a Redis database
  • rest-ip implemented in Node.js (Express framework) using a MongoDB database

Using consul-template you can generate a dynamic Nginx configuration so that you can deploy new microservices version with no downtime.

You can find additional information on my Slideshare presentation "Always be shipping"

Diagram

Prerequisites

Docker 1.11

docker-compose 1.7

Getting started

Run the following commands in terminal (the first time you have to wait for a few minutes to download the Docker base images):

docker-compose -f application/docker-compose.yml up -d

open your browser to http://localhost:8080/

you can check the Consul state on http://localhost:8500/ui/

now edit rest-count/main.py (for example, you can increase the version to 1.1)

docker build -t francescou/rest-count rest-count/

docker-compose -f application/docker-compose.yml up -d restcountprimary

sleep 15

docker-compose -f application/docker-compose.yml up -d restcountbackup

the updated microservice will be deployed with no downtime.

You can also modify the rest-ip microservice in the same way (see rest-ip/app.js).

Scaling microservices

this section will explain how to can scale up and down docker-compose services.

open your browser to http://localhost:8500/ui/. There you will find a rest-count service, running on two nodes (one primary and one backup). Note that each node is a Docker container. Execute

docker-compose -f application/docker-compose.yml scale restcountprimary=3

check again http://localhost:8500/ui to ensure that there are now four rest-count instance (three primary and one backup).

Make a few requests to http://localhost:8080/api/v1/count and then run docker-compose -f application/docker-compose.yml logs to see how requests are processed by different rest-count instances.

You can now scale down the rest-count service without having any down time, e.g.:

docker-compose -f application/docker-compose.yml scale restcountprimary=2

Again, you can check http://localhost:8500/ui to see that there are now only two primary instances.

docker-continuous-deployment's People

Contributors

francescou avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

andieandpal

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.