Docker deployment specification-directory structure and auxiliary tools

Insert picture description here

Article Directory

Docker deployment specification-directory structure and auxiliary tools

This specification summarizes the practice of multiple projects, through the standardization of the directory structure, combined with auxiliary tools , can reduce the repetitive work and communication workload in the deployment of multiple nodes and new environments, and greatly improve deployment efficiency.

Standardize the deployment directory structure

The planning of the directory structure is based on the following considerations:

  • Multiple systems can be deployed on one host
  • A system should be "self-consistent", with complete logic, and all documents involved in the system are self-contained
  • The directory result is as simple as possible and easy to manage (the dockcer-compose up --build command is no longer executed), the local configuration modification is completed by the volume folder or file mounting method to cover the file in the container

The directory structure is as follows:

  • [Product]-deplopy:
  • docker-compose.yml : main file
  • init-data : initialized data, such as database scripts, initial data when the program is loaded, etc.
  • web/nginx.conf: nginx configuration folder, such as routing configuration, security settings, etc.
  • web/ca/ : The certificate file directory of nginx.
  • mysql/ : msql initialization script, etc.
  • mongo/ : The initialization script of mongodb, etc.
  • run-data : data in the process of running, such as database storage directory, temporary file directory of the program
  • mysql/ :msql database file directory
  • mongo/ :mongodb database file directory
  • log : program log target
  • back : program backup directory

Auxiliary tools to solve

Auxiliary tool reference: github code dc-help
tool installation

git clone https://github.com/perfectstorm88/dc-help
cd dc-help
python setup.py install

In the directory where docker-compose.yml is located, executedc-help -h

usage: dc-help COMMAND

docker-compose辅助工具,帮助管理镜像、版本文件

optional arguments:
  -h, --help            show this help message and exit

COMMAND:
  {image,init-data,run-data}
    image               管理docker-compose.yml中的镜像,打包、装载
                        、清理、升级
    init-data           init-data的压缩和解压缩
    run-data            run-data的压缩和解压缩2

among themdc-help image -h

usage: dc-help COMMAND image [-h] (--pack | --unpack | --clear | --upgrade)

optional arguments:
  -h, --help  show this help message and exit
  --pack      对镜像进行自动打包
  --unpack    对镜像进行自动装载
  --clear     对镜像文件进行清理
  --upgrade   对镜像文件进行自动装载,然后升级`

Features

  • dc-help image --pack:Automatically package the image of the project
  • dc-help image --unpack:Automatically load the image of the project
  • dc-help image --clear:Clean up the image of the project
  • dc-help image --upgrade: Scan the backup directory, determine whether there is a mirror update, perform automatic loading, and update cluster services
  • dc-help init-data --pack: Automatically pack and compress the init-data file of the project
  • dc-help init-data --pack: Automatically decompress the init-data file of the project
  • dc-help run-data --pack: Automatically pack and compress the run-data file of the project
  • dc-help run-data --pack: Automatically decompress the run-data file of the project

reference