Coder Social home page Coder Social logo

docker-nginx-blue-green's Introduction

Docker blue green upstreams for nginx with ngx_http_perl_module

Maintenance Join the chat at https://gitter.im/docker-nginx-blue-green Build Status

Proof of concept for blue-green upstream proxy with nginx + ngx_http_perl_module.

Docker run

This method pulls the latest image from Docker Hub. Ready for use as a stateless container proxy for use on container platforms like ECS, EKS

Objectives

  1. Set up environment file and docker run
  2. Print current upstream
  3. Switch upstream
  4. Clean up container

Copy sample environment file, modify values to suit, and docker run

# cp .env.sample .env
# docker run -p 80:80 -d --name nginx --env-file ./.env meappy/nginx-blue-green

Print current upstream

# docker exec -it nginx /deploy.py -p
Current deploy status: apache:80

Switch upstream

# docker exec -it nginx /deploy.py -d green
Current deploy status: apache:81

Clean up container

# docker stop nginx
# docker rm nginx

ย 

Docker Compose method

This method pulls an nginx image from Docker Hub. Docker volume is used with deploy script. Good for use as stateful setup where persistent storage is used.

Objectives

  1. Start up nginx + Apache containers
  2. Setup config.ini and deploy blue or green upstream
  3. Test

Start up nginx + Apache containers

docker-compose up -d 

Setup config.ini and deploy blue or green upstream

# cp config.ini.sample config.ini

# ./deploy.py -d blue 
Current deploy status: blue:8081

Test

# ./deploy.py -p 
Current deploy status: blue:8081

# curl -H 'Host: poc' -k -iL http://127.0.0.1
HTTP/1.1 200 OK
Server: nginx/1.15.12
Date: Thu, 23 May 2019 07:19:00 GMT
Content-Type: text/html
Content-Length: 45
Connection: keep-alive
Last-Modified: Mon, 11 Jun 2007 18:53:14 GMT
ETag: "2d-432a5e4a73a80"
Accept-Ranges: bytes

<html><body><h1>It works!</h1></body></html>

docker-nginx-blue-green's People

Contributors

meappy avatar hridoy-122 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.