Vuepress通过Webhook,拉取并打包 Docker Image

Posted by Leon on 2020-04-14

说明

项目的帮助文档使用了Vuepress构建,为此制作了Docker镜像。

此Docker可以将公共或私有仓库Vuepress Git源代码通过Webhook自动触发,并拉取并重新打包。

Docker Pull Command: docker pull funnyzak/vuepress-webhook

Webhook Url: http://hostname:9000/hooks/vuepress-webhook


Available Configuration Parameters

The following flags are a list of all the currently supported options that can be changed by passing in the variables to docker with the -e flag.

  • USE_HOOK : The web hook is enabled as long as this is present.
  • GIT_REPO : URL to the repository containing your source code
  • GIT_BRANCH : Select a specific branch (optional)
  • GIT_EMAIL : Set your email for code pushing (required for git to work)
  • GIT_NAME : Set your name for code pushing (required for git to work)
  • WEBHOOK_LIST : Optional. Notify link array that send notifications when pull code, each link is separated by |
  • HOOK_NAME : Optional. When setting WEBHOOK_LIST, it is best to set a HOOK name

Volume Configuration

  • /app/target : builded code files will move to this folder.
  • /app/code : source code dir. Will automatically pull the code.
  • /root/.ssh : If it is a private repository, please set ssh key

ssh-keygen

ssh-keygen -t rsa -b 4096 -C "[email protected]" -N "" -f ./id_rsa


Docker-Compose

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
version: '3'
services:
vuepress:
image: funnyzak/vuepress-webhook
privileged: true
container_name: vuepress
working_dir: /app/code
logging:
driver: 'json-file'
options:
max-size: '1g'
tty: true
environment:
- TZ=Asia/Shanghai
- LANG=C.UTF-8
- USE_HOOK=1
- [email protected]:username/repo_name.git
- GIT_BRANCH=master
- GIT_EMAIL=youremail
- GIT_NAME=yourname
- WEBHOOK_LIST=http://link1.com/hook|http://link2.com/hook
- HOOK_NAME=vuepress_app
restart: on-failure
ports:
- 9000:9000 # webhook port
volumes:
- ./target:/app/target
- ./code:/app/code
- ./ssh:/root/.ssh

Nginx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
server {
listen 80;
server_name yourdomain.com;

underscores_in_headers on;
ssl off;

location / {
root /mnt/app/vuepress/target;
index index.html index.htm;
}

location /webhook {
proxy_set_header Host $host;
proxy_set_header X-Real-Ip $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://127.0.0.1:9000/hooks/vuepress-webhook;
}

error_page 404 /404.html;
}

Please configure according to the actual deployment path and port.