Read Fowler about Blue Green Deployment https://martinfowler.com/bliki/BlueGreenDeployment.html
By default folder structure of all BGD complex is like that:
|- /opt/
| |- blue-gree-deployment/ <- current project folder
| |- projects/ <- projects folder (docker-compose instances for projects)
| | |- project-name/ <- current project folder
| | | |- logs/ <- logs folder
| | | |- {test,stage,production}/ <- stage folder
| | | | |- {green,blue}/ <- instance folder. Here docker-compose folder is cloned
|
|- /etc/nginx/
| |- site-available/
| | |- project-name/ <- current project folder
| | | |- {test,stage,production}/ <- stage folder
| | | | |- {green,blue} <- proxy configs
| |- site-enabled/
| | |- project-name/ <- current project folder
| | | |- {test,stage,production}/ <- stage folder
| | | | |- {green,blue} <- symlink to config file (blue or green) in available folder
Running init.sh
script will deploy this structure. Options to pass to init.sh
:
-p projectName
- name for project folders in BGD structure-h baseHostName
- base host name for project that will work like *.example.com, where * will be project stage-r [email protected]
- git path to docker-compose project. It will be cloned into every instance folder
After initialization your should configure every instance of docker-compose for all stages for the project.
Init script will create two files for your server:
.env
- main paths to BGD and projects.used-ports
- here will be stored used by BGD ports for nginx proxy
If you want to customize variables in this files, you can make them from examples.
/opt/blue-green-deployment/switch.sh -p projectName -i stage
/opt/blue-green-deployment/migrate.sh -p projectName -i stage
/opt/blue-green-deployment/fallback.sh -p projectName -i stage