Docker搭配Gitbook进行文档部署

构建目录结构

nginx-docker
    --default.conf
    --docker-compose.yml
    --web
        ---note

拉取文档仓库并编译

git pull && rm -rf _book && gitbook install && gitbook build .

编写nginx服务配置

➜  nginx-docker cat default.conf 
server {
  listen 80;
  server_name your_hostname;
  root /web;

  location /note {
    alias /web/note/_book;
    index index.html;
  }

  location  ^~ gitbook/ {
    root /web/gitbook/;
   }
}

通过docker启动

编写docker-compse.yml

➜  nginx-docker cat docker-compose.yml 
version: '2'

services:
  nginx:
    image: nginx:latest
    restart: always
    container_name: nginx-web
    network_mode: host
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./web:/web
      - ./default.conf:/etc/nginx/conf.d/default.conf

启动容器

➜  docker-compose up -d

你可能感兴趣的:(Docker搭配Gitbook进行文档部署)